diff options
author | 2023-09-11 19:28:59 +0200 | |
---|---|---|
committer | 2023-09-11 19:32:12 +0200 | |
commit | a18e8fb2d31e8cdd967c53a010c79dc6f104da2a (patch) | |
tree | 11f693b71ed5f67ef002c4bbd87a38a6a1eb8755 /subprojects/store-reasoning-scope/src | |
parent | feat: cancellation token for ModelStore (diff) | |
download | refinery-a18e8fb2d31e8cdd967c53a010c79dc6f104da2a.tar.gz refinery-a18e8fb2d31e8cdd967c53a010c79dc6f104da2a.tar.zst refinery-a18e8fb2d31e8cdd967c53a010c79dc6f104da2a.zip |
fix: avoid GLOP error message on stderr
Diffstat (limited to 'subprojects/store-reasoning-scope/src')
4 files changed, 14 insertions, 5 deletions
diff --git a/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/BoundScopePropagator.java b/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/BoundScopePropagator.java index 3ae4d84b..ecca6117 100644 --- a/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/BoundScopePropagator.java +++ b/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/BoundScopePropagator.java | |||
@@ -37,6 +37,7 @@ class BoundScopePropagator implements BoundPropagator { | |||
37 | queryEngine = model.getAdapter(ModelQueryAdapter.class); | 37 | queryEngine = model.getAdapter(ModelQueryAdapter.class); |
38 | countInterpretation = model.getInterpretation(storeAdapter.getCountSymbol()); | 38 | countInterpretation = model.getInterpretation(storeAdapter.getCountSymbol()); |
39 | solver = MPSolver.createSolver("GLOP"); | 39 | solver = MPSolver.createSolver("GLOP"); |
40 | solver.suppressOutput(); | ||
40 | objective = solver.objective(); | 41 | objective = solver.objective(); |
41 | initializeVariables(); | 42 | initializeVariables(); |
42 | countInterpretation.addListener(this::countChanged, true); | 43 | countInterpretation.addListener(this::countChanged, true); |
@@ -149,7 +150,10 @@ class BoundScopePropagator implements BoundPropagator { | |||
149 | changed = false; | 150 | changed = false; |
150 | for (var propagator : propagators) { | 151 | for (var propagator : propagators) { |
151 | model.checkCancelled(); | 152 | model.checkCancelled(); |
152 | propagator.updateBounds(); | 153 | if (!propagator.updateBounds()) { |
154 | // Avoid logging GLOP error to console by checking for inconsistent constraints in advance. | ||
155 | return PropagationResult.REJECTED; | ||
156 | } | ||
153 | } | 157 | } |
154 | var result = PropagationResult.UNCHANGED; | 158 | var result = PropagationResult.UNCHANGED; |
155 | if (activeVariables.isEmpty()) { | 159 | if (activeVariables.isEmpty()) { |
diff --git a/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/LowerTypeScopePropagator.java b/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/LowerTypeScopePropagator.java index 5d903f41..2be92464 100644 --- a/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/LowerTypeScopePropagator.java +++ b/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/LowerTypeScopePropagator.java | |||
@@ -35,7 +35,7 @@ class LowerTypeScopePropagator extends TypeScopePropagator { | |||
35 | } | 35 | } |
36 | 36 | ||
37 | @Override | 37 | @Override |
38 | public void updateBounds() { | 38 | protected void doUpdateBounds() { |
39 | constraint.setLb((lowerBound - getSingleCount())); | 39 | constraint.setLb((lowerBound - getSingleCount())); |
40 | } | 40 | } |
41 | 41 | ||
diff --git a/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/TypeScopePropagator.java b/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/TypeScopePropagator.java index db80be7f..bb50656b 100644 --- a/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/TypeScopePropagator.java +++ b/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/TypeScopePropagator.java | |||
@@ -38,7 +38,12 @@ abstract class TypeScopePropagator { | |||
38 | multiNodes.addListener(this::multiChanged); | 38 | multiNodes.addListener(this::multiChanged); |
39 | } | 39 | } |
40 | 40 | ||
41 | public abstract void updateBounds(); | 41 | protected abstract void doUpdateBounds(); |
42 | |||
43 | public boolean updateBounds() { | ||
44 | doUpdateBounds(); | ||
45 | return constraint.lb() <= constraint.ub(); | ||
46 | } | ||
42 | 47 | ||
43 | protected int getSingleCount() { | 48 | protected int getSingleCount() { |
44 | return allNodes.size() - multiNodes.size(); | 49 | return allNodes.size() - multiNodes.size(); |
diff --git a/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/UpperTypeScopePropagator.java b/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/UpperTypeScopePropagator.java index 062f976c..4aba5aac 100644 --- a/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/UpperTypeScopePropagator.java +++ b/subprojects/store-reasoning-scope/src/main/java/tools/refinery/store/reasoning/scope/UpperTypeScopePropagator.java | |||
@@ -26,8 +26,8 @@ class UpperTypeScopePropagator extends TypeScopePropagator { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | @Override | 28 | @Override |
29 | public void updateBounds() { | 29 | protected void doUpdateBounds() { |
30 | constraint.setUb(upperBound - getSingleCount()); | 30 | constraint.setUb((upperBound - getSingleCount())); |
31 | } | 31 | } |
32 | 32 | ||
33 | public static class Factory extends TypeScopePropagator.Factory { | 33 | public static class Factory extends TypeScopePropagator.Factory { |