V
- VariableT
- Valuepublic class ConflictStatistics<V extends Variable<V,T>,T extends Value<V,T>> extends Extension<V,T> implements ConstraintListener<V,T>
CBS[Va = va, Vb != vb] = cab,
stating that the assignment Va = va caused the unassignment of Vb = vb a
total of cab times in the past. Note that in case of n-ary constraints (where
n > 2), this does not imply that the assignments Va = va and Vb = vb cannot
be used together. The proposed conflict-based statistics do not actually work
with any constraint, they only memorize unassignments and the assignment that
caused them. Let us consider a variable Va selected by the
VariableSelection.selectVariable(Solution)
function and a value va
selected by ValueSelection.selectValue(Solution, Variable)
. Once the
assignment Vb = vb is selected by Model.conflictValues(Assignment, Value)
to be
unassigned, the array cell CBS[Va = va, Vb != vb] is incremented by one.
A = a → 3 x B != b, 4 x B
!= c, 2 x C != a, 120 x D != a
expresses that variable B lost its assignment b three times and its
assignment c four times, variable C lost its assignment a two times, and D
lost its assignment a 120 times, all because of later assignments of value a
to variable A. This structure is being used in the value selection heuristics
to evaluate existing conflicts with the assigned variables. For example, if
there is a variable A selected and if the value a is in conflict with the
assignment B = b, we know that a similar problem has already occurred 3x in
the past, and hence the conflict A = a is weighted with the number 3. Parameter | Type | Comment |
---|---|---|
ConflictStatistics.Ageing | Double |
Ageing of the conflict-based statistics. Every memorized conflict is aged (multiplited) by this factor for every iteration which passed from the time it was memorized. For instance, if there was a conflict 10 iterations ago, its value is ageing^10 (default is 1.0 -- no ageing). |
ConflictStatistics.AgeingHalfTime | Integer |
Another way how to express ageing: number of iterations to decrease a conflict to 1/2 (default is 0 -- no ageing) |
Solver
,
Model
,
ValueSelection
,
VariableSelection
Constructor and Description |
---|
ConflictStatistics(Solver<V,T> solver,
DataProperties properties) |
Modifier and Type | Method and Description |
---|---|
void |
constraintAdded(Constraint<V,T> constraint)
Called when a constraint is added to the model
|
void |
constraintAfterAssigned(Assignment<V,T> assignment,
long iteration,
Constraint<V,T> constraint,
T assigned,
Set<T> unassigned)
Increments appropriate counters when there is a value unassigned
|
void |
constraintBeforeAssigned(Assignment<V,T> assignment,
long iteration,
Constraint<V,T> constraint,
T assigned,
Set<T> unassigned)
Called by the constraint, before a value is assigned to its variable.
|
void |
constraintRemoved(Constraint<V,T> constraint)
Called when a constraint is removed from the model
|
long |
countAssignments(V variable)
Count the number of past assignments of a variable
|
long |
countPotentialConflicts(Assignment<V,T> assignment,
long iteration,
T value,
int limit)
Counts potential number of unassignments of if the given value is
selected.
|
double |
countRemovals(long iteration,
Collection<T> conflictValues,
T value)
Counts number of unassignments of the given conflicting values caused by
the assignment of the given value.
|
double |
countRemovals(long iteration,
T conflictValue,
T value)
Counts number of unassignments of the given conflicting value caused by
the assignment of the given value.
|
Map<AssignedValue<T>,List<AssignedValue<T>>> |
getNoGoods() |
void |
register(Model<V,T> model)
Registration of a model.
|
void |
reset() |
String |
toString() |
void |
unregister(Model<V,T> model)
Unregistration of a model.
|
void |
variableUnassigned(long iteration,
T unassignedValue,
T assignedValue) |
afterAssigned, afterUnassigned, beforeAssigned, beforeUnassigned, getModel, getProperties, getSolver, init, isRegistered, variableAdded, variableRemoved
public ConflictStatistics(Solver<V,T> solver, DataProperties properties)
public void register(Model<V,T> model)
Extension
public void unregister(Model<V,T> model)
Extension
public void reset()
public Map<AssignedValue<T>,List<AssignedValue<T>>> getNoGoods()
public void variableUnassigned(long iteration, T unassignedValue, T assignedValue)
public double countRemovals(long iteration, Collection<T> conflictValues, T value)
iteration
- current iterationconflictValues
- values conflicting with the given valuevalue
- given valuepublic double countRemovals(long iteration, T conflictValue, T value)
iteration
- current iterationconflictValue
- value conflicting with the given valuevalue
- given valuepublic long countPotentialConflicts(Assignment<V,T> assignment, long iteration, T value, int limit)
assignment
- current assignmentiteration
- current iterationvalue
- given valuelimit
- conflict limitpublic long countAssignments(V variable)
variable
- given variablepublic void constraintBeforeAssigned(Assignment<V,T> assignment, long iteration, Constraint<V,T> constraint, T assigned, Set<T> unassigned)
ConstraintListener
constraintBeforeAssigned
in interface ConstraintListener<V extends Variable<V,T>,T extends Value<V,T>>
assignment
- current assignmentiteration
- current iterationconstraint
- source constraintassigned
- value which will be assigned to its variable (
Value.variable()
)unassigned
- set of conflicting values which will be unassigned by the
constraint before it assigns the given valuepublic void constraintAfterAssigned(Assignment<V,T> assignment, long iteration, Constraint<V,T> constraint, T assigned, Set<T> unassigned)
constraintAfterAssigned
in interface ConstraintListener<V extends Variable<V,T>,T extends Value<V,T>>
assignment
- current assignmentiteration
- current iterationconstraint
- source constraintassigned
- value which was assigned to its variable (
Value.variable()
)unassigned
- set of conflicting values which were unassigned by the
constraint before it assigned the given valuepublic void constraintAdded(Constraint<V,T> constraint)
Extension
public void constraintRemoved(Constraint<V,T> constraint)
Extension