public class ExtendedQuadraticOptimizer extends QuadraticOptimizer
QuadraticOptimizer
class to allow for some variables to
have a fixed value and for some inequalities to be unsatisfiable, as long as
satisfiable fallback is provided. Implemented as a separate class as it is
slightly slower due to the additional terms used.Constructor and Description |
---|
ExtendedQuadraticOptimizer(int variableCount)
The constructor creates a zero function with no constraints.
|
Modifier and Type | Method and Description |
---|---|
void |
addConstantEquality(int i,
double value)
Adds the following equality constraint:
xi=value . |
void |
addConstantInequality(int i,
double value)
Add an inequality constraint in the form of
xi≥value . |
void |
addConstantReverseInequality(int i,
double value)
Add an inequality constraint in the form of
xi≤value . |
void |
addMeanDifference(int i,
int j,
double value,
double weight)
Add a new term in the form of
weight*((xi+xj)/2-value)2 . |
void |
addQuadraticConstantDifference(int i,
double value,
double weight)
Add a new term in the form of
weight*(xi-value)2 . |
void |
addReducibleInequality(int i,
int j,
double distance,
double minDistance)
Adds an inequality constraint in the form of
xj-xi≥distance≥minDistance . |
double[] |
performOptimization()
Performs the function minimization using the given terms and constraints.
|
addCombinedTerm, addDoubleMeanConstantDifference, addDoubleMeanDifference, addEquality, addInequality, addLinearDifference, addLinearTerm, addMeanVariableDifference, addQuadraticDifference, addQuadraticTerm, setEpsilon, setVariable
public ExtendedQuadraticOptimizer(int variableCount)
variableCount
- the number of variablespublic void addQuadraticConstantDifference(int i, double value, double weight)
QuadraticOptimizer
weight*(xi-value)2
. Use this method to minimize the drift
of an object.addQuadraticConstantDifference
in class QuadraticOptimizer
i
- the variable of the termvalue
- the value to keep the variable close toweight
- the weight of this termpublic void addMeanDifference(int i, int j, double value, double weight)
weight*((xi+xj)/2-value)2
.
Use this method to minimize the drift of the mass center of two objects.addMeanDifference
in class QuadraticOptimizer
i
- the first variable of the termj
- the second variable of the termvalue
- the value to keep the mass center of the two objects close
toweight
- the weight of this termpublic void addConstantInequality(int i, double value)
xi≥value
.i
- the variable of the inequalityvalue
- the constant of the inequalitypublic void addConstantReverseInequality(int i, double value)
xi≤value
.i
- the variable of the inequalityvalue
- the constant of the inequalitypublic void addConstantEquality(int i, double value)
xi=value
.i
- the variable of the equalityvalue
- the constant of the equalitypublic void addReducibleInequality(int i, int j, double distance, double minDistance)
xj-xi≥distance≥minDistance
. If the set
of constraints is unsatisfiable with distance
, they are relaxed
towards minDistance
until they are satisfiable.i
- the second variable of the inequalityj
- the first variable of the inequalitydistance
- the minimum distance between the two variablesminDistance
- the minimum distance between the two variables if distance
is not possible.public double[] performOptimization()
QuadraticOptimizer
performOptimization
in class QuadraticOptimizer