java.lang.Object
org.maxicp.cp.engine.core.AbstractCPConstraint
org.maxicp.cp.engine.constraints.SoftCardinalityDC
- All Implemented Interfaces:
CPConstraint,ConcreteConstraint<ConcreteCPModel>
Soft Global Cardinality Constraint
- Author:
- Pierre Schaus pschaus@gmail.com Algorithm based on the paper: Schaus, P., Van Hentenryck, P., invalid input: '&' Zanarini, A. Revisiting the soft global cardinality constraint. In CPAIOR 2010
-
Constructor Summary
ConstructorsConstructorDescriptionSoftCardinalityDC(CPIntVar[] x, int[] low, int[] up, CPIntVar viol) Constraint the values i to appear between low[i] and up[i] times in x but accept some violations to this rule.SoftCardinalityDC(CPIntVar[] x, int minval, int[] low, int[] up, CPIntVar viol) Constraint the values minval+i to appear between low[i] and up[i] times in x but accept some violations to this rule. -
Method Summary
Modifier and TypeMethodDescriptionintgetReducedCost(int i, int v) intgetValInBestAssignment(int i) booleanhasValInBestAssignment(int i) voidpost()Initializes the constraint when it is posted to the solver.voidPropagates the constraint.Methods inherited from class org.maxicp.cp.engine.core.AbstractCPConstraint
getSolver, isActive, isScheduled, priority, registerDelta, setActive, setScheduled, updateDeltas
-
Constructor Details
-
SoftCardinalityDC
Constraint the values minval+i to appear between low[i] and up[i] times in x but accept some violations to this rule. For the value vi = minval+i, let ci be the number of occurences in x and viol(vi) = max(0,low[i]-ci,ci-up[i]) i.e. viol(vi) is the shortage or excess wrt the prescribed cardinalities.- Parameters:
x-minval-low-up-viol- = sum(i) viol(i)
-
SoftCardinalityDC
Constraint the values i to appear between low[i] and up[i] times in x but accept some violations to this rule. For the value let ci be the number of occurences of i in x and viol(i) = max(0,low[i]-ci,ci-up[i]) i.e. viol(vi) is the shortage or excess wrt the prescribed cardinalities.- Parameters:
x-low-up-viol- = sum(i) viol(i)
-
-
Method Details
-
post
public void post()Description copied from interface:CPConstraintInitializes the constraint when it is posted to the solver.- Specified by:
postin interfaceCPConstraint- Overrides:
postin classAbstractCPConstraint
-
propagate
public void propagate()Description copied from interface:CPConstraintPropagates the constraint.- Specified by:
propagatein interfaceCPConstraint- Overrides:
propagatein classAbstractCPConstraint
-
hasValInBestAssignment
public boolean hasValInBestAssignment(int i) -
getValInBestAssignment
public int getValInBestAssignment(int i) -
getReducedCost
public int getReducedCost(int i, int v)
-