Class OptimizationProblem

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double EPSILON
      Some value to represent a very small number
      static int MAXIMIZE
      Static constant for the type "maximization"
      static int MINIMIZE
      Static constant for the type "minimization"
    • Constructor Summary

      Constructors 
      Constructor Description
      OptimizationProblem()
      Creates an empty optimization problem.
      OptimizationProblem​(int type)
      Creates an empty optimization problem of the given type.
    • Method Summary

      Modifier and Type Method Description
      OptimizationProblem clone()  
      void collapseAssociativeOperations()
      This method collapses all associative operations appearing in the target function and the constraints, e.g.
      java.lang.String convertToCplexLpFormat()
      Converts the this optimization problem into a string in the commonly used CPLEX LP-format for mixed integer linear programming.
      java.lang.String convertToLpFormat()
      Converts the this optimization problem into a string in the commonly used LP-format for mixed integer linear programming.
      java.util.Set<Minimum> getMinimums()
      Returns all minimums appearing in this problem.
      Term getTargetFunction()
      Returns the target function of this problem.
      int getType()
      Returns the type of this problem.
      java.util.Set<Variable> getVariables()
      Returns all variables of this problem.
      boolean isLinear()
      Checks whether every constraint of this problem is linear.
      boolean isMinimumFree()
      Checks whether this problem uses no minimum function.
      boolean isTargetLinear()
      Checks whether the target function is linear.
      void resolveAbsoluteValues()
      Resolves all occurrences of absolute values "abs(X)" by replacing "abs(X)" by a new variable "TMPABS" adding constraints "TMPABS - X>= 0" and "TMPABS + X >= 0" (yielding "TMPABS <= abs(X)") introducing a new variable "TMPABSB" adding constraints "X+PENALTY*TMPABSB - TMPABS >= 0" and "-X-TMPABSB*PENALTY - TMPABS >= -PENALTY" (yielding "TMPABS >= abs(X)") adding constraints "TMPABSB<=1"
      void resolveMaximums()
      Resolves all occurrences of maximums by substituting a maximum "max{a,b}" by "0.5 a + 0.5 b + abs(a-b)".
      void resolveMinimums()
      Resolves all occurrences of minimums by substituting a minimum "min{a,b}" by "0.5 a + 0.5 b - abs(a-b)".
      void setPenalty​(int penalty)
      Sets the penalty for violated minimum.
      void setTargetFunction​(Term targetFunction)
      Sets the target function of this problem.
      void setType​(int type)
      Sets the type of this problem, either OptimizationProblem.MINIMIZE or OptimizationProblem.MAXIMIZE.
      java.lang.String toString()  
      • Methods inherited from class java.util.HashSet

        add, clear, contains, isEmpty, iterator, remove, size, spliterator
      • Methods inherited from class java.util.AbstractSet

        equals, hashCode, removeAll
      • Methods inherited from class java.util.AbstractCollection

        addAll, containsAll, retainAll, toArray, toArray
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
    • Field Detail

      • EPSILON

        public static final double EPSILON
        Some value to represent a very small number
        See Also:
        Constant Field Values
      • MINIMIZE

        public static final int MINIMIZE
        Static constant for the type "minimization"
        See Also:
        Constant Field Values
      • MAXIMIZE

        public static final int MAXIMIZE
        Static constant for the type "maximization"
        See Also:
        Constant Field Values
    • Constructor Detail

      • OptimizationProblem

        public OptimizationProblem()
        Creates an empty optimization problem.
      • OptimizationProblem

        public OptimizationProblem​(int type)
        Creates an empty optimization problem of the given type.
        Parameters:
        type - the type of the problem; either OptimizationProblem.MINIMIZE or OptimizationProblem.MAXIMIZE.
    • Method Detail

      • setTargetFunction

        public void setTargetFunction​(Term targetFunction)
        Sets the target function of this problem.
        Parameters:
        targetFunction - a term.
      • isTargetLinear

        public boolean isTargetLinear()
        Checks whether the target function is linear.
        Returns:
        "true" if the target function is linear.
      • resolveAbsoluteValues

        public void resolveAbsoluteValues()
        Resolves all occurrences of absolute values "abs(X)" by
        • replacing "abs(X)" by a new variable "TMPABS"
        • adding constraints "TMPABS - X>= 0" and "TMPABS + X >= 0" (yielding "TMPABS <= abs(X)")
        • introducing a new variable "TMPABSB"
        • adding constraints "X+PENALTY*TMPABSB - TMPABS >= 0" and "-X-TMPABSB*PENALTY - TMPABS >= -PENALTY" (yielding "TMPABS >= abs(X)")
        • adding constraints "TMPABSB<=1"
      • convertToLpFormat

        public java.lang.String convertToLpFormat()
        Converts the this optimization problem into a string in the commonly used LP-format for mixed integer linear programming.
        Returns:
        A string representing this problem in LP-format
      • convertToCplexLpFormat

        public java.lang.String convertToCplexLpFormat()
        Converts the this optimization problem into a string in the commonly used CPLEX LP-format for mixed integer linear programming.
        Returns:
        A string representing this problem in CPLEX LP-format
      • setType

        public void setType​(int type)
        Sets the type of this problem, either OptimizationProblem.MINIMIZE or OptimizationProblem.MAXIMIZE.
        Parameters:
        type - the type of this problem.
      • setPenalty

        public void setPenalty​(int penalty)
        Sets the penalty for violated minimum.
        Parameters:
        penalty - some penalty
      • getType

        public int getType()
        Returns the type of this problem.
        Returns:
        the type of this problem.
      • getTargetFunction

        public Term getTargetFunction()
        Returns the target function of this problem.
        Returns:
        the target function of this problem.