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.
Algorithm based on the paper: Schaus, P., Van Hentenryck, P., & Zanarini, A. Revisiting the soft global cardinality constraint. In CPAIOR 2010
- Author:
- Pierre Schaus pschaus@gmail.com
-
Constructor Summary
ConstructorsConstructorDescriptionSoftCardinalityDC(CPIntVar[] x, int[] low, int[] up, CPIntVar viol) Constraint the valuesito appear betweenlow[i]andup[i]times inxbut accept some violations to this rule.SoftCardinalityDC(CPIntVar[] x, int minval, int[] low, int[] up, CPIntVar viol) Constraint the valuesminval+ito appear betweenlow[i]andup[i]times inxbut 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 valuesminval+ito appear betweenlow[i]andup[i]times inxbut accept some violations to this rule. For the valuevi = minval+i, letcibe the number of occurrences inxandviol(vi) = max(0, low[i]-ci, ci-up[i]), i.e.,viol(vi)is the shortage or excess wrt the prescribed cardinalities.- Parameters:
x- the array of variablesminval- the minimum value of the cardinality rangelow- the lower cardinality boundsup- the upper cardinality boundsviol- the total violation variablesum(i) viol(i)
-
SoftCardinalityDC
Constraint the valuesito appear betweenlow[i]andup[i]times inxbut accept some violations to this rule. For the value letcibe the number of occurrences ofiinxandviol(i) = max(0, low[i]-ci, ci-up[i]), i.e.,viol(vi)is the shortage or excess wrt the prescribed cardinalities.- Parameters:
x- the array of variableslow- the lower cardinality boundsup- the upper cardinality boundsviol- the total violation variablesum(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)
-