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