Module org.maxicp

Class SoftCardinalityDC

java.lang.Object
org.maxicp.cp.engine.core.AbstractCPConstraint
org.maxicp.cp.engine.constraints.SoftCardinalityDC
All Implemented Interfaces:
CPConstraint, ConcreteConstraint<ConcreteCPModel>

public class SoftCardinalityDC extends AbstractCPConstraint
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 Details

    • SoftCardinalityDC

      public 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. For the value vi = minval+i, let ci be the number of occurrences 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 - the array of variables
      minval - the minimum value of the cardinality range
      low - the lower cardinality bounds
      up - the upper cardinality bounds
      viol - the total violation variable sum(i) viol(i)
    • SoftCardinalityDC

      public SoftCardinalityDC(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. For the value let ci be the number of occurrences 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 - the array of variables
      low - the lower cardinality bounds
      up - the upper cardinality bounds
      viol - the total violation variable sum(i) viol(i)
  • Method Details

    • post

      public void post()
      Description copied from interface: CPConstraint
      Initializes the constraint when it is posted to the solver.
      Specified by:
      post in interface CPConstraint
      Overrides:
      post in class AbstractCPConstraint
    • propagate

      public void propagate()
      Description copied from interface: CPConstraint
      Propagates the constraint.
      Specified by:
      propagate in interface CPConstraint
      Overrides:
      propagate in class AbstractCPConstraint
    • hasValInBestAssignment

      public boolean hasValInBestAssignment(int i)
    • getValInBestAssignment

      public int getValInBestAssignment(int i)
    • getReducedCost

      public int getReducedCost(int i, int v)