Class OptimizationProblem

All Implemented Interfaces:
Serializable, Cloneable, Iterable<OptProbElement>, Collection<OptProbElement>, Set<OptProbElement>

public class OptimizationProblem extends ConstraintSatisfactionProblem
This class models a general optimization problem.
Author:
Matthias Thimm
See Also:
  • Field Details

    • EPSILON

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

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

      public static final int MAXIMIZE
      Static constant for the type "maximization"
      See Also:
  • Constructor Details

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

    • 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.
    • isLinear

      public boolean isLinear()
      Description copied from class: ConstraintSatisfactionProblem
      Checks whether every constraint of this problem is linear.
      Overrides:
      isLinear in class ConstraintSatisfactionProblem
      Returns:
      "true" if every constraint of this problem is linear.
    • isMinimumFree

      public boolean isMinimumFree()
      Description copied from class: ConstraintSatisfactionProblem
      Checks whether this problem uses no minimum function.
      Overrides:
      isMinimumFree in class ConstraintSatisfactionProblem
      Returns:
      "true" if this problem uses no minimum function.
    • resolveMinimums

      public void resolveMinimums()
      Description copied from class: ConstraintSatisfactionProblem
      Resolves all occurrences of minimums by substituting a minimum "min{a,b}" by "0.5 a + 0.5 b - abs(a-b)".
      Overrides:
      resolveMinimums in class ConstraintSatisfactionProblem
    • resolveMaximums

      public void resolveMaximums()
      Description copied from class: ConstraintSatisfactionProblem
      Resolves all occurrences of maximums by substituting a maximum "max{a,b}" by "0.5 a + 0.5 b + abs(a-b)".
      Overrides:
      resolveMaximums in class ConstraintSatisfactionProblem
    • 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 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 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
    • getVariables

      public Set<Variable> getVariables()
      Description copied from class: ConstraintSatisfactionProblem
      Returns all variables of this problem.
      Overrides:
      getVariables in class ConstraintSatisfactionProblem
      Returns:
      all variables of this problem.
    • getMinimums

      public Set<Minimum> getMinimums()
      Description copied from class: ConstraintSatisfactionProblem
      Returns all minimums appearing in this problem.
      Overrides:
      getMinimums in class ConstraintSatisfactionProblem
      Returns:
      all minimums appearing in this problem.
    • collapseAssociativeOperations

      public void collapseAssociativeOperations()
      Description copied from class: ConstraintSatisfactionProblem
      This method collapses all associative operations appearing in the target function and the constraints, e.g. every min{min{a,b},c} becomes min{a,b,c}
      Overrides:
      collapseAssociativeOperations in class ConstraintSatisfactionProblem
    • 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.
    • toString

      public String toString()
      Overrides:
      toString in class ConstraintSatisfactionProblem
    • clone

      public OptimizationProblem clone()
      Overrides:
      clone in class ConstraintSatisfactionProblem