this repo has no description
at develop 2.4 kB view raw
1%-----------------------------------------------------------------------------% 2% Radiation problem, MiniZinc 2.0.4 version 3% 4%-----------------------------------------------------------------------------% 5 6%-----------------------------------------------------------------------------% 7% Parameters 8%-----------------------------------------------------------------------------% 9 10int: m; % Rows 11int: n; % Columns 12 13set of int: Rows = 1..m; 14set of int: Columns = 1..n; 15 16 % Intensity matrix 17array[Rows, Columns] of int: Intensity; 18 19 20set of int: BTimes = 1..Bt_max; 21 22int: Bt_max = max(i in Rows, j in Columns) (Intensity[i,j]); 23int: Ints_sum = sum(i in Rows, j in Columns) (Intensity[i,j]); 24 25%-----------------------------------------------------------------------------% 26% Variables 27%-----------------------------------------------------------------------------% 28 29 % Total beam-on time 30var 0..Ints_sum: Beamtime; 31 32 % Number of shape matrices 33var 0..m*n: K; 34 35 % N[b] is the number of shape matrices with associated beam-on time b 36array[BTimes] of var 0..m*n: N; 37 38 % Q[i,j,b] is the number of shape matrices with associated beam-on time 39 % b that expose cell (i,j) 40array[Rows, Columns, BTimes] of var 0..m*n: Q; 41 42%-----------------------------------------------------------------------------% 43% Constraints 44%-----------------------------------------------------------------------------% 45 46 % For FD/LP hybrid solving, all these should go the LP solver 47 % (with a suitable linearisation of the 'max' expressions). 48constraint 49 Beamtime = sum(b in BTimes) (b * N[b]) 50 /\ 51 K = sum(b in BTimes) (N[b]) 52 /\ 53 forall(i in Rows, j in Columns) 54 ( Intensity[i,j] = sum([b * Q[i,j,b] | b in BTimes]) ) 55 /\ 56 forall(i in Rows, b in BTimes) 57 ( upper_bound_on_increments(N[b], [Q[i,j,b] | j in Columns]) ); 58 59 60predicate upper_bound_on_increments(var int: N_b, array[int] of var int: L) = 61 N_b >= L[1] + sum([ max(L[j] - L[j-1], 0) | j in 2..n ]); 62 % 63 % Good linear version: 64 % let { array[min(index_set(L))..max(index_set(L))] of var int: S } in 65 % N_b >= L[1] + sum([ S[j] | j in 2..n ]) /\ 66 % forall([ S[j] >= L[j] - L[j-1] /\ S[j] >= 0 | j in 2..n ]); 67 68 69%-----------------------------------------------------------------------------% 70output [ 71 "Beamtime = \(Beamtime);\n", 72 "K = \(K);\n", 73 "N = \(N);\n", 74 "Q = array3d(\(Rows), \(Columns), \(BTimes), \(Q));\n" 75]; 76 77%-----------------------------------------------------------------------------%