Class ReachedLimitBestKnownException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.clafer.compiler.ReachedLimitException
org.clafer.compiler.ReachedLimitBestKnownException
- All Implemented Interfaces:
Serializable, InstanceIterator, OptimalInstanceIterator
public class ReachedLimitBestKnownException
extends ReachedLimitException
implements OptimalInstanceIterator
Resource limit reached on an optimization problem with the best known
solution thus far.
solver.limitTime(1000);
try {
solver.find();
} catch (ReachedLimitBestKnownException rle) {
// This is an optimization problem and 1000ms has passed.
// Although the solver did not complete, it returned the best known
// (but possibly non-optimal) instance after 1000ms. This instance is
// stored in the rle exception.
while (rle.find()) {
System.out.println("Approximate solutions: " + rle.instance());
}
} catch (ReachedLimitException rle) {
// 1000ms has passed.
}
- Author:
- jimmy
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionReachedLimitBestKnownException(InstanceModel[] instances, int[][] objectiveValues) ReachedLimitBestKnownException(InstanceModel instance, int[] objectiveValues) -
Method Summary
Modifier and TypeMethodDescriptionbooleanfind()Find the next instance.instance()Return the instance from the lastInstanceIterator.find()operation, if successful.intReturn the number of instances found so far.int[]Returns the optimal values.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface InstanceIterator
allInstances
-
Constructor Details
-
ReachedLimitBestKnownException
-
ReachedLimitBestKnownException
-
-
Method Details
-
find
Description copied from interface:InstanceIteratorFind the next instance.- Specified by:
findin interfaceInstanceIterator- Returns:
trueif and only if another solution is found,falseotherwise
-
instance
Description copied from interface:InstanceIteratorReturn the instance from the lastInstanceIterator.find()operation, if successful.- Specified by:
instancein interfaceInstanceIterator- Returns:
- the instance
-
optimalValues
Description copied from interface:OptimalInstanceIteratorReturns the optimal values. The order of the values corresponds to the order of the objectives.- Specified by:
optimalValuesin interfaceOptimalInstanceIterator- Returns:
- the optimal value
-
instanceCount
Description copied from interface:InstanceIteratorReturn the number of instances found so far.- Specified by:
instanceCountin interfaceInstanceIterator- Returns:
- the number of instances found so far
-