this repo has no description
at develop 1.9 kB view raw
1include "fzn_network_flow.mzn"; 2include "fzn_network_flow_reif.mzn"; 3include "fzn_network_flow_cost.mzn"; 4include "fzn_network_flow_cost_reif.mzn"; 5 6/** @group globals 7 Defines a network flow constraint. 8 9@param arc: a directed arc of the flow network. Arc \p i connects node \a arc[\p i,1] to node \a arc[\p i,2]. 10@param balance: the difference between input and output flow for each node. 11@param flow: the flow going through each arc. 12*/ 13 14predicate network_flow(array[int,1..2] of int: arc, 15 array[int] of int: balance, 16 array[int] of var int: flow) = 17 18 let { 19 set of int: ARCS = index_set_1of2(arc); 20 set of int: NODES = index_set(balance); 21 } in 22 assert ( 23 ARCS == index_set(flow) /\ 24 lb_array(arc) >= min(NODES) /\ 25 ub_array(arc) <= max(NODES), 26 "network_flow: wrong sizes of input array parameters", 27 fzn_network_flow(arc, balance, flow) 28 ); 29 30/** @group globals 31 Defines a network flow constraint with cost. 32 33@param arc: a directed arc of the flow network. Arc \p i connects node \a arc[\p i,1] to node \a arc[\p i,2]. 34@param balance: the difference between input and output flow for each node. 35@param weight: the unit cost of the flow through the arc. 36@param flow: the flow going through each arc. 37@param cost: the overall cost of the flow. 38*/ 39predicate network_flow_cost(array[int,1..2] of int: arc, 40 array[int] of int: balance, 41 array[int] of int: weight, 42 array[int] of var int: flow, var int: cost) = 43 44 let { 45 set of int: ARCS = index_set_1of2(arc); 46 set of int: NODES = index_set(balance); 47 } in 48 assert ( 49 ARCS == index_set(flow) /\ 50 ARCS == index_set(weight) /\ 51 lb_array(arc) >= min(NODES) /\ 52 ub_array(arc) <= max(NODES), 53 "network_flow: wrong sizes of input array parameters", 54 fzn_network_flow_cost(arc, balance, weight, flow, cost) 55 );