diff options
author | 2023-09-14 19:29:36 +0200 | |
---|---|---|
committer | 2023-09-14 19:29:36 +0200 | |
commit | 98ed3b6db5f4e51961a161050cc31c66015116e8 (patch) | |
tree | 8bfd6d9bc8d6ed23b9eb0f889dd40b6c24fe8f92 /subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/NACOperation.java | |
parent | Merge pull request #38 from nagilooh/design-space-exploration (diff) | |
parent | Merge remote-tracking branch 'upstream/main' into partial-interpretation (diff) | |
download | refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.gz refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.zst refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.zip |
Merge pull request #39 from kris7t/partial-interpretation
Implement partial interpretation based model generation
Diffstat (limited to 'subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/NACOperation.java')
-rw-r--r-- | subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/NACOperation.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/NACOperation.java b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/NACOperation.java new file mode 100644 index 00000000..3759e1d1 --- /dev/null +++ b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/check/NACOperation.java | |||
@@ -0,0 +1,89 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2013, Zoltan Ujhelyi, Istvan Rath and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package tools.refinery.viatra.runtime.localsearch.operations.check; | ||
10 | |||
11 | import java.util.List; | ||
12 | import java.util.function.Function; | ||
13 | |||
14 | import tools.refinery.viatra.runtime.localsearch.MatchingFrame; | ||
15 | import tools.refinery.viatra.runtime.localsearch.matcher.ISearchContext; | ||
16 | import tools.refinery.viatra.runtime.localsearch.operations.CheckOperationExecutor; | ||
17 | import tools.refinery.viatra.runtime.localsearch.operations.IPatternMatcherOperation; | ||
18 | import tools.refinery.viatra.runtime.localsearch.operations.ISearchOperation; | ||
19 | import tools.refinery.viatra.runtime.localsearch.operations.util.CallInformation; | ||
20 | import tools.refinery.viatra.runtime.matchers.backend.IQueryResultProvider; | ||
21 | import tools.refinery.viatra.runtime.matchers.tuple.VolatileModifiableMaskedTuple; | ||
22 | |||
23 | /** | ||
24 | * @author Zoltan Ujhelyi | ||
25 | * @noextend This class is not intended to be subclassed by clients. | ||
26 | */ | ||
27 | public class NACOperation implements ISearchOperation, IPatternMatcherOperation { | ||
28 | |||
29 | private class Executor extends CheckOperationExecutor { | ||
30 | private final VolatileModifiableMaskedTuple maskedTuple; | ||
31 | private IQueryResultProvider matcher; | ||
32 | |||
33 | private Executor() { | ||
34 | this.maskedTuple = new VolatileModifiableMaskedTuple(information.getThinFrameMask()); | ||
35 | } | ||
36 | |||
37 | @Override | ||
38 | public void onInitialize(MatchingFrame frame, ISearchContext context) { | ||
39 | super.onInitialize(frame, context); | ||
40 | maskedTuple.updateTuple(frame); | ||
41 | matcher = context.getMatcher(information.getCallWithAdornment()); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | protected boolean check(MatchingFrame frame, ISearchContext context) { | ||
46 | return !matcher.hasMatch(information.getParameterMask(), maskedTuple); | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public ISearchOperation getOperation() { | ||
51 | return NACOperation.this; | ||
52 | } | ||
53 | } | ||
54 | |||
55 | private final CallInformation information; | ||
56 | |||
57 | /** | ||
58 | * @since 1.7 | ||
59 | */ | ||
60 | public NACOperation(CallInformation information) { | ||
61 | super(); | ||
62 | this.information = information; | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | public ISearchOperationExecutor createExecutor() { | ||
67 | return new Executor(); | ||
68 | } | ||
69 | |||
70 | @Override | ||
71 | public String toString() { | ||
72 | return toString(Object::toString); | ||
73 | } | ||
74 | |||
75 | @Override | ||
76 | public String toString(Function<Integer, String> variableMapping) { | ||
77 | return "check neg find "+information.toString(variableMapping); | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | public List<Integer> getVariablePositions() { | ||
82 | return information.getVariablePositions(); | ||
83 | } | ||
84 | |||
85 | @Override | ||
86 | public CallInformation getCallInformation() { | ||
87 | return information; | ||
88 | } | ||
89 | } | ||