Class ModelStrategy

    • Field Detail

      • myIndices

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

        private final java.util.List<java.util.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.
    • Method Detail

      • 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
      • getWorkerPriorities

        public java.util.List<java.util.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
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • countIntegerVariables

        protected int countIntegerVariables()
      • getIndex

        protected int getIndex​(int idx)
        The variable's global index
        Parameters:
        idx - Index among the integer variables
      • isCutRatherThanBranch

        protected abstract boolean isCutRatherThanBranch​(double displacement,
                                                         boolean found)
      • isDirect

        protected abstract boolean isDirect​(NodeKey node,
                                            boolean found)
        This method will be called twice when branching – once for each of the new nodes created by branching. In most cases you only want to return true for (at most) one of those new branches. Always returning true for both the new nodes will cause excessive memory consumption.
        Parameters:
        node - The node to check
        found - Is an integer solution already found?
        Returns:
        true if this node should be evaluated directly (not deferred)
      • isGoodEnough

        protected boolean isGoodEnough​(Optimisation.Result bestResultSoFar,
                                       double relaxedNodeValue)
        Is the node's result good enough to continue branching? (Compare the node's objective function value with the that of the best integer solution found so far.)
      • markInfeasible

        protected abstract void markInfeasible​(NodeKey key,
                                               boolean found)
        Called everytime a node/subproblem is found to be infeasible
      • markInteger

        protected abstract void markInteger​(NodeKey key,
                                            Optimisation.Result result)
        Called everytime a new integer solution is found
      • toComparable

        protected abstract double toComparable​(int idx,
                                               double displacement,
                                               boolean found)
        Convert the fraction to something "comparable" used to determine which variable to branch on. If a variable is at an integer value or not is determined by the Optimisation.Options.feasibility property. If an integer variable is not at an integer value, then this method is invoked to obtain a value that is then used to copare with that of other integer variables with fractional values. The variable with the max "comparable" is picked for branching.
        Parameters:
        idx - Integer variable index
        displacement - variable's fractional value
        found - Is an integer solution already found?
        Returns:
        Value used to compare variables when determining which to branch on. Larger value means more likelyn to branch on this.