this repo has no description
1% RUNS ON mzn20_fd
2% RUNS ON mzn-fzn_fd
3% RUNS ON mzn20_fd_linear
4% RUNS ON mzn20_mip
5
6% Regression test for bug #259: mzn2fzn (and consequently solns2out) didn't support
7% array5d casts.
8
9%----------------------------------------------------------------------------%
10
11
12% Copyright (c) 2011 HighTechKids. All rights reserved
13% HighTechKids is on the web at: http://www.hightechkids.org
14% This code is released under GPL; see LICENSE.txt for details.
15
16include "globals.mzn";
17
18% run with 'minizinc -G linear -b mip' - doesn't work because of 5d arrays
19% mzn2fzn --no-output-ozn --globals-dir linear schedule.mzn <param file>.dzn && flatzinc -b mip -o schedule.result schedule.fzn
20
21% parameters
22int: TInc;
23int: TMax_hours;
24
25% subjective setup
26int: NSubjective;
27
28% performance setup
29int: NRounds;
30int: NTables;
31
32% judging groups
33int: NGroups;
34
35int: alpha_perf_minutes;
36
37int: ct_minutes;
38int: pct_minutes;
39
40
41
42%%%% Don't edit below here %%%%
43int: M = 10000;
44
45% computed parameters
46
47array [1..NSubjective] of int : subj_minutes;
48array [1..NGroups] of int : group_counts;
49
50array [1..NSubjective] of int : alpha_subj = [ x div TInc | x in subj_minutes ];
51
52int: NTeams = sum(group_counts);
53constraint assert(NTeams mod 2 == 0, "Number of teams must be even");
54
55int: TMax = TMax_hours * 60 div TInc;
56int: alpha_perf = alpha_perf_minutes div TInc;
57int: ct = ct_minutes div TInc;
58int: pct = pct_minutes div TInc;
59
60
61int: MaxTeamsInGroup = max(group_counts);
62
63
64% variables
65array [1..NGroups, 1..MaxTeamsInGroup, 1..NSubjective, 1..TMax ] of var
660..1 : sz;
67array [1..NGroups, 1..MaxTeamsInGroup, 1..NSubjective, 1..TMax ] of var
680..1 : sy;
69array [1..NGroups, 1..MaxTeamsInGroup, 1..NTables, 1..2, 1..TMax ] of var
700..1 : pz;
71array [1..NGroups, 1..MaxTeamsInGroup, 1..NTables, 1..2, 1..TMax ] of var
720..1 : py;
73var int: objective;
74
75% stationBusySubjective
76constraint
77 forall(g in 1..NGroups) (
78 forall (i in 1..group_counts[g]) (
79 forall (n in 1..NSubjective) (
80 forall (t in 1..TMax) (
81 sum (u in 1..alpha_subj[n]) (
82 if(t-u+1 >= 1) then
83 sz[g,i,n,t-u+1]
84 else
85 0
86 endif
87 ) <= sy[g,i,n,t]
88))));
89
90% stationBusyPerformance
91constraint
92 forall(g in 1..NGroups) (
93 forall(i in 1..group_counts[g]) (
94 forall(b in 1..NTables) (
95 forall(s in 1..2) (
96 forall(t in alpha_perf..TMax) (
97 sum(u in 1..alpha_perf) (
98 if(t-u+1 >= 1) then
99 pz[g,i,b,s,t-u+1]
100 else
101 0
102 endif
103 ) <= py[g,i,b,s,t]
104)))));
105
106% stationStartSubjective
107constraint
108 forall(g in 1..NGroups) (
109 forall (i in 1..group_counts[g]) (
110 forall (n in 1..NSubjective) (
111 forall (t in 2..TMax) (
112 sy[g,i,n,t] - sy[g,i,n,t-1] <= sz[g,i,n,t]
113))));
114
115% stationStartPerformance
116constraint
117 forall(g in 1..NGroups) (
118 forall (i in 1..group_counts[g]) (
119 forall(b in 1..NTables) (
120 forall(s in 1..2) (
121 forall(t in 2..TMax) (
122 py[g,i,b,s,t] - py[g,i,b,s,t-1] <= pz[g,i,b,s,t]
123)))));
124
125% noOverlapSubjective
126constraint
127 forall(g in 1..NGroups) (
128 forall (t in 1..TMax) (
129 forall (n in 1..NSubjective) (
130 sum(i in 1..group_counts[g]) (sy[g,i,n,t]) <= 1
131)));
132
133% noOverlapPerformance
134constraint
135 forall (t in 1..TMax) (
136 forall (b in 1..NTables) (
137 forall (s in 1..2) (
138 sum(g in 1..NGroups) (sum(i in 1..group_counts[g]) (py[g,i,b,s,t])) <= 1
139)));
140
141% teamSubjective
142constraint
143forall(g in 1..NGroups) (
144 forall (i in 1..group_counts[g]) (
145 forall (n in 1..NSubjective) (
146 sum (t in 1..TMax) (sz[g,i,n,t]) = 1
147)));
148
149% teamPerformance
150constraint
151forall(g in 1..NGroups) (
152 forall (i in 1..group_counts[g]) (
153 sum (b in 1..NTables) (
154 sum (t in 1..TMax) (pz[g,i,b,1,t] + pz[g,i,b,2,t])
155 ) = 1
156));
157
158% subjectiveEOS
159constraint
160sum(g in 1..NGroups) (
161 sum (i in 1..group_counts[g]) (
162 sum (n in 1..NSubjective) (
163 sum (t in TMax-alpha_subj[n]+1..TMax) (
164 sz[g,i,n,t]
165)))) = 0;
166
167% performanceEOS
168constraint
169sum(g in 1..NGroups) (
170 sum (i in 1..group_counts[g]) (
171 sum (b in 1..NTables) (
172 sum (t in TMax-alpha_perf+1..TMax) (
173 pz[g,i,b,1,t] + pz[g,i,b,2,t]
174)))) = 0;
175
176int: subj_ulimit = ct-1;
177int: subj_tlimit = TMax-subj_ulimit;
178
179% subjSubjChangetime
180constraint
181forall(g in 1..NGroups) (
182 forall(i in 1..group_counts[g]) (
183 forall(n in 1..NSubjective) (
184 forall(t in 1..subj_tlimit) (
185 forall(d in 1..NSubjective) (
186 forall(u in 0..subj_ulimit) (
187 if(d != n) then
188 sy[g,i,n,t] + sy[g,i,d,t+u] <= 1
189 else
190 true
191 endif
192))))));
193
194% subjPerfChangetime
195constraint
196forall(g in 1..NGroups) (
197 forall(i in 1..group_counts[g]) (
198 forall(n in 1..NSubjective) (
199 forall(t in 1..subj_tlimit) (
200 forall(u in 0..subj_ulimit) (
201 forall(b in 1..NTables) (
202 forall(s in 1..2) (
203 sy[g,i,n,t] + py[g,i,b,s,t+u] <= 1
204)))))));
205
206int: perf_ulimit = ct-1;
207int: perf_tlimit = TMax-perf_ulimit;
208
209% perfPerfChangetime
210constraint
211forall(g in 1..NGroups) (
212 forall(i in 1..group_counts[g]) (
213 forall(b in 1..NTables) (
214 forall(s in 1..2) (
215 forall(t in 1..perf_tlimit) (
216 forall(u in 0..perf_ulimit) (
217 forall(d in 1..NTables) (
218 forall(e in 1..2) (
219 if(b != d /\ s != e) then
220 py[g,i,b,s,t] + py[g,i,d,e,t+u] <= 1
221 else
222 true
223 endif
224))))))));
225
226% perfSubjChangetime
227constraint
228forall(g in 1..NGroups) (
229 forall(i in 1..group_counts[g]) (
230 forall(b in 1..NTables) (
231 forall(s in 1..2) (
232 forall(t in 1..perf_tlimit) (
233 forall(u in 0..perf_ulimit) (
234 forall(n in 1..NSubjective) (
235 py[g,i,b,s,t] + sy[g,i, n, t+u] <= 1
236)))))));
237
238int: perf_pct_ulimit = pct-1;
239int: perf_pct_tlimit = TMax-perf_pct_ulimit;
240
241% performanceChangetime
242constraint
243forall(g in 1..NGroups) (
244 forall(i in 1..group_counts[g]) (
245 forall(t in 1..perf_pct_tlimit) (
246 forall(u in 1..perf_pct_ulimit) (
247 sum(b in 1..NTables) (
248 py[g,i,b,1,t] + py[g,i,b,2,t] + py[g,i,b,1,t+u] + py[g,i,b,2,t+u]
249 ) <= 1
250))));
251
252% perfUseBothSides
253constraint
254 forall(b in 1..NTables) (
255 forall(t in 1..TMax) (
256 sum(g in 1..NGroups) (sum(i in 1..group_counts[g]) (py[g,i,b,1,t]))
257 = sum(g in 1..NGroups) (sum(i in 1..group_counts[g]) (py[g,i,b,2,t]))
258));
259
260% teamJudging
261constraint
262forall(g in 1..NGroups) (
263 forall(i in 1..group_counts[g]) (
264 sum(t in 1..TMax) (
265 sum(n in 1..NSubjective) (
266 sz[g,i,n,t] +
267 sum(b in 1..NTables) (
268 pz[g,i,b,1,t] + pz[g,i,b,2,t]
269 ))) = NSubjective + NRounds
270));
271
272
273% performanceStart
274int: perfStartWait = 60 div TInc;
275constraint
276sum(g in 1..NGroups) (
277 sum(i in 1..group_counts[g]) (
278 sum(b in 1..NTables) (
279 sum(t in 1..perfStartWait) (
280 pz[g,i,b,1,t] + pz[g,i,b,2,t]
281)))) = 0;
282
283% objective
284constraint
285sum(t in 1..TMax) (
286 sum(g in 1..NGroups) (
287 sum(i in 1..group_counts[g]) (
288 sum(n in 1..NSubjective) (
289 sy[g,i,n,t] * t
290 ) +
291 sum(b in 1..NTables) (
292 (py[g,i,b,1,t] + py[g,i,b,2,t]) * t
293 )
294))) = objective;
295
296
297solve minimize objective;
298
299output
300[ if fix(sz[g,i,n,t]) == 1 then
301 "sz[" ++ show(g) ++ "][" ++ show(i) ++ "][" ++ show(n) ++ "][" ++ show(t) ++ "] = " ++
302 show(sz[g, i, n, t]) ++ "\n"
303 else
304 ""
305 endif
306 | g in 1..NGroups, i in 1..group_counts[g], n in 1..NSubjective, t in 1..TMax
307 ]
308++ [
309 if fix(pz[g,i,b,s,t]) == 1 then
310 "pz[" ++ show(g) ++ "][" ++ show(i) ++ "][" ++ show(b) ++ "][" ++ show(s) ++ "][" ++ show(t) ++ "] = "
311 ++ show(pz[g, i, b, s, t]) ++ "\n"
312 else
313 ""
314 endif
315 | g in 1..NGroups, i in 1..group_counts[g], b in 1..NTables, s in 1..2, t in 1..TMax
316 ]
317++ ["\n"];
318
319% Instance data
320
321TInc = 5;
322TMax_hours = 8;
323
324% subjective setup
325NSubjective = 1;
326subj_minutes = [20];
327
328% performance setup
329NRounds = 1;
330NTables = 1;
331
332% judging groups
333NGroups = 1;
334group_counts = [2];
335
336alpha_perf_minutes = 5;
337
338ct_minutes = 15;
339pct_minutes = 45;