this repo has no description
at develop 1.2 kB view raw
1predicate fzn_cost_regular(array[int] of var int: x, int: Q, int: S, 2 array[int,int] of int: d, int: q0, set of int: F, 3 array[int,int] of int: c, var int: C) = 4 let { 5 % If x has index set m..n-1, then a[m] holds the initial state 6 % (q0), and a[i+1] holds the state we're in after processing 7 % x[i]. If a[n] is in F, then we succeed (ie. accept the string). 8 int: m = min(index_set(x)); 9 int: n = max(index_set(x)) + 1; 10 array[m..n] of var 1..Q: a; 11 % cc[i+1] holds the accumulated cost of edges taken process up to x[i] 12 array[m..n] of var int: cc; 13 } in 14 a[m] = q0 /\ % Set a[0]. 15 cc[m] = 0 /\ % initially zero cost 16 forall(i in index_set(x)) ( 17 x[i] in 1..S /\ % Do this in case it's a var. 18 a[i+1] = d[a[i], x[i]] /\ % Determine a[i+1]. 19 cc[i+1] = c[a[i],x[i]] + cc[i] % Calculate new cost sum 20 ) /\ 21 a[n] in F /\ % Check the final state is in F. 22 C = cc[n] % return final cost 23 ;