diff options
Diffstat (limited to 'subprojects/store-dse/src/main/java')
5 files changed, 13 insertions, 7 deletions
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/propagation/impl/PropagationAdapterImpl.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/propagation/impl/PropagationAdapterImpl.java index 586a8d7a..fdd19217 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/propagation/impl/PropagationAdapterImpl.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/propagation/impl/PropagationAdapterImpl.java | |||
@@ -31,6 +31,7 @@ class PropagationAdapterImpl implements PropagationAdapter { | |||
31 | PropagationResult result = PropagationResult.UNCHANGED; | 31 | PropagationResult result = PropagationResult.UNCHANGED; |
32 | PropagationResult lastResult; | 32 | PropagationResult lastResult; |
33 | do { | 33 | do { |
34 | model.checkCancelled(); | ||
34 | lastResult = propagateOne(); | 35 | lastResult = propagateOne(); |
35 | result = result.andThen(lastResult); | 36 | result = result.andThen(lastResult); |
36 | } while (lastResult.isChanged()); | 37 | } while (lastResult.isChanged()); |
@@ -40,6 +41,7 @@ class PropagationAdapterImpl implements PropagationAdapter { | |||
40 | private PropagationResult propagateOne() { | 41 | private PropagationResult propagateOne() { |
41 | PropagationResult result = PropagationResult.UNCHANGED; | 42 | PropagationResult result = PropagationResult.UNCHANGED; |
42 | for (int i = 0; i < boundPropagators.length; i++) { | 43 | for (int i = 0; i < boundPropagators.length; i++) { |
44 | model.checkCancelled(); | ||
43 | var lastResult = propagateUntilFixedPoint(i); | 45 | var lastResult = propagateUntilFixedPoint(i); |
44 | result = result.andThen(lastResult); | 46 | result = result.andThen(lastResult); |
45 | if (result.isRejected()) { | 47 | if (result.isRejected()) { |
@@ -54,6 +56,7 @@ class PropagationAdapterImpl implements PropagationAdapter { | |||
54 | PropagationResult result = PropagationResult.UNCHANGED; | 56 | PropagationResult result = PropagationResult.UNCHANGED; |
55 | PropagationResult lastResult; | 57 | PropagationResult lastResult; |
56 | do { | 58 | do { |
59 | model.checkCancelled(); | ||
57 | lastResult = propagator.propagateOne(); | 60 | lastResult = propagator.propagateOne(); |
58 | result = result.andThen(lastResult); | 61 | result = result.andThen(lastResult); |
59 | } while (lastResult.isChanged()); | 62 | } while (lastResult.isChanged()); |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/propagation/impl/rule/BoundPropagationRule.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/propagation/impl/rule/BoundPropagationRule.java index 6e6a78d2..a70292ad 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/propagation/impl/rule/BoundPropagationRule.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/propagation/impl/rule/BoundPropagationRule.java | |||
@@ -13,10 +13,12 @@ import tools.refinery.store.query.ModelQueryAdapter; | |||
13 | import tools.refinery.store.query.resultset.ResultSet; | 13 | import tools.refinery.store.query.resultset.ResultSet; |
14 | 14 | ||
15 | class BoundPropagationRule { | 15 | class BoundPropagationRule { |
16 | private final Model model; | ||
16 | private final ResultSet<Boolean> resultSet; | 17 | private final ResultSet<Boolean> resultSet; |
17 | private final BoundAction action; | 18 | private final BoundAction action; |
18 | 19 | ||
19 | public BoundPropagationRule(Model model, Rule rule) { | 20 | public BoundPropagationRule(Model model, Rule rule) { |
21 | this.model = model; | ||
20 | resultSet = model.getAdapter(ModelQueryAdapter.class).getResultSet(rule.getPrecondition()); | 22 | resultSet = model.getAdapter(ModelQueryAdapter.class).getResultSet(rule.getPrecondition()); |
21 | action = rule.createAction(model); | 23 | action = rule.createAction(model); |
22 | } | 24 | } |
@@ -27,6 +29,7 @@ class BoundPropagationRule { | |||
27 | } | 29 | } |
28 | var cursor = resultSet.getAll(); | 30 | var cursor = resultSet.getAll(); |
29 | while (cursor.move()) { | 31 | while (cursor.move()) { |
32 | model.checkCancelled(); | ||
30 | var result = action.fire(cursor.getKey()); | 33 | var result = action.fire(cursor.getKey()); |
31 | if (!result) { | 34 | if (!result) { |
32 | return PropagationResult.REJECTED; | 35 | return PropagationResult.REJECTED; |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstExplorer.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstExplorer.java index 4a75a3a6..5e2f8fa9 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstExplorer.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstExplorer.java | |||
@@ -19,14 +19,9 @@ public class BestFirstExplorer extends BestFirstWorker { | |||
19 | this.random = new Random(id); | 19 | this.random = new Random(id); |
20 | } | 20 | } |
21 | 21 | ||
22 | private boolean interrupted = false; | ||
23 | |||
24 | public void interrupt() { | ||
25 | this.interrupted = true; | ||
26 | } | ||
27 | |||
28 | private boolean shouldRun() { | 22 | private boolean shouldRun() { |
29 | return !interrupted && !hasEnoughSolution(); | 23 | model.checkCancelled(); |
24 | return !hasEnoughSolution(); | ||
30 | } | 25 | } |
31 | 26 | ||
32 | public void explore() { | 27 | public void explore() { |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/actions/BoundAction.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/actions/BoundAction.java index ed2ff33d..4da609fa 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/actions/BoundAction.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/actions/BoundAction.java | |||
@@ -23,6 +23,7 @@ public class BoundAction { | |||
23 | } | 23 | } |
24 | 24 | ||
25 | public boolean fire(Tuple activation) { | 25 | public boolean fire(Tuple activation) { |
26 | model.checkCancelled(); | ||
26 | if (this.activation != null) { | 27 | if (this.activation != null) { |
27 | throw new IllegalStateException("Reentrant firing is not allowed"); | 28 | throw new IllegalStateException("Reentrant firing is not allowed"); |
28 | } | 29 | } |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationAdapterImpl.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationAdapterImpl.java index e1a29d40..23325a1f 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationAdapterImpl.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationAdapterImpl.java | |||
@@ -56,6 +56,7 @@ public class DesignSpaceExplorationAdapterImpl implements DesignSpaceExploration | |||
56 | @Override | 56 | @Override |
57 | public boolean checkAccept() { | 57 | public boolean checkAccept() { |
58 | for (var accept : this.accepts) { | 58 | for (var accept : this.accepts) { |
59 | model.checkCancelled(); | ||
59 | if (!accept.isSatisfied()) { | 60 | if (!accept.isSatisfied()) { |
60 | return false; | 61 | return false; |
61 | } | 62 | } |
@@ -66,6 +67,7 @@ public class DesignSpaceExplorationAdapterImpl implements DesignSpaceExploration | |||
66 | @Override | 67 | @Override |
67 | public boolean checkExclude() { | 68 | public boolean checkExclude() { |
68 | for (var exclude : this.excludes) { | 69 | for (var exclude : this.excludes) { |
70 | model.checkCancelled(); | ||
69 | if (exclude.isSatisfied()) { | 71 | if (exclude.isSatisfied()) { |
70 | return true; | 72 | return true; |
71 | } | 73 | } |
@@ -75,6 +77,7 @@ public class DesignSpaceExplorationAdapterImpl implements DesignSpaceExploration | |||
75 | 77 | ||
76 | @Override | 78 | @Override |
77 | public ObjectiveValue getObjectiveValue() { | 79 | public ObjectiveValue getObjectiveValue() { |
80 | model.checkCancelled(); | ||
78 | if (objectives.size() == 1) { | 81 | if (objectives.size() == 1) { |
79 | return ObjectiveValue.of(objectives.get(0).getValue()); | 82 | return ObjectiveValue.of(objectives.get(0).getValue()); |
80 | } else if (objectives.size() == 2) { | 83 | } else if (objectives.size() == 2) { |
@@ -82,6 +85,7 @@ public class DesignSpaceExplorationAdapterImpl implements DesignSpaceExploration | |||
82 | } else { | 85 | } else { |
83 | double[] res = new double[objectives.size()]; | 86 | double[] res = new double[objectives.size()]; |
84 | for (int i = 0; i < objectives.size(); i++) { | 87 | for (int i = 0; i < objectives.size(); i++) { |
88 | model.checkCancelled(); | ||
85 | res[i] = objectives.get(i).getValue(); | 89 | res[i] = objectives.get(i).getValue(); |
86 | } | 90 | } |
87 | return ObjectiveValue.of(res); | 91 | return ObjectiveValue.of(res); |