Class ModelStrategy
java.lang.Object
org.ojalgo.optimisation.integer.ModelStrategy
- All Implemented Interfaces:
IntegerStrategy
- Direct Known Subclasses:
ModelStrategy.AbstractStrategy, ModelStrategy.DefaultStrategy
This base class contains some model/problem specific data required by the
IntegerSolver. The
"strategies" are implemented in subclasses. If you plan to implement a custom strategy it may be helpful to
extend ModelStrategy.AbstractStrategy instead.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWhen implementing your ownModelStrategyextending this abstract class is a good starting point.(package private) static final classNested classes/interfaces inherited from interface IntegerStrategy
IntegerStrategy.ConfigurableStrategy, IntegerStrategy.GMICutConfiguration -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanIndicates if cut generation is turned on, or not.private final int[]One entry per integer variable, the entry is the global index of that integer variableprivate final Optimisation.Senseprivate final IntegerStrategyprivate final List<Comparator<NodeKey>> Fields inherited from interface IntegerStrategy
DEFAULT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedModelStrategy(ExpressionsBasedModel model, IntegerStrategy strategy) -
Method Summary
Modifier and TypeMethodDescriptionprotected intintThe MIP gap is the difference between the best integer solution found so far and a node's relaxed non-integer solution.protected intgetIndex(int idx) Used to determine if a variable value is integer or notThere will be 1 worker thread per item in the returnedList.protected abstract ModelStrategyinitialise(MultiaryFunction.TwiceDifferentiable<Double> function, Access1D<?> point) protected abstract booleanisCutRatherThanBranch(NodeKey nodeKey, int branchIntegerIndex, double variableValue, double nodeValue, Optimisation.Result bestResultSoFar) Decide if cuts should be attempted at this node.protected booleanisGoodEnough(Optimisation.Result bestResultSoFar, double relaxedNodeValue) (package private) booleanprotected abstract voidmarkInfeasible(NodeKey key, boolean found, double incumbentValue) protected abstract voidmarkInteger(NodeKey key, Optimisation.Result result) protected abstract voidCalled when cut generation produced no cuts (default: disable further cutting).protected abstract voidonCutSuccess(NodeKey nodeKey) Called when cut generation added at least one cut (default: no-op).protected abstract voidonNodeSolved(NodeKey key, Optimisation.Result child, double childObj, boolean minimisation) Hook to update pseudo-costs after a node is solved.protected abstract doublescoreBranch(int idx, double distanceDown, double distanceUp, boolean found) protected abstract doublescoreBranchDown(int idx, double distanceDown, boolean found) protected abstract doublescoreBranchUp(int idx, double distanceUp, boolean found) final StringtoString()
-
Field Details
-
myIndices
private final int[] myIndicesOne entry per integer variable, the entry is the global index of that integer variable -
myOptimisationSense
-
myStrategy
-
myWorkerPriorities
-
cutting
protected boolean cuttingIndicates if cut generation is turned on, or not. On by default. Algorithms can turn off when/if no longer useful.
-
-
Constructor Details
-
ModelStrategy
-
-
Method Details
-
countUniqueStrategies
public int countUniqueStrategies()- Specified by:
countUniqueStrategiesin interfaceIntegerStrategy
-
getGapTolerance
Description copied from interface:IntegerStrategyThe MIP gap is the difference between the best integer solution found so far and a node's relaxed non-integer solution. The relative MIP gap is that difference divided by the optimal value (approximated by the currently best integer solution). If the gap (absolute or relative) is too small, then the corresponding branch is terminated as it is deemed unlikely or too "expensive" to find better integer solutions there.- Specified by:
getGapTolerancein interfaceIntegerStrategy- Returns:
- The tolerance context used to determine if the gap is too small or not
-
getGMICutConfiguration
- Specified by:
getGMICutConfigurationin interfaceIntegerStrategy
-
getIntegralityTolerance
Description copied from interface:IntegerStrategyUsed to determine if a variable value is integer or not- Specified by:
getIntegralityTolerancein interfaceIntegerStrategy
-
getWorkerPriorities
Description copied from interface:IntegerStrategyThere will be 1 worker thread per item in the returnedList. TheComparatorinstances need not be unique. Used to prioritise among the nodes waiting to be evaluated.- Specified by:
getWorkerPrioritiesin interfaceIntegerStrategy
-
newModelStrategy
- Specified by:
newModelStrategyin interfaceIntegerStrategy
-
toString
-
countIntegerVariables
protected int countIntegerVariables() -
getIndex
protected int getIndex(int idx) -
initialise
protected abstract ModelStrategy initialise(MultiaryFunction.TwiceDifferentiable<Double> function, Access1D<?> point) -
isCutRatherThanBranch
protected abstract boolean isCutRatherThanBranch(NodeKey nodeKey, int branchIntegerIndex, double variableValue, double nodeValue, Optimisation.Result bestResultSoFar) Decide if cuts should be attempted at this node. -
isGoodEnough
-
markInfeasible
-
markInteger
-
onCutFailure
protected abstract void onCutFailure()Called when cut generation produced no cuts (default: disable further cutting). -
onCutSuccess
Called when cut generation added at least one cut (default: no-op). -
onNodeSolved
protected abstract void onNodeSolved(NodeKey key, Optimisation.Result child, double childObj, boolean minimisation) Hook to update pseudo-costs after a node is solved. -
scoreBranch
protected abstract double scoreBranch(int idx, double distanceDown, double distanceUp, boolean found) -
scoreBranchDown
protected abstract double scoreBranchDown(int idx, double distanceDown, boolean found) -
scoreBranchUp
protected abstract double scoreBranchUp(int idx, double distanceUp, boolean found) -
isMinimisation
boolean isMinimisation()
-