public abstract class AbstractCriterion<V extends Variable<V,T>,T extends Value<V,T>> extends Object implements Criterion<V,T>
Criterion
except of the Criterion.getValue(Value, Set)
.Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractCriterion.ValueUpdateType
Defines how the overall value of the criterion should be automatically updated (using
Criterion.getValue(Value, Set) ). |
Modifier and Type | Field and Description |
---|---|
protected double |
iBest |
protected boolean |
iDebug |
protected double |
iValue |
protected AbstractCriterion.ValueUpdateType |
iValueUpdateType |
protected double |
iWeight |
protected static DecimalFormat |
sDoubleFormat |
protected static DecimalFormat |
sPercentFormat |
Constructor and Description |
---|
AbstractCriterion() |
Modifier and Type | Method and Description |
---|---|
void |
afterAssigned(long iteration,
T value)
Called after a value is assigned to its variable (
Value.variable() ). |
void |
afterUnassigned(long iteration,
T value)
Called after a value is unassigned from its variable (
Value.variable() ). |
void |
beforeAssigned(long iteration,
T value)
Called before a value is assigned to its variable (
Value.variable() ). |
void |
beforeUnassigned(long iteration,
T value)
Called before a value is unassigned from its variable (
Value.variable() ). |
void |
bestRestored()
Notification that the current solution has been restored from the best.
|
void |
bestSaved()
Notification that the current solution has been saved to the best.
|
protected void |
clearCache()
Clear bounds cache
|
protected double[] |
computeBounds()
Compute bounds (bounds are being cached by default).
|
void |
constraintAdded(Constraint<V,T> constraint)
Constraint is added to the model
|
void |
constraintRemoved(Constraint<V,T> constraint)
Constraint is removed from the model
|
double |
getBest()
Best value (value of the criterion in the best solution)
|
double[] |
getBounds()
Bounds (minimum and maximum) estimate for the value
|
double[] |
getBounds(Collection<V> variables)
Value bounds (minimum and maximum) of the criterion on a part of the problem
|
void |
getInfo(Map<String,String> info)
Adds some information into the table with information about the solution
|
void |
getInfo(Map<String,String> info,
Collection<V> variables)
Adds some information into the table with information about the solution,
only consider variables from the given set
|
Model<V,T> |
getModel()
Returns current model
|
String |
getName()
Criterion name
|
protected String |
getPerc(double value,
double min,
double max) |
protected String |
getPercRev(double value,
double min,
double max) |
double |
getValue()
Current value of the criterion (optimization objective)
|
double |
getValue(Collection<V> variables)
Value of a part of the problem (given by the collection of variables)
|
double |
getWeight()
Weight of the criterion
|
double |
getWeightDefault(DataProperties config)
Defines default weight (when
getWeightName() parameter is not present in the criterion). |
double |
getWeightedBest()
Weighted best value of the objective (value in the best solution).
|
double |
getWeightedValue()
Weighted value of the objectives
|
double |
getWeightedValue(Collection<V> variables)
Weighted value of a part of the problem (given by the collection of variables)
|
double |
getWeightedValue(T value,
Set<T> conflicts)
Weighted value of a proposed assignment (including hard conflicts)
|
String |
getWeightName()
Defines weight name (to be used to get the criterion weight from the configuration).
|
void |
inc(double value)
Outside update of the criterion (usefull when the criterion is driven by a set of constraints).
|
boolean |
init(Solver<V,T> solver)
Notification that the model was initialized by the solver.
|
void |
variableAdded(V variable)
Variable is added to the model
|
void |
variableRemoved(V variable)
Variable is removed from the model
|
protected double iBest
protected double iValue
protected double iWeight
protected static DecimalFormat sDoubleFormat
protected static DecimalFormat sPercentFormat
protected boolean iDebug
protected AbstractCriterion.ValueUpdateType iValueUpdateType
public AbstractCriterion()
public String getWeightName()
public double getWeightDefault(DataProperties config)
getWeightName()
parameter is not present in the criterion).public boolean init(Solver<V,T> solver)
ModelListener
public double getValue()
Criterion
public double getBest()
Criterion
public double getValue(Collection<V> variables)
Criterion
public double getWeight()
Criterion
public double getWeightedBest()
Criterion
public double getWeightedValue()
Criterion
public double getWeightedValue(T value, Set<T> conflicts)
Criterion
public double getWeightedValue(Collection<V> variables)
Criterion
protected double[] computeBounds()
public double[] getBounds()
Criterion
public double[] getBounds(Collection<V> variables)
Criterion
public void beforeAssigned(long iteration, T value)
ModelListener
Value.variable()
).beforeAssigned
in interface ModelListener<V extends Variable<V,T>,T extends Value<V,T>>
iteration
- current iterationvalue
- value to be assignedpublic void afterAssigned(long iteration, T value)
ModelListener
Value.variable()
).afterAssigned
in interface ModelListener<V extends Variable<V,T>,T extends Value<V,T>>
iteration
- current iterationvalue
- value to be assignedpublic void beforeUnassigned(long iteration, T value)
ModelListener
Value.variable()
).beforeUnassigned
in interface ModelListener<V extends Variable<V,T>,T extends Value<V,T>>
iteration
- current iterationvalue
- value to be unassignedpublic void afterUnassigned(long iteration, T value)
ModelListener
Value.variable()
).afterUnassigned
in interface ModelListener<V extends Variable<V,T>,T extends Value<V,T>>
iteration
- current iterationvalue
- value to be unassignedpublic void bestSaved()
Criterion
public void bestRestored()
Criterion
public void inc(double value)
Criterion
protected void clearCache()
public void variableAdded(V variable)
ModelListener
variableAdded
in interface ModelListener<V extends Variable<V,T>,T extends Value<V,T>>
variable
- added variablepublic void variableRemoved(V variable)
ModelListener
variableRemoved
in interface ModelListener<V extends Variable<V,T>,T extends Value<V,T>>
variable
- removed variablepublic void constraintAdded(Constraint<V,T> constraint)
ModelListener
constraintAdded
in interface ModelListener<V extends Variable<V,T>,T extends Value<V,T>>
constraint
- added constraintpublic void constraintRemoved(Constraint<V,T> constraint)
ModelListener
constraintRemoved
in interface ModelListener<V extends Variable<V,T>,T extends Value<V,T>>
constraint
- removed constraintprotected String getPercRev(double value, double min, double max)
public void getInfo(Map<String,String> info)
InfoProvider
public void getInfo(Map<String,String> info, Collection<V> variables)
InfoProvider