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
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 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 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

      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 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: 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)