diff options
author | 2019-08-02 19:04:40 +0200 | |
---|---|---|
committer | 2019-08-02 19:04:40 +0200 | |
commit | 15fafc1b66a38e362f4aca49a8848d080f760310 (patch) | |
tree | e5c865b9e5ffb219c6e12742f8420cbd6c45e742 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver | |
parent | Handle floating point rounding errors in Cbc (diff) | |
download | VIATRA-Generator-15fafc1b66a38e362f4aca49a8848d080f760310.tar.gz VIATRA-Generator-15fafc1b66a38e362f4aca49a8848d080f760310.tar.zst VIATRA-Generator-15fafc1b66a38e362f4aca49a8848d080f760310.zip |
Be more lenient with rounding IP solver results
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend index c772aebc..75c396b4 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend | |||
@@ -142,13 +142,13 @@ class CbcSaturationOperator extends AbstractPolyhedronSaturationOperator { | |||
142 | switch (minimizationResult) { | 142 | switch (minimizationResult) { |
143 | CbcResult.SolutionBounded: { | 143 | CbcResult.SolutionBounded: { |
144 | val doubleValue = minimizationResult.value | 144 | val doubleValue = minimizationResult.value |
145 | val roundedValue = Math.floor(doubleValue) | 145 | val roundedValue = Math.ceil(doubleValue - EPSILON) |
146 | val intValue = roundedValue as int | 146 | val intValue = roundedValue as int |
147 | val oldBound = expressionToSaturate.lowerBound | 147 | val oldBound = expressionToSaturate.lowerBound |
148 | if (oldBound === null || intValue > oldBound) { | 148 | if (oldBound === null || intValue >= oldBound) { |
149 | expressionToSaturate.lowerBound = intValue | 149 | expressionToSaturate.lowerBound = intValue |
150 | setBound(expressionToSaturate, constraints, roundedValue, columnLowerBounds, rowLowerBounds) | 150 | setBound(expressionToSaturate, constraints, roundedValue, columnLowerBounds, rowLowerBounds) |
151 | } else if (oldBound - doubleValue > EPSILON) { | 151 | } else { |
152 | throw new IllegalStateException("Unexpected decrease of lower bound by " + (oldBound - doubleValue)) | 152 | throw new IllegalStateException("Unexpected decrease of lower bound by " + (oldBound - doubleValue)) |
153 | } | 153 | } |
154 | } | 154 | } |
@@ -175,13 +175,13 @@ class CbcSaturationOperator extends AbstractPolyhedronSaturationOperator { | |||
175 | switch (maximizationResult) { | 175 | switch (maximizationResult) { |
176 | CbcResult.SolutionBounded: { | 176 | CbcResult.SolutionBounded: { |
177 | val doubleValue = -maximizationResult.value | 177 | val doubleValue = -maximizationResult.value |
178 | val roundedValue = Math.ceil(doubleValue) | 178 | val roundedValue = Math.floor(doubleValue + EPSILON) |
179 | val intValue = roundedValue as int | 179 | val intValue = roundedValue as int |
180 | val oldBound = expressionToSaturate.upperBound | 180 | val oldBound = expressionToSaturate.upperBound |
181 | if (oldBound === null || intValue < oldBound) { | 181 | if (oldBound === null || intValue <= oldBound) { |
182 | expressionToSaturate.upperBound = intValue | 182 | expressionToSaturate.upperBound = intValue |
183 | setBound(expressionToSaturate, constraints, roundedValue, columnUpperBounds, rowUpperBounds) | 183 | setBound(expressionToSaturate, constraints, roundedValue, columnUpperBounds, rowUpperBounds) |
184 | } else if (doubleValue - oldBound > EPSILON) { | 184 | } else { |
185 | throw new IllegalStateException("Unexpected increase of upper bound by " + (doubleValue - oldBound)) | 185 | throw new IllegalStateException("Unexpected increase of upper bound by " + (doubleValue - oldBound)) |
186 | } | 186 | } |
187 | } | 187 | } |