Module org.maxicp

Class Precedence

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

public class Precedence extends AbstractCPConstraint
  • Constructor Summary

    Constructors
    Constructor
    Description
    Precedence(CPSeqVar seqVar, boolean appearTogether, int... order)
    Ensures that a list of nodes appears in a given relative order within the sequence, if they appear.
    Precedence(CPSeqVar seqVar, int... order)
    Ensures that a list of nodes appears in a given relative order within the sequence, if they appear Example of a solution: order = [1, 3, 5, 9] seqVar = 1 -> 2 -> 3 -> 4 -> 5 -> 8 Note that nodes can be put in between and some nodes in `order` may be excluded Example of a non solution (since 1 cannot appear before 5): order = [1, 3, 5, 9] seqVar = 5 -> 2 -> 4 -> 1 -> 8
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Initializes the constraint when it is posted to the solver.
    void
    Propagates the constraint.

    Methods inherited from class org.maxicp.cp.engine.core.AbstractCPConstraint

    getSolver, isActive, isScheduled, priority, registerDelta, setActive, setScheduled, updateDeltas

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Precedence

      public Precedence(CPSeqVar seqVar, int... order)
      Ensures that a list of nodes appears in a given relative order within the sequence, if they appear Example of a solution: order = [1, 3, 5, 9] seqVar = 1 -> 2 -> 3 -> 4 -> 5 -> 8 Note that nodes can be put in between and some nodes in `order` may be excluded Example of a non solution (since 1 cannot appear before 5): order = [1, 3, 5, 9] seqVar = 5 -> 2 -> 4 -> 1 -> 8
      Parameters:
      seqVar - sequence variable
      order - nodes that must respect the given ordering if they are included in the sequence
    • Precedence

      public Precedence(CPSeqVar seqVar, boolean appearTogether, int... order)
      Ensures that a list of nodes appears in a given relative order within the sequence, if they appear. Example of a solution: order = [1, 3, 5, 9]. seqVar = 1 -> 2 -> 3 -> 4 -> 5 -> 8. Note that nodes can be put in between and some nodes in `order` may be excluded, provided that appearTogether is set to false. Example of a non solution (since 1 cannot appear before 5): order = [1, 3, 5, 9]. seqVar = 5 -> 2 -> 4 -> 1 -> 8.
      Parameters:
      seqVar - sequence variable
      appearTogether - if set to true, all nodes in order must appear together. Requiring one means requiring all of them, and excluding one means excluding all of them
      order - nodes that must respect the given ordering if they are included in the sequence
  • Method Details