this repo has no description
at develop 5.8 kB view raw
1/** @group globals.graph 2 Constrains the subgraph \a ns and \a es of a given directed graph to be a path from \a s to \a t of weight \a K. 3 4 \a N is the number of nodes in the given graph 5 \a E is the number of edges in the given graph 6 \a from is the leaving node 1..\a N for each edge 7 \a to is the entering node 1..\a N for each edge 8 \a w is the weight of each edge 9 \a s is the source node (which may be variable) 10 \a t is the dest node (which may be variable) 11 \a ns is a Boolean for each node whether it is in the subgraph 12 \a es is a Boolean for each edge whether it is in the subgraph 13 \a K is the cost of the path 14*/ 15predicate bounded_dpath(int: N, int: E, array[int] of int: from, array[int] of int: to, array[int] of int: w, 16 var int: s, var int: t, array[int] of var bool: ns, array[int] of var bool: es, var int: K) = 17 assert(index_set(from) = 1..E,"bounded_dpath: index set of from must be 1..\(E)") /\ 18 assert(index_set(to) = 1..E,"bounded_dpath: index set of to must be 1..\(E)") /\ 19 assert(index_set(ns) = 1..N,"bounded_dpath: index set of ns must be 1..\(N)") /\ 20 assert(index_set(es) = 1..E,"bounded_dpath: index set of es must be 1..\(E)") /\ 21 assert(index_set(w) = 1..E,"bounded_dpath: index set of w must be 1..\(E)") /\ 22 fzn_bounded_dpath(N,E,from,to,w,s,t,ns,es,K); 23 24/** @group globals.graph 25 Constrains the subgraph \a ns and \a es of a given directed graph to be a path from \a s to \a t of weight \a K. 26 27 \a from is the leaving node for each edge 28 \a to is the entering node for each edge 29 \a w is the weight of each edge 30 \a s is the source node (which may be variable) 31 \a t is the dest node (which may be variable) 32 \a ns is a Boolean for each node whether it is in the subgraph 33 \a es is a Boolean for each edge whether it is in the subgraph 34 \a K is the cost of the path 35*/ 36predicate bounded_dpath(array[int] of $$N: from, array[int] of $$N: to, array[int] of int: w, 37 var $$N: s, var $$N: t, array[$$N] of var bool: ns, array[int] of var bool: es, var int: K) = 38 assert(index_set(from) = index_set(to),"bounded_dpath: index set of from and to must be identical") /\ 39 assert(index_set(from) = index_set(es),"bounded_dpath: index set of from and es must be identical") /\ 40 assert(index_set(w) = index_set(es),"bounded_dpath: index set of w and es must be identical") /\ 41 assert(dom_array(from) subset index_set(ns),"bounded_dpath: nodes in from must be in index set of ns") /\ 42 assert(dom_array(from) subset index_set(ns),"bounded_dpath: nodes in to must be in index set of ns") /\ 43 fzn_bounded_dpath(from,to,w,s,t,ns,es,K); 44 45 46/** @group globals.graph 47 Constrains the subgraph \a ns and \a es of a given undirected graph to be a path from \a s to \a t of weight \a K. 48 49 \a N is the number of nodes in the given graph 50 \a E is the number of edges in the given graph 51 \a from is the leaving node 1..\a N for each edge 52 \a to is the entering node 1..\a N for each edge 53 \a w is the weight of each edge 54 \a s is the source node (which may be variable) 55 \a t is the dest node (which may be variable) 56 \a ns is a Boolean for each node whether it is in the subgraph 57 \a es is a Boolean for each edge whether it is in the subgraph 58 \a K is the cost of the path 59*/ 60predicate bounded_path(int: N, int: E, array[int] of int: from, array[int] of int: to, array[int] of int: w, 61 var int: s, var int: t, array[int] of var bool: ns, array[int] of var bool: es, var int: K) = 62 assert(index_set(from) = 1..E,"bounded_path: index set of from must be 1..\(E)") /\ 63 assert(index_set(to) = 1..E,"bounded_path: index set of to must be 1..\(E)") /\ 64 assert(index_set(ns) = 1..N,"bounded_path: index set of ns must be 1..\(N)") /\ 65 assert(index_set(es) = 1..E,"bounded_path: index set of es must be 1..\(E)") /\ 66 assert(index_set(w) = 1..E,"bounded_path: index set of w must be 1..\(E)") /\ 67 fzn_bounded_path(N,E,from,to,w,s,t,ns,es,K); 68 69 70/** @group globals.graph 71 Constrains the subgraph \a ns and \a es of a given undirected graph to be a path from \a s to \a t of weight \a K. 72 73 \a from is the leaving node for each edge 74 \a to is the entering node for each edge 75 \a w is the weight of each edge 76 \a s is the source node (which may be variable) 77 \a t is the dest node (which may be variable) 78 \a ns is a Boolean for each node whether it is in the subgraph 79 \a es is a Boolean for each edge whether it is in the subgraph 80 \a K is the cost of the path 81*/ 82predicate bounded_path(array[int] of $$N: from, array[int] of $$N: to, array[int] of int: w, 83 var $$N: s, var $$N: t, array[$$N] of var bool: ns, array[int] of var bool: es, var int: K) = 84 assert(index_set(from) = index_set(to),"bounded_path: index set of from and to must be identical") /\ 85 assert(index_set(from) = index_set(es),"bounded_path: index set of from and es must be identical") /\ 86 assert(index_set(w) = index_set(es),"bounded_path: index set of w and es must be identical") /\ 87 assert(dom_array(from) subset index_set(ns),"bounded_path: nodes in from must be in index set of ns") /\ 88 assert(dom_array(from) subset index_set(ns),"bounded_path: nodes in to must be in index set of ns") /\ 89 fzn_bounded_path(from,to,w,s,t,ns,es,K); 90 91include "fzn_bounded_path_int.mzn"; 92include "fzn_bounded_path_int_reif.mzn"; 93include "fzn_bounded_path_enum.mzn"; 94include "fzn_bounded_path_enum_reif.mzn"; 95include "fzn_bounded_dpath_int.mzn"; 96include "fzn_bounded_dpath_int_reif.mzn"; 97include "fzn_bounded_dpath_enum.mzn"; 98include "fzn_bounded_dpath_enum_reif.mzn"; 99 100%-----------------------------------------------------------------------------% 101%-----------------------------------------------------------------------------%