- All Superinterfaces:
ConcreteSeqVar,ConcreteVar,CPVar,Expression,SeqExpression,SeqVar,Serializable,Var
- All Known Implementing Classes:
CPSeqVarImpl,CPSeqVarViewFlip
-
Method Summary
Modifier and TypeMethodDescriptionintend()Last member of the sequencevoidexclude(int node) Excludes a node from the sequence.intfillInsert(int node, int[] dest) Fills an array with the insertions for a node.intCopies the nodes matching a status into an array.intfillPred(int node, int[] dest) Copies the predecessors of a node into an array.intCopies the predecessors of a node matching a status into an array.intfillSucc(int node, int[] dest) Copies the successors of a node into an array.intCopies the successors of a node matching a status into an array.getNodeVar(int node) Returns the variable related to a node.Returns the solver in which this variable was created.booleanhasEdge(int from, int to) Tells if a directed edge exists between two nodes.booleanhasInsert(int prev, int node) Tells if an insertion is valid.voidinsert(int prev, int node) Inserts a node in the sequence after a given member.booleanisFixed()Returns true if every node is either a member or an excluded node.booleanTells if a node is matching a status.isNodeRequired(int node) Gives a variable telling if a given node must be visitedintmemberAfter(int node) Returns the member following another member in the sequence.intmemberBefore(int node) Returns the member preceding another member in the sequence.default StringReturns a string representation of the members, ordered following the sequence fromstart()toend(), separated by " -> ".default StringmembersOrdered(String join) Returns a string representation of the members, ordered following the sequence fromstart()toend(), separated by the given delimiter.default StringmembersOrdered(String join, Predicate<Integer> filter) Returns a string representation of the members, ordered following the sequence fromstart()toend(), separated by the given delimiter.intnInsert(int node) Returns the number of insertions of a node.intnNode()Gives the total number of nodes.intGives the number of nodes matching a status.voidnotBetween(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.intnPred(int node) Returns the number of predecessors of a node.intnSucc(int node) Returns the number of successors of a node.voidAsks thatCPConstraint.propagate()is called whenever an exclusion happens.voidAsks thatCPConstraint.propagate()is called whenever the domain is fixedisFixed()In such a state the variable is fixed and we say that a fix event occurs.voidAsks thatCPConstraint.propagate()is called whenever an insertion happens.voidAsks thatCPConstraint.propagate()is called whenever an insertion is removed We say that a removeInsert event occurs.voidAsks thatCPConstraint.propagate()is called whenever a node is required.voidrequire(int node) Requires a node in the sequence.intstart()First member of the sequencedefault StringExports the variable into a GraphViz format See ...voidAsks that the closure is called whenever an exclusion happens.voidAsks that the closure is called whenever the domain is fixedisFixed().voidAsks that the closure is called whenever an insertion happens.voidAsks that the closure is called whenever an insertion is removed.voidAsks that the closure is called a node is required.Methods inherited from interface org.maxicp.modeling.algebra.Expression
getModelProxy, subexpressionsMethods inherited from interface org.maxicp.modeling.SeqVar
computeSubexpressions, mapSubexpressionsMethods inherited from interface org.maxicp.modeling.Var
getModelProxy
-
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. -
getNodeVar
Returns the variable related to a node.- Parameters:
node- node.- Returns:
- variable related to a node.
-
isNodeRequired
Gives a variable telling if a given node must be visited- Specified by:
isNodeRequiredin interfaceSeqVar- Parameters:
node- node in the sequence- Returns:
- variable set to true if the node must be visited
-
fillNode
Copies the nodes matching a status into an array. -
nNode
Gives the number of nodes matching a status. -
nNode
int nNode()Gives the total number of nodes. -
isNode
Tells if a node is matching a status. -
start
int start()First member of the sequence -
end
int end()Last member of the sequence -
memberAfter
int memberAfter(int node) Returns the member following another member in the sequence.- Specified by:
memberAfterin interfaceSeqVar- 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:
memberBeforein interfaceSeqVar- Parameters:
node- member within the sequence.- Returns:
- member preceding the given node in the sequence.
-
fillPred
Copies the predecessors of a node matching a status into an array. -
fillPred
int fillPred(int node, int[] dest) Copies the predecessors of a node into an array. -
nPred
int nPred(int node) Returns the number of predecessors of a node. -
fillSucc
Copies the successors of a node matching a status into an array.- Specified by:
fillSuccin interfaceSeqVar- Parameters:
node- node.dest- an array large enoughdest.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. -
nSucc
int nSucc(int node) Returns the number of successors of a node. -
fillInsert
int fillInsert(int node, int[] dest) Fills an array with the insertions for a node. Equivalent tofillPred(node, dest, MEMBER).- Specified by:
fillInsertin interfaceSeqVar- Parameters:
node- node.dest- an array large enoughdest.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. -
hasEdge
boolean hasEdge(int from, int to) Tells if a 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)). -
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 nodenode- node in the middle of the subsequencesucc- end of the subsequence, a member node- Throws:
InconsistencyException- if the subsequence to remove appears within the sequence
-
whenFixed
Asks that the closure is called whenever the domain is fixedisFixed().- Parameters:
f- the closure.
-
whenInsert
Asks that the closure is called whenever an insertion happens.- Parameters:
f- the closure.
-
whenInsertRemoved
Asks that the closure is called whenever an insertion is removed.- Parameters:
f- the closure.
-
whenExclude
Asks that the closure is called whenever an exclusion happens.- Parameters:
f- the closure.
-
whenRequire
Asks that the closure is called a node is required.- Parameters:
f- the closure.
-
propagateOnFix
Asks thatCPConstraint.propagate()is called whenever the domain is fixedisFixed()In such a state the variable is fixed and we say that a fix event occurs.- Parameters:
c- the constraint for which theCPConstraint.propagate()method should be called on fix events of this variable.
-
propagateOnInsertRemoved
Asks thatCPConstraint.propagate()is called whenever an insertion is removed We say that a removeInsert event occurs.- Parameters:
c- the constraint for which theCPConstraint.propagate()method should be called on removeInsert events of this variable.
-
propagateOnInsert
Asks thatCPConstraint.propagate()is called whenever an insertion happens. We say that an insert event occurs.- Parameters:
c- the constraint for which theCPConstraint.propagate()method should be called on insert events of this variable.
-
propagateOnExclude
Asks thatCPConstraint.propagate()is called whenever an exclusion happens. We say that an exclude event occurs.- Parameters:
c- the constraint for which theCPConstraint.propagate()method should be called on exclude events of this variable.
-
propagateOnRequire
Asks thatCPConstraint.propagate()is called whenever a node is required. We say that an require event occurs.- Parameters:
c- the constraint for which theCPConstraint.propagate()method should be called on require events of this variable.
-
membersOrdered
Returns a string representation of the members, ordered following the sequence fromstart()toend(), separated by " -> ".- Returns:
- string representation of the members, ordered following the sequence
from
start()toend().
-
membersOrdered
Returns a string representation of the members, ordered following the sequence fromstart()toend(), separated by the given delimiter.- Parameters:
join- delimiter between two member nodes.- Returns:
- string representation of the members, ordered following the sequence
from
start()toend(). The nodes are separated by the given delimiter.
-
membersOrdered
Returns a string representation of the members, ordered following the sequence fromstart()toend(), 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()toend(). The nodes are separated by the given delimiter.
-
toGraphViz
Exports the variable into a GraphViz format See ...- Returns:
- variable encoded into a GraphViz format
-