public class OptimizationProblem extends ConstraintSatisfactionProblem
Modifier and Type | Field and 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"
|
private int |
penalty
penalty for converted absolute values.
|
private static long |
serialVersionUID
For serialization.
|
private static int |
STANDARD_PENALTY
standard penalty for converted minimums.
|
private Term |
targetFunction
The target function of this problem.
|
private int |
type
The type of the optimization problem.
|
Constructor and Description |
---|
OptimizationProblem()
Creates an empty optimization problem.
|
OptimizationProblem(int type)
Creates an empty optimization problem of the given type.
|
Modifier and Type | Method and 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() |
isInteger, toNormalizedForm
add, clear, contains, isEmpty, iterator, remove, size, spliterator
addAll, containsAll, retainAll, toArray, toArray
finalize, getClass, notify, notifyAll, wait, wait, wait
private static final long serialVersionUID
public static final double EPSILON
public static final int MINIMIZE
public static final int MAXIMIZE
private static final int STANDARD_PENALTY
private int penalty
private int type
private Term targetFunction
public OptimizationProblem()
public OptimizationProblem(int type)
type
- the type of the problem; either OptimizationProblem.MINIMIZE or
OptimizationProblem.MAXIMIZE.public void setTargetFunction(Term targetFunction)
targetFunction
- a term.public boolean isTargetLinear()
public boolean isLinear()
ConstraintSatisfactionProblem
isLinear
in class ConstraintSatisfactionProblem
public boolean isMinimumFree()
ConstraintSatisfactionProblem
isMinimumFree
in class ConstraintSatisfactionProblem
public void resolveMinimums()
ConstraintSatisfactionProblem
resolveMinimums
in class ConstraintSatisfactionProblem
public void resolveMaximums()
ConstraintSatisfactionProblem
resolveMaximums
in class ConstraintSatisfactionProblem
public void resolveAbsoluteValues()
public java.lang.String convertToLpFormat()
public java.lang.String convertToCplexLpFormat()
public java.util.Set<Variable> getVariables()
ConstraintSatisfactionProblem
getVariables
in class ConstraintSatisfactionProblem
public java.util.Set<Minimum> getMinimums()
ConstraintSatisfactionProblem
getMinimums
in class ConstraintSatisfactionProblem
public void collapseAssociativeOperations()
ConstraintSatisfactionProblem
collapseAssociativeOperations
in class ConstraintSatisfactionProblem
public void setType(int type)
type
- the type of this problem.public void setPenalty(int penalty)
penalty
- public int getType()
public Term getTargetFunction()
public java.lang.String toString()
toString
in class ConstraintSatisfactionProblem
public OptimizationProblem clone()
clone
in class ConstraintSatisfactionProblem