Package org.jacop.constraints.netflow
Class NetworkBuilder
- java.lang.Object
-
- org.jacop.constraints.netflow.NetworkBuilder
-
- Direct Known Subclasses:
Arithmetic.ArithmeticBuilder
,SoftAlldifferent.SoftAlldiffBuilder
,SoftGCC.SoftGCCBuilder
public class NetworkBuilder extends java.lang.Object
A builder class for the network flow constraints. Models should use or inherit from this class to build a network.- Version:
- 4.7
-
-
Field Summary
Fields Modifier and Type Field Description java.util.List<Arc>
arcList
IntVar
costVariable
java.util.List<VarHandler>
handlerList
private int
nextNodeName
java.util.List<Node>
nodeList
-
Constructor Summary
Constructors Constructor Description NetworkBuilder()
NetworkBuilder(IntVar costVariable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Arc
addArc(Node from, Node to)
Arc
addArc(Node from, Node to, int weight)
Arc
addArc(Node from, Node to, int weight, int capacity)
Arc
addArc(Node from, Node to, int weight, int lowerCapacity, int upperCapacity)
Arc
addArc(Node from, Node to, int weight, IntVar xVar)
Arc
addArc(Node from, Node to, IntVar wVar, int lowerCapacity, int upperCapacity)
Arc
addArc(Node from, Node to, IntVar wVar, IntVar xVar)
Node
addNode()
Node
addNode(int balance)
Node
addNode(java.lang.String name)
Node
addNode(java.lang.String name, int balance)
NetworkFlow
build()
java.util.ArrayList<IntVar>
listVariables()
java.util.List<Constraint>
primitiveDecomposition(Store store)
Generally speaking, especially in case of multiple arcs between two nodes and structure constraints imposed on arcs makes it hard to decompose network flow constraint into primitive ones.void
setCostVariable(IntVar costVariable)
private void
sumC(java.util.List<Constraint> list, Store store, java.util.List<IntVar> vars, IntVar result)
Node[][]
valueGraph(IntVar[] vars, IntDomain[] domains)
Returns two arrays containing the nodes for each variable and the nodes for each domain, respectively.
-
-
-
Field Detail
-
nextNodeName
private int nextNodeName
-
costVariable
public IntVar costVariable
-
nodeList
public final java.util.List<Node> nodeList
-
arcList
public final java.util.List<Arc> arcList
-
handlerList
public final java.util.List<VarHandler> handlerList
-
-
Constructor Detail
-
NetworkBuilder
public NetworkBuilder()
-
NetworkBuilder
public NetworkBuilder(IntVar costVariable)
-
-
Method Detail
-
setCostVariable
public void setCostVariable(IntVar costVariable)
-
addNode
public Node addNode()
-
addNode
public Node addNode(int balance)
-
addNode
public Node addNode(java.lang.String name)
-
addNode
public Node addNode(java.lang.String name, int balance)
-
valueGraph
public Node[][] valueGraph(IntVar[] vars, IntDomain[] domains)
Returns two arrays containing the nodes for each variable and the nodes for each domain, respectively.- Parameters:
vars
- varibales for nodesdomains
- nodes for each variable- Returns:
- two arrays containing the nodes for each variable and the nodes for each domain, respectively
-
listVariables
public java.util.ArrayList<IntVar> listVariables()
-
build
public NetworkFlow build()
-
primitiveDecomposition
public java.util.List<Constraint> primitiveDecomposition(Store store)
Generally speaking, especially in case of multiple arcs between two nodes and structure constraints imposed on arcs makes it hard to decompose network flow constraint into primitive ones. Since, the decomposition introduces new variables and removal of artificial solutions is not practically achievable in all cases it is possible that decomposition will have more solutions due to the fact that decomposition may use more expensive arcs to transfer the flow.- Parameters:
store
- current store- Returns:
- decomposed network using primitive constraints
-
sumC
private void sumC(java.util.List<Constraint> list, Store store, java.util.List<IntVar> vars, IntVar result)
-
-