diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2023-09-14 19:29:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 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/CheckOperationExecutor.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/CheckOperationExecutor.java')
-rw-r--r-- | subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/CheckOperationExecutor.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/CheckOperationExecutor.java b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/CheckOperationExecutor.java new file mode 100644 index 00000000..295ac110 --- /dev/null +++ b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/operations/CheckOperationExecutor.java | |||
@@ -0,0 +1,50 @@ | |||
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; | ||
10 | |||
11 | import tools.refinery.viatra.runtime.localsearch.MatchingFrame; | ||
12 | import tools.refinery.viatra.runtime.localsearch.matcher.ISearchContext; | ||
13 | import tools.refinery.viatra.runtime.localsearch.operations.ISearchOperation.ISearchOperationExecutor; | ||
14 | |||
15 | /** | ||
16 | * Abstract base class for search operations that check only the already set variables. | ||
17 | * | ||
18 | * @noextend This class is not intended to be subclassed by clients. | ||
19 | * @since 2.0 | ||
20 | */ | ||
21 | public abstract class CheckOperationExecutor implements ISearchOperationExecutor { | ||
22 | |||
23 | /** | ||
24 | * The executed field ensures that the second call of the check always returns false, resulting in a quick | ||
25 | * backtracking. | ||
26 | */ | ||
27 | private boolean executed; | ||
28 | |||
29 | @Override | ||
30 | public void onInitialize(MatchingFrame frame, ISearchContext context) { | ||
31 | executed = false; | ||
32 | } | ||
33 | |||
34 | @Override | ||
35 | public void onBacktrack(MatchingFrame frame, ISearchContext context) { | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public boolean execute(MatchingFrame frame, ISearchContext context) { | ||
40 | executed = executed ? false : check(frame, context); | ||
41 | return executed; | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * Executes the checking operation | ||
46 | * @since 1.7 | ||
47 | */ | ||
48 | protected abstract boolean check(MatchingFrame frame, ISearchContext context) ; | ||
49 | |||
50 | } | ||