Network flow problems in constraint programming Alexander Bockmayr1 , Nicolai Pisaruk1 , and Abderrahmane Aggoun2
?
1
Universit´e Henri Poincar´e, LORIA B.P. 239, F-54506 Vandœuvre-l`es-Nancy, France {bockmayr|pisaruk}@loria.fr 2
COSYTEC S.A., Parc Club Orsay Universit´e, 4, rue Jean Rostand, F-91893 Orsay, France,
[email protected]
Abstract. We introduce a new global constraint for modeling and solving network flow problems in constraint programming. We describe the declarative and operational semantics of the flow constraint and illustrate its use through a number of applications.
1
Introduction
Network flows are a fundamental concept in mathematics and computer science. They play an important role in various applications, e.g. in transportation, telecommunication, or supply chain optimization [2, 8]. Many classical network models can be solved very quickly, they have naturally integer solutions, and they provide a modeling language for real world problems that is easier to understand than, e.g., the language of linear programming. In spite of their importance, constraint programming systems normally do not provide special support to deal with network flows. We introduce here a new global constraint flow for modeling and solving network problems inside constraint programming. The flow constraint is complementary to existing global constraints. Typically, it is used together with other global constraints and all kind of side constraints. While pure network flow problems may be solved directly by specialized algorithms [2, 8], our goal here is to handle efficiently problems in constraint programming that involve network flows as a subproblem. Global constraints are a key concept of constraint programming. They were first introduced in the Chip system [1, 5]. Since that time, they have been continuously studied in the literature. Recent work on global constraints includes, e.g., [12, 16, 17]. A classification scheme for global constraints is presented in [4]. The role of global constraints for the integration of constraint programming and mathematical programming is discussed, among others, in [7, 9, 15, 13, 14]. There are two main benefits of global constraints. On the one hand, they provide high-level abstractions for modeling complex combinatorial problems in ?
This work was partially supported by the European Commission, Growth Programme, Research Project LISCOS – Large Scale Integrated Supply Chain Optimisation Software, Contract No. G1RD-CT-1999-00034
a natural and declarative way. They serve as building blocks for developing large applications. On the other hand, they make available efficient algorithms for solving specific combinatorial problems within a general-purpose solver. Typically, global constraints give much stronger propagation than equivalent formulations based on elementary constraints, provided such formulations exist at all. The organization of this paper is as follows. We start in Sect. 2 with the declarative semantics of the new constraint. First we describe the underlying mathematical model, then we introduce the flow constraint in two different forms. A key feature of this constraint are the conversion nodes. They are particularly useful when modeling supply chain optimization problems. Sect. 3 discusses the operational semantics. We present a decomposition technique for generalized networks with conversion nodes and expose the main ideas used in propagation. Sect. 4 contains three applications of the flow constraint: maximum flow, production planning, and personnel scheduling. Finally, Sect. 5 briefly describes the current implementation of the flow constraint within the Chip system.
2
A global constraint for flow problems
In this section, we introduce the new global constraint flow. We start by describing the underlying mathematical model. 2.1
Generalized flow networks
A generalized flow network N = (V = V s ∪ V d ∪ V c , E; l, u, c; γ, d− , d+ , q) is a directed network of n nodes and m arcs, where – V is the set of nodes, which is partitioned into three subsets V s , V d , and V c of supply, demand, and conversion nodes respectively; – E is the set of directed arcs; – l, u : E → R are lower and upper capacity functions; – c : E → R is an edge cost function; – γ : E(V, V c ) → R is a conversion function; – q : V → R is a node cost function; – d− , d+ : V → R+ are lower and upper demand functions. Here E(X, Y ), for X, Y ⊆ V , denotes the set {(v, w) ∈ E : v ∈ X, w ∈ Y } of arcs leaving X and entering Y . An arc (v, w) ∈ E(V, V c ) is called a conversion arc. A pseudoflow in N is a function f : E → R that satisfies the capacity constraints l(v, w) ≤ f (v, w) ≤ u(v, w), (v, w) ∈ E. (1) For a pseudoflow f , the inflow, outflow, and excess at node v ∈ V are defined by X def inf (v) = f (w, v), (w,v)∈E(V,v)
def
outf (v) =
X
f (v, w),
(v,w)∈E(v,V ) def
excf (v) = inf (v) − outf (v).
A circulation is a pseudoflow f in N with excf (v) = 0, for all v ∈ V . The demand at node v ∈ V is given by −excf (v), if v ∈ V s , def d(v) = excf (v), if v ∈ V d , outf (v), if v ∈ V c .
A pseudoflow f is a flow if it satisfies the balance constraints d− (v) ≤ d(v) ≤ d+ (v),
v ∈ V,
(2)
and the flow conversion constraints f (v, w) = γ(v, w) · outf (w),
(v, w) ∈ E(V, w), w ∈ V c .
(3)
Conversion nodes are a key feature of the generalized flow networks introduced in this paper. They are particularly useful when modeling production processes, see Sect. 4.2. The flow conversion constraints allow one to state, e.g., that in order to produce 1 unit of product P , we need 1 unit of raw material R1 and two units of raw material R2 . The cost of a pseudoflow f is the value X X def c(f ) = c(v, w) f (v, w) + q(v) d(v) . (v,w)∈E
v∈V \V
Given a network N , the goal is usually to find a flow of minimum cost, i.e., to solve a minimum cost flow problem. 2.2
The flow constraint
To handle flow problems on generalized networks within constraint programming, we introduce a global constraint flow of the following form: flow(NodeType, Edge, Conv, EdgeCost, NodeCost, Demand, Flow, FlowVal), (4) where – NodeType: a list [s1 , . . . , sn ] of values from the set {supply,demand,conv}; si specifies the type of node i, respectively, supply, demand, or conversion; – Edge: a list of lists [[t1 , h1 ], . . . , [tm , hm ]] of values ti , hi from the set V = {1, . . . , n}; ti , hi are the tail and head of arc i; – Conv: a list [γ1 , . . . , γm ] of rational values γi or -; if defined, γi is the conversion factor of the conversion arc i; – EdgeCost: a list [c1 , . . . , cm ] of rational values ci ; ci is the unit flow cost along arc i; – NodeCost: a list [q1 , . . . , qn ] of rational values qi ; qi is the unit cost at node i; – Demand: a list [d1 , . . . , dn ] of variables di ; di is the demand at node i and + takes values from an interval [d− i , di ] ⊂ R + ; – Flow: a list [f1 , . . . , fm ] of variables fi ; fi is the flow along arc i and takes values from an interval [li , ui ] ⊂ R+ ; – FlowVal: a domain variable or a rational value.
In the context of finite domain constraint programming, we assume that all variables are defined over a finite domain of integer numbers. Note, however, that the algorithms described in this paper, can easily be extended to variables ranging over an interval of rational numbers. This is important when using the flow constraint within a hybrid CP/MIP solver. If the list EdgeCost (resp. NodeCost) is empty, the edge (resp. node) costs are assumed to be zero. A flow constraint is satisfiable if, in the network N that is defined by its arguments, there exists a flow whose cost value is FlowVal. For large networks, it may be preferable to define the flow constraint in the following equivalent form: flow([Node1 , . . . , Noden ], FlowVal),
(5)
where, for i = 1, . . . , n, Nodei is a list of the form [si , di , [[vi,1 , li,1 , ui,1 , ci,1 , fi,1 ], ..., [vi,k(i) , li,k(i) , ui,k(i) , ci,k(i) , fi,k(i) ]]] and – si is a value from the set {supply, demand, convwith , convwithout }, indicating whether node i is a supply node, a demand node, a conversion node with excess, or a conversion node without excess, respectively. – di is a variable, the demand at node i; it takes values from an interval + [d− i , di ] ⊂ R + ; – for j = 1, . . . , k(i), • vi,j is a value from {1, . . . , n}; (vi,1 , i), . . . , (vi,k(i) , i) are the arcs entering node i; • ci,j is a rational number, the cost of arc (vi,j , i); • fi,j is a variable, the flow along arc (vi,j , i); it takes values from an interval [li,j , ui,j ] ⊂ R+ . The interest of this alternative form of the flow constraint is that it can be constructed locally, i.e. by assembling separately data about the arcs entering each particular node v.
3
Operational semantics
In this section, we present the operational semantics of the flow constraint. A key question is how to handle conversion nodes. First we show how a generalized flow network N with conversion nodes can be decomposed into smaller networks N1 , . . . , Nk such that circulations in Ni yield flows in N and vice versa. 3.1
Decomposition into subnetworks
Let N = (V = V s ∪ V d ∪ V c , E; l, u, c; γ, d− , d+ , q) be a generalized flow network as defined in Sect. 2.1. Let G = (V, E) denote the graph of the net¯i ), i = 1, . . . , k, be the weak components of the subwork N . Let Gi = (V¯i , E graph G0 = (V, E(V, V \ V c )). For i = 1, . . . , k, we build the flow network
Ni = (Vi , Ei , ci , li , ui ) as follows. First we add a new node si , not previously def ¯i with two new in V , and set Vi = V¯i ∪ {si }. Next, we extend the set of arcs E families (see the example at the end of this section): def ¯ Ei = E i ∪ Di ∪ Hi , where def Di = {(si , v)} : v ∈ V¯i ∩ (V s ∪ V c )} ∪ {(v, si )} : v ∈ V¯i ∩ V d }, and def
Hi = {(v, si )w : (v, w) ∈ E(V¯i , V c )}. For each supply and conversion node v ∈ V¯i we include in Di the arc (si , v), and for each demand node v ∈ V¯i the arc (v, si ). Arcs (v, w) in the original network N that lead from a node v ∈ V¯i to a conversion node w are represented in Gi by an arc (v, si ) ∈ Hi that is labeled with the superscript ”w”. The cost function ci and the capacity functions l i , ui on Ei are defined as follows: def def def ¯i ci (v, w) = c(v, w), li (v, w) = l(v, w), ui (v, w) = u(v, w), (v, w) ∈ E def
li (si , v) = d− (v),
def
ui (si , v) = d+ (v), (si , v) ∈ Di
def
li (v, si ) = d− (v),
def
ui (v, si ) = d+ (v), (v, si ) ∈ Di
ci (si , v) = q(v), ci (v, si ) = q(v), ci (v, si )
w def
= c(v, w), li (v, si )
def
def
w def
= l(v, w), ui (v, si )
w def
= u(v, w), (v, si )w ∈ Hi
For i = 1, . . . , k, let f i be a circulation in Ni ; if the collection (f 1 , . . . , f k ) satisfies the constraints f i (v, si )w = γ(v, w)f j (sj , w),
(v, w) ∈ E(V¯i \ V c , V¯j ∩ V c ) ,
(6)
then it determines in the network N a flow f which is defined by f (v, w) =
½
f i (v, w), if (v, w) ∈ E(V¯i , V¯i ), f i (v, si )w , if (v, w) ∈ E(V¯i , V \ V¯i ).
(7)
Furthermore, the cost of the flow f is equal to the sum of the costs of the circulations f 1 , . . . , f k , i.e., c(f ) =
k X
ci (f i ),
(8)
i=1
def P where ci (f i ) = (v,w)∈Ei ci (v, w)f i (v, w). Conversely, a flow f in N uniquely determines the collection of circulations (f 1 , . . . , f k ) defined by (7) and
f i (si , v) = −excf (v), f i (si , v) = outf (v), f i (v, si ) = excf (v),
v ∈ V¯i ∩ V s , v ∈ V¯i ∩ V c , v ∈ V¯i ∩ V d .
Example. Let us consider the generalized flow network N depicted in Fig. 1. The triples inside the nodes and near the arcs represent: – (q(v); d− (v), d+ (v)), for a node v; – (c(v, w); l(v, w), u(v, w)), for a non-conversion arc (v, w); – (c(v, w); α(v, w)/β(v, w)), for a conversion arc (v, w), where γ(v, w) =
α(v,w) β(v,w) .
Suppose that the conversion arcs have lower capacity 0 and upper capacity 10.
2(s) (0;0,0)
(2;1/1) 3
4(c) (3;0,7)
(2;2/1) 6
7(d) (-3;0,3)
(1;0,6) 3
(2;0,5)
(3;0,6) 5
2
5(d)
1(d) 1 (3;1,6)
(-3;1,3)
9(s) (2;0,4) 1
(-9;4,8)
(2;3,6)
3 0
(1;0,4) 4
(1;0,7)
3(s) (0;8,8)
(2;1/1) 4
6(c)
(3;2/1)
8(s)
(2;0,6)
8
(0;9,9)
(1;0,6)
Fig. 1. Network N
The decomposition of N into 3 subnetworks is presented in Fig. 2. The flow in network N , represented by the italic numbers in Fig. 1, corresponds to the circulations depicted in Fig. 2. 3.2
Propagation
In the previous section we have shown that, to find a flow f in a generalized flow network N , we can decompose N into smaller subnetworks N1 , . . . , Nk and then look for a collection of circulations (f 1 , . . . , f k ) obeying the linear constraints (6). It remains to discuss propagation on these subnetworks. This is based on classical network algorithms. Due to lack of space, we can describe here only the main ideas. For i = 1, . . . , k, we verify whether there exists a circulation in every network Ni ; if, for some i, the answer is negative, then there is no flow in N and we are done. Otherwise, for each network Ni , we apply two propagation subroutines to reduce the feasible intervals [l(v, w), u(v, w)] for the flow variables f (v, w). These subroutines are called recursively and in cooperation with a propagation procedure for the linear constraints (6) and (8).
(2;0,10) (2,4)
2
4
3
0
(-3;0,3) 2
(1;0,6) 3
1
3
(3;0,7)
5
1
(-3;1,3) 1
(3;1,6)
1
5
(-9;4,8) 7
11
4
(2;0,6)
0
3
4
(2;3,6) 12 5
9 (0;9,9)
(3,6) (2;0,10)
6
(1;0,6) (1;0,4) 4
8
9
(2;0,4)
(1;0,7) (0;8,8)
0
(3;0,6)
(2;0,5) 10
(2;0,10) (7,4)
7
(0;0,0)
3
6
8
8 (8,6) (3;0,10)
Fig. 2. Decomposition of network N
Suppose that we are given a circulation network, i.e. a flow network of the form CN = (V, E; l, u, c), without γ, d+ , d− , q. By Hoffman’s theorem [10], there is a circulation in CN iff X X l(v, w) ≤ u(v, w), for all X ⊂ V. (9) (v,w)∈E(X,V \X)
(v,w)∈E(V \X,X)
By a single maximum flow computation (see [2]), we can find either a circulation in CN or a subset X for which inequality (9) is most violated. Our first propagation subroutine is based only on feasibility reasoning. For an arc (v, w) ∈ E, let α(v, w) (resp. β(v, w) ) denote the maximum flow value from v to w (resp. from w to v) in the network (V, E \{(v, w)}; l, u). The recursive step of our first propagation subroutine calculates (or only estimates) for (v, w) ∈ E the values α(v, w), β(v, w), and then replaces l(v, w) by max{l(v, w), −α(v, w)}, and u(v, w) by min{u(v, w), β(v, w)}. Our second subroutine is based on optimality reasoning. Let B be an upper bound on the cost of a minimal circulation. The subroutine first computes an optimal circulation f and an optimal price function p : V → R, i.e., such that the complementary slackness condition holds cp (v, w) < 0 ⇒ f (v, w) = u(v, w), cp (v, w) > 0 ⇒ f (v, w) = l(v, w),
(10)
def
where cp (v, w) = p(v) + c(v, w) − p(w) denotes the reduced cost of an arc (v, w) with respect to a price function p (see again [2]). Then it changes the lower and upper capacities according to the rule: – if cp (v, w) < 0 and ² =
c(f ) − B < u(v, w) − l(v, w), then set l(v, w) = cp (v, w)
u(v, w) − ²; – if cp (v, w) > 0 and δ = l(v, w) + δ.
B − c(f ) < u(v, w) − l(v, w), then set u(v, w) = cp (v, w)
4
Some applications
We present in this section a number of applications of the flow constraint. The list of examples given here is by no way exhaustive. We can illustrate here only some basic features of the flow constraint. More advanced applications would include, e.g., cyclic time tabling, multicommodity flows, network design, and flow problems with various side constraints, like the equal flow problem [3]. 4.1
Maximum flow
It is quite natural that the flow constraint can be used for solving most of the classical network problems. Here, we demonstrate this for the maximum flow problem. Consider a network (V, E; u, l, s, t), with n = |V | nodes and m = |E| arcs. l, u : E → R are lower and upper capacity functions, s ∈ V is a source, and t ∈ V is a sink. The maximum flow problem consists in finding a flow f in G such that excf (v) = 0 for all v ∈ V \ {s, t} and excf (t) = −excf (s), the value of the flow f , is maximal. As an example let us consider the instance of the maximum flow problem represented in Fig. 3. Here, the numbers in the parentheses are the arc capacities, the other numbers represent a maximum flow of value 15. This flow is obtained by the following simple solution strategy (see also Fig. 4): – set up the list representation of the network; – post one flow constraint and do propagation; – fix the value of Demand[source] to its upper bound (this starts propagation again); – in turn, fix each flow variable to any value from its current domain (followed each time by propagation).
(1,5) 1
(2,8) 7
(2,4) 4 (1,6)
(1,4)
3 (0,5)
(1,5)
(1,5) 5
2
(0,3) 3
0
4
1
5
1
5
3 (0,8) 8
3
1
(0,3)
2
(1,3) 3 (2,5)
5 (2,5)
(1,3) 1
6
Fig. 3. : Maximum flow: network
4 (0,9)
7
n = 8; m = 16; s = 0; t = 7; NodeType = [supply,supply,supply,supply,supply,supply,demand]; Edge = [[0,1],[0,2],[0,3],[1,2],[1,3],[1,4],[2,3],[2,5],[2,6], [3,4],[3,5],[4,5],[4,7],[5,7],[6,5],[6,7]]; LoCap = [2,1,0,1,2,1,0,0,2,1,1,2,1,0,1,0]; UpCap = [8,5,3,6,4,5,5,3,5,5,4,5,3,8,3,9]; Demand[v] = 0, v 6= s, t; Demand[s] ∈ [0,16]; Demand[t] ∈ [0,16]; Flow[e] ∈ [LoCap[e], UpCap[e]], e = 0, . . . , m − 1; flow(NodeType,Edge,[],[],[],Demand,Flow,0). Demand[s] ← max val in domain(Demand[s]); for (e = 0, . . . , m − 1) Flow[e] ← min val in domain(Flow[e]); Fig. 4. Maximum flow: model and solution procedure
4.2
Production planning
Suppose there are two types of manufacturing facilities F1 , F2 for producing a discrete product P . In both facilities, two raw materials R1 and R2 are used. Up to 400 units of R1 and up to 700 units of R2 are available. One unit of R1 costs 5$, and one unit of R2 costs 7$. Because of different technologies, the quantities of the raw materials used for producing one unit of product P are different in F1 and F2 , see the following Tab. 1. R1 R2 P1 1 2 P2 1 3/2
S1 S2 S3 P1 1 1 2 P2 2 1 1
Table 1. : Production planning: data
The production cost of one unit of product P is 12$ in facility F1 , and 10$ in facility F2 . The maximum capacities of facilities F1 and F2 are, respectively, 200 and 250 units of the product. Furthermore, at least 100 resp. 150 units of the product must be produced in the facilities F1 resp. F2 . The demands for product P at the customer sites, S1 , S2 , and S3 , are 160, 70, 140 units respectively. The unit transportation costs for shipping units of products from facilities to customers can also be found in Tab. 1. The problem is to determine the production rates and the shipping patterns to meet all the demands at a minimum cost. We formulate this problem as a generalized flow problem in the network given in Fig. 5. Nodes 0 and 1, respectively, represent the raw materials R1 and R2 ; nodes 2 and 3 are production facilities for product P1 and P2 respectively; nodes 4,5, and 6 are customers nodes that represent the sites S1 , S2 , and S3 . The numbers in parentheses at the nodes are the lower and upper demands. The
numbers inside the circles are the costs, and the numbers inside the rectangles are the conversion factors. We define the upper capacity of an arc as the upper demand of its head node. All lower capacities are zero.
(0,700)
(0,400) 5
0
1
7 3/2
3 2
1
1
(100,200)
10
12
2
(160,160)
1
1
1
4
(150,250)
3
2
2 1
2
4
2
5 (70,70)
6 (140,140)
Fig. 5. Production planning: network
A complete model for this problem is given in Fig. 6. Labeling the demand variables and fixing the flow variables yields, after running the corresponding C implementation, an optimal flow f (0, 2) = 120, f (0, 3) = 250, f (1, 2) = 240, f (1, 3) = 375, f (2, 4) = 120, f (2, 5) = f (2, 6) = 0, f (3, 4) = 40, f (3, 5) = 70, f (3, 6) = 140, whose cost is 13095. 4.3
Personnel scheduling
The telephone service of an airline operates around the clock. Tab. 2 indicates for 6 time periods of 4 hours the number of operators needed to answer the incoming calls.
Period 0 1 2 3 4 5
Time of day Min. operator needed 3 a.m. to 7 a.m. 26 7 a.m. to 11 a.m. 52 11 a.m. to 3 p.m. 86 3 p.m. to 7 p.m. 120 7 p.m. to 11 p.m. 75 11 p.m. to 3 a.m. 35
Table 2. Personnel scheduling: data
n = 7; m = 10; NodeType = [supply,supply,conv,conv,demand,demand,demand]; Edge = [[0,2],[0,3],[1,2],[1,3],[2,4],[2,5],[2,6],[3,4],[3,5],[3,6]]; Conv = [1,1,2,3/2,-,-,-,-,-,-]; EdgeCost = [3,4,2,2,1,1,2,2,1,1]; NodeCost = [5,7,12,10,0,0,0]; LoDem = [0,0,100,150,160,70,140]; UpDem = [400,700,200,250,160,70,140]; UpCap = [200,250,200,250,160,70,140,160,70,140]; Demand[v] ∈ [LoDem[v],UpDem[v]], v = 0, . . . , n − 1; FlowCost ∈ [0,100000]; Flow[e] ∈ [0, UpCap[e]], e = 0, . . . , m − 1; flow(NodeType,Edge,Conv,EdgeCost,NodeCost,Demand,Flow,FlowVal). if (labeling(Demand)) { FlowVal = min val in domain(FlowVal); for (e = 0, . . . , m − 1) Flow[e] ← min val in domain(Flow[e]); } Fig. 6. Production planning: model and solution procedure
We assume that operators work for a consecutive periods of 8 hours. They can start to work at the beginning of any of the 6 periods. Let xt denote the number of operators starting to work at the beginning of period t, t = 0, . . . , 5. We need to find the optimum values for xt to meet the requirements in all the periods, by employing the least number of operators. Any feasible schedule x = (x0 , x1 , x2 , x3 , x4 , x5 ) that meets the requirements on the operators in the different time periods can be represented by a circulation f in the network depicted in Fig. 7.
0
0
46(26)
52(52)
1 11
35
2
86(86)
41
3
45
120(120)
4
75(75)
5
75
35(35)
Fig. 7. Personnel scheduling: network
In this network, every node t corresponds to the beginning of period t, t = 0, . . . , 5. There are two types of arcs: working arcs (t, t+1 (mod 6)) and free arcs (t, t + 4 mod 6). A flow f (t, t + 1 mod 6) = xt + x(t+5) mod 6 along a working arc (t, t+1 mod 6) corresponds to the number of operators scheduled to work during period t; therefore, the lower capacity of this arc (number given in parentheses)
is defined to be the number of operators needed during that period. A flow f (t, (t + 4) mod 6) = x(t+4) mod 6 along a free arc (t, (t + 4) mod 6) corresponds to the number of operators having free time during periods t, t + 1, t + 2, t + 3; its lower capacity is zero. It can be easily checked that we can set the upper capacity of each arc to 120 (the maximal number of operators needed for one period). The circulation represented by the numbers on the arcs in Fig. 7 yields a feasible schedule x = (11, 41, 45, 75, 0, 35). In fact, this is even an optimal schedule. However, an arbitrary circulation does not always determine a feasible schedule. In general, it may violate the requirement that each operator works for a consecutive period of 8 hours. In other words, this means that the number of operators working during some period must be equal to the number of operators starting to work at the beginning of this period plus the number of operators finishing their work at the end of this period. To meet this condition, a schedule-circulation f must comply for t = 0, . . . , 5 with the side constraints f (t, (t + 1) mod 6) = f ((t − 4) mod 6, t) + f ((t + 1) mod 6, (t + 5) mod 6). (11) We define arc costs c(t, (t + 1) mod 6) = 1 and c(t, t + 4 mod 6) = 0, for t = 0, . . . , 5. Since each operator works during two consecutive periods, the cost c(f ) of a circulation f is equal to twice the number of operators employed. If f is an optimal schedule-circulation, then the optimal values for xt are defined by xt = f ((t − 4) mod 6, t), for t = 0, . . . , 5. The solution algorithm is very simple and given in Fig. 8. For Flow to be a circulation, we post one flow constraint. Since, for a circulation, the demand at any node is zero, we can set NodeType[v]=supply for every node v. To satisfy equations (11), we post n linear constraints. Finally, we solve the problem using the min max procedure which labels variables Flow in order to minimize variable FlowVal. n = 6; m = 10; OpNeeded = [26,52,86,120,75,35]; UpCap = max0≤i