Class ModelStrategy

java.lang.Object
org.ojalgo.optimisation.integer.ModelStrategy
All Implemented Interfaces:
IntegerStrategy
Direct Known Subclasses:
ModelStrategy.AbstractStrategy, ModelStrategy.DefaultStrategy

public abstract class ModelStrategy extends Object implements IntegerStrategy
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.
  • Field Details

    • myIndices

      private final int[] myIndices
      One entry per integer variable, the entry is the global index of that integer variable
    • myOptimisationSense

      private final Optimisation.Sense myOptimisationSense
    • myStrategy

      private final IntegerStrategy myStrategy
    • myWorkerPriorities

      private final List<Comparator<NodeKey>> myWorkerPriorities
    • cutting

      protected boolean cutting
      Indicates if cut generation is turned on, or not. On by default. Algorithms can turn off when/if no longer useful.
  • Constructor Details

  • Method Details

    • countUniqueStrategies

      public int countUniqueStrategies()
      Specified by:
      countUniqueStrategies in interface IntegerStrategy
    • getGapTolerance

      public NumberContext getGapTolerance()
      Description copied from interface: IntegerStrategy
      The 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:
      getGapTolerance in interface IntegerStrategy
      Returns:
      The tolerance context used to determine if the gap is too small or not
    • getGMICutConfiguration

      public IntegerStrategy.GMICutConfiguration getGMICutConfiguration()
      Specified by:
      getGMICutConfiguration in interface IntegerStrategy
    • getIntegralityTolerance

      public NumberContext getIntegralityTolerance()
      Description copied from interface: IntegerStrategy
      Used to determine if a variable value is integer or not
      Specified by:
      getIntegralityTolerance in interface IntegerStrategy
    • getWorkerPriorities

      public List<Comparator<NodeKey>> getWorkerPriorities()
      Description copied from interface: IntegerStrategy
      There will be 1 worker thread per item in the returned List. The Comparator instances need not be unique. Used to prioritise among the nodes waiting to be evaluated.
      Specified by:
      getWorkerPriorities in interface IntegerStrategy
    • newModelStrategy

      public ModelStrategy newModelStrategy(ExpressionsBasedModel model)
      Specified by:
      newModelStrategy in interface IntegerStrategy
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • 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

      protected boolean isGoodEnough(Optimisation.Result bestResultSoFar, double relaxedNodeValue)
    • markInfeasible

      protected abstract void markInfeasible(NodeKey key, boolean found, double incumbentValue)
    • markInteger

      protected abstract void markInteger(NodeKey key, Optimisation.Result result)
    • onCutFailure

      protected abstract void onCutFailure()
      Called when cut generation produced no cuts (default: disable further cutting).
    • onCutSuccess

      protected abstract void onCutSuccess(NodeKey nodeKey)
      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()