this repo has no description
1% RUNS ON mzn20_fd
2% RUNS ON mzn-fzn_fd
3% RUNS ON mzn20_mip
4%-----------------------------------------------------------------------------%
5% Radiation problem, Minizinc version
6%
7% Sebastian Brand
8% 05/2007
9%-----------------------------------------------------------------------------%
10
11%-----------------------------------------------------------------------------%
12% Instances
13%-----------------------------------------------------------------------------%
14
15m = 5; % Rows
16n = 5; % Columns
17
18Intensity = [| % g5c
19 7, 2, 14, 8, 9 |
20 13, 4, 1, 2, 9 |
21 5, 12, 2, 11, 9 |
22 10, 2, 4, 9, 7 |
23 10, 2, 8, 11, 1 |];
24
25%-----------------------------------------------------------------------------%
26% Parameters
27%-----------------------------------------------------------------------------%
28
29int: m; % Rows
30int: n; % Columns
31
32set of int: Rows = 1..m;
33set of int: Columns = 1..n;
34
35 % Intensity matrix
36array[Rows, Columns] of int: Intensity;
37
38
39set of int: BTimes = 1..Bt_max;
40
41int: Bt_max = max(i in Rows, j in Columns) (Intensity[i,j]);
42int: Ints_sum = sum(i in Rows, j in Columns) (Intensity[i,j]);
43
44%-----------------------------------------------------------------------------%
45% Variables
46%-----------------------------------------------------------------------------%
47
48 % Total beam-on time
49var 0..Ints_sum: Beamtime;
50
51 % Number of shape matrices
52var 0..m*n: K;
53
54 % N[b] is the number of shape matrices with associated beam-on time b
55array[BTimes] of var 0..m*n: N;
56
57 % Q[i,j,b] is the number of shape matrices with associated beam-on time
58 % b that expose cell (i,j)
59array[Rows, Columns, BTimes] of var 0..m*n: Q;
60%-----------------------------------------------------------------------------%
61% Constraints
62%-----------------------------------------------------------------------------%
63
64 % For FD/LP hybrid solving, all these should go the LP solver
65 % (with a suitable linearisation of the 'max' expressions).
66constraint
67 Beamtime = sum(b in BTimes) (b * N[b])
68 /\
69 K = sum(b in BTimes) (N[b])
70 /\
71 forall(i in Rows, j in Columns)
72 ( Intensity[i,j] = sum([b * Q[i,j,b] | b in BTimes]) )
73 /\
74 forall(i in Rows, b in BTimes)
75 ( upper_bound_on_increments(N[b], [Q[i,j,b] | j in Columns]) );
76
77
78predicate upper_bound_on_increments(var int: N_b, array[int] of var int: L) =
79 N_b >= L[1] + sum([ max(L[j] - L[j-1], 0) | j in 2..n ]);
80
81%-----------------------------------------------------------------------------%
82% Objective
83%-----------------------------------------------------------------------------%
84
85solve :: int_search(
86 [Beamtime] ++ N ++
87 [ Q[i,j,b] | i in Rows, j in Columns, b in BTimes ],
88 input_order, indomain_split, complete)
89 minimize (ub(K) + 1) * Beamtime + K;
90 % really: (Beamtime, K), i.e. in lexicographic order
91
92%-----------------------------------------------------------------------------%
93
94output ["radiation:\n",
95 "B / K = ", show(Beamtime), " / ", show(K), "\n",
96 % "N = ", show(N), "\n"
97];
98
99%-----------------------------------------------------------------------------%
100%-----------------------------------------------------------------------------%