Module org.maxicp

Interface CPSeqVar

All Superinterfaces:
ConcreteSeqVar, ConcreteVar, CPVar, Expression, SeqExpression, SeqVar, Serializable, Var
All Known Implementing Classes:
CPSeqVarImpl, CPSeqVarViewFlip

public interface CPSeqVar extends CPVar, ConcreteSeqVar
  • Method Details

    • getSolver

      CPSolver getSolver()
      Returns the solver in which this variable was created.
      Returns:
      the solver in which this variable was created.
    • isFixed

      boolean isFixed()
      Returns true if every node is either a member or an excluded node.
      Specified by:
      isFixed in interface CPVar
      Specified by:
      isFixed in interface Expression
      Specified by:
      isFixed in interface SeqVar
      Returns:
      true if every node is either a member or an excluded node.
    • getNodeVar

      CPNodeVar getNodeVar(int node)
      Returns the variable related to a node.
      Parameters:
      node - node.
      Returns:
      variable related to a node.
    • isNodeRequired

      CPBoolVar isNodeRequired(int node)
      Gives a variable telling if a given node must be visited
      Specified by:
      isNodeRequired in interface SeqVar
      Parameters:
      node - node in the sequence
      Returns:
      variable set to true if the node must be visited
    • fillNode

      int fillNode(int[] dest, SeqStatus status)
      Copies the nodes matching a status into an array.
      Specified by:
      fillNode in interface SeqVar
      Parameters:
      dest - an array large enough dest.length >= nNode(status).
      status - status that must be matched by the nodes.
      Returns:
      the number of nodes matching the status and dest[0,...,nNode(status)-1] contains the nodes in an arbitrary order.
    • nNode

      int nNode(SeqStatus status)
      Gives the number of nodes matching a status.
      Specified by:
      nNode in interface SeqVar
      Parameters:
      status - status that must be matched by the nodes.
      Returns:
      the number of nodes matching the status.
    • nNode

      int nNode()
      Gives the total number of nodes.
      Specified by:
      nNode in interface SeqVar
      Returns:
      the total number of nodes.
    • isNode

      boolean isNode(int node, SeqStatus status)
      Tells if a node is matching a status.
      Specified by:
      isNode in interface SeqVar
      Parameters:
      node - node.
      status - status that must be matched by the node.
      Returns:
      true if the node is matching the status.
    • start

      int start()
      First member of the sequence
      Specified by:
      start in interface SeqVar
      Returns:
      first member of the sequence
    • end

      int end()
      Last member of the sequence
      Specified by:
      end in interface SeqVar
      Returns:
      last member of the sequence
    • memberAfter

      int memberAfter(int node)
      Returns the member following another member in the sequence.
      Specified by:
      memberAfter in interface SeqVar
      Parameters:
      node - member within the sequence.
      Returns:
      member following the given node in the sequence.
    • memberBefore

      int memberBefore(int node)
      Returns the member preceding another member in the sequence.
      Specified by:
      memberBefore in interface SeqVar
      Parameters:
      node - member within the sequence.
      Returns:
      member preceding the given node in the sequence.
    • fillPred

      int fillPred(int node, int[] dest, SeqStatus status)
      Copies the predecessors of a node matching a status into an array.
      Specified by:
      fillPred in interface SeqVar
      Parameters:
      node - node.
      dest - an array large enough
      status - status that must be matched by the predecessors.
      Returns:
      the number of predecessors matching the status and dest[0,...,nPred(node, status)-1] contains the predecessors in an arbitrary order.
    • fillPred

      int fillPred(int node, int[] dest)
      Copies the predecessors of a node into an array.
      Specified by:
      fillPred in interface SeqVar
      Parameters:
      node - node.
      dest - an array large enough dest.length >= nPred(node).
      Returns:
      the number of predecessors and dest[0,...,nPred(node)-1] contains the predecessors in an arbitrary order.
    • nPred

      int nPred(int node)
      Returns the number of predecessors of a node.
      Specified by:
      nPred in interface SeqVar
      Parameters:
      node - node.
      Returns:
      the number of predecessors.
    • fillSucc

      int fillSucc(int node, int[] dest, SeqStatus status)
      Copies the successors of a node matching a status into an array.
      Specified by:
      fillSucc in interface SeqVar
      Parameters:
      node - node.
      dest - an array large enough dest.length >= nSucc(node, status).
      status - status that must be matched by the nodes.
      Returns:
      the number of successors matching the status and dest[0,...,nSucc(node, status)-1] contains the successors in an arbitrary order.
    • fillSucc

      int fillSucc(int node, int[] dest)
      Copies the successors of a node into an array.
      Specified by:
      fillSucc in interface SeqVar
      Parameters:
      node - node.
      dest - an array large enough dest.length >= nSucc(node).
      Returns:
      the number of successors and dest[0,...,nSucc(node)-1] contains the successors in an arbitrary order.
    • nSucc

      int nSucc(int node)
      Returns the number of successors of a node.
      Specified by:
      nSucc in interface SeqVar
      Parameters:
      node - node.
      Returns:
      the number of successors matching the status.
    • fillInsert

      int fillInsert(int node, int[] dest)
      Fills an array with the insertions for a node. Equivalent to fillPred(node, dest, MEMBER).
      Specified by:
      fillInsert in interface SeqVar
      Parameters:
      node - node.
      dest - an array large enough dest.length >= nInsert(node).
      Returns:
      the number of insertions and dest[0,...,nInsert(node)-1] contains the insertions in an arbitrary order.
    • nInsert

      int nInsert(int node)
      Returns the number of insertions of a node.
      Specified by:
      nInsert in interface SeqVar
      Parameters:
      node - node.
      Returns:
      the number of insertions of a node.
    • hasEdge

      boolean hasEdge(int from, int to)
      Tells if a directed edge exists between two nodes.
      Specified by:
      hasEdge in interface SeqVar
      Parameters:
      from - origin of the edge.
      to - destination of the edge.
      Returns:
      true if the directed edge exists between two nodes.
    • hasInsert

      boolean hasInsert(int prev, int node)
      Tells if an insertion is valid. An insert operation is valid iff - prev is a member node ; - node is an insertable node (either possible or a required node not yet inserted) ; - hasEdge(prev, node) ; - hasEdge(node, memberAfter(prev)).
      Specified by:
      hasInsert in interface SeqVar
      Parameters:
      prev - a member node.
      node - an insertable node.
      Returns:
      true if the node can be inserted after the given member.
    • exclude

      void exclude(int node)
      Excludes a node from the sequence.
      Parameters:
      node - node to be excluded.
      Throws:
      InconsistencyException - if the node is required (isNode(node, REQUIRED)).
    • require

      void require(int node)
      Requires a node in the sequence.
      Parameters:
      node - node to be required.
      Throws:
      InconsistencyException - if the node is excluded (isNode(node, EXCLUDED)).
    • insert

      void insert(int prev, int node)
      Inserts a node in the sequence after a given member. Requires the node if it was not required yet.
      Parameters:
      prev - member after which the node will be inserted.
      node - node inserted in the sequence.
      Throws:
      InconsistencyException - if the insertion is invalid (!hasInsert(prev, node)).
      IllegalArgumentException - if prev and node are two member nodes that are not consecutive (isNode(prev, MEMBER) && isNode(node, MEMBER) && memberAfter(prev) != node)
    • notBetween

      void notBetween(int prev, int node, int succ)
      Forbids a subsequence of length 3 to appear, removing from the domain all sequences containing the sub-sequence given as input. For technical reasons, the two endpoints of the subsequence must belong to the current partial sequence.
      Parameters:
      prev - origin of the subsequence, a member node
      node - node in the middle of the subsequence
      succ - end of the subsequence, a member node
      Throws:
      InconsistencyException - if the subsequence to remove appears within the sequence
    • whenFixed

      void whenFixed(Runnable f)
      Asks that the closure is called whenever the domain is fixed isFixed().
      Parameters:
      f - the closure.
    • whenInsert

      void whenInsert(Runnable f)
      Asks that the closure is called whenever an insertion happens.
      Parameters:
      f - the closure.
    • whenInsertRemoved

      void whenInsertRemoved(Runnable f)
      Asks that the closure is called whenever an insertion is removed.
      Parameters:
      f - the closure.
    • whenExclude

      void whenExclude(Runnable f)
      Asks that the closure is called whenever an exclusion happens.
      Parameters:
      f - the closure.
    • whenRequire

      void whenRequire(Runnable f)
      Asks that the closure is called a node is required.
      Parameters:
      f - the closure.
    • propagateOnFix

      void propagateOnFix(CPConstraint c)
      Asks that CPConstraint.propagate() is called whenever the domain is fixed isFixed() In such a state the variable is fixed and we say that a fix event occurs.
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on fix events of this variable.
    • propagateOnInsertRemoved

      void propagateOnInsertRemoved(CPConstraint c)
      Asks that CPConstraint.propagate() is called whenever an insertion is removed We say that a removeInsert event occurs.
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on removeInsert events of this variable.
    • propagateOnInsert

      void propagateOnInsert(CPConstraint c)
      Asks that CPConstraint.propagate() is called whenever an insertion happens. We say that an insert event occurs.
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on insert events of this variable.
    • propagateOnExclude

      void propagateOnExclude(CPConstraint c)
      Asks that CPConstraint.propagate() is called whenever an exclusion happens. We say that an exclude event occurs.
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on exclude events of this variable.
    • propagateOnRequire

      void propagateOnRequire(CPConstraint c)
      Asks that CPConstraint.propagate() is called whenever a node is required. We say that an require event occurs.
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on require events of this variable.
    • membersOrdered

      default String membersOrdered()
      Returns a string representation of the members, ordered following the sequence from start() to end(), separated by " -> ".
      Returns:
      string representation of the members, ordered following the sequence from start() to end().
    • membersOrdered

      default String membersOrdered(String join)
      Returns a string representation of the members, ordered following the sequence from start() to end(), separated by the given delimiter.
      Parameters:
      join - delimiter between two member nodes.
      Returns:
      string representation of the members, ordered following the sequence from start() to end(). The nodes are separated by the given delimiter.
    • membersOrdered

      default String membersOrdered(String join, Predicate<Integer> filter)
      Returns a string representation of the members, ordered following the sequence from start() to end(), separated by the given delimiter.
      Parameters:
      join - delimiter between two member nodes.
      filter - filter the nodes that are valid for giving the representation. Only nodes evaluated to true are included in the representation
      Returns:
      string representation of the members, ordered following the sequence from start() to end(). The nodes are separated by the given delimiter.
    • toGraphViz

      default String toGraphViz()
      Exports the variable into a GraphViz format See ...
      Returns:
      variable encoded into a GraphViz format