Hello Kasper, The syntax for set data blocks is described in chapter 5.2 of glpk-4.47/doc/gmpl.pdf as set name [ symbol , . . . , symbol ] , record , . . . , record ;
set Sc[c1] := s1 s2 s3 s4; set Sc[c2] := s5 s6 s7 s8; Best regards Xypron -------- Original-Nachricht -------- > Datum: Fri, 21 Oct 2011 12:33:31 +0200 > Von: Kasper Tordrup <[email protected]> > An: Andrew Makhorin <[email protected]> > CC: glpk xypron <[email protected]>, Help Glpk <[email protected]> > Betreff: Re: [Help-glpk] Subset > Okey so I ran into another noob error. > I tried to edit the code to suit my problem, but when i try to print out > some info I get "Sc[C] out of domain" at the for loop: " for {ms in > MSizeSubs[c]} {" > Anyone know what I am doing wrong? > The new code looks like this: > > # The set of servers > set S; > > #The set of clusters > set C; > > #The set of servers in a cluster > set Sc{c in C}; > > # Number of servers in subset > param mc{c in C}; > > # Number of servers available in cluster > param cSize{c in C} := card(Sc[c]); > > # Set of subset sizes less or equal mc > set I{c in C} := {1 .. mc[c]}; > > # Set of indices for a subset of size i of set Sc > set J{c in C, i in I[c]} := { 1 .. round((prod{a in {1..cSize[c]}}a) / > (prod{a in {1..i}}a) / (prod{a in {1..cSize[c]-i}}a)) }; > > # Set of indices for S > set K{c in C} := {1 .. cSize[c]}; > > # Set containing the kth member of S > set L{c in C, k in K[c]} := setof{s in Sc[c] : k == sum{t in Sc[c] : t <= > s} > 1} s; > > # Set of integers in [i, n] > set MRange{c in C, i in I[c]} := {i .. cSize[c]}; > > # Number of subsets of size i of a set of size j - 1 > param ji{c in C, i in I[c], j in MRange[c,i]} := if i==j then 0 > else round((prod{a in {1..j-1}}a) / > (prod{a in {1..i}}a) / (prod{a in {1..j-1-i}}a)) ; > > # Subsets j of size i > set N{c in C, i in I[c], j in J[c,i]} := > if i == 1 then L[c,j] > else N[c,i-1,j - ji[c,i,max{k in MRange[c,i] : ji[c,i,k] < j} k]] > union L[c,max{k in MRange[c,i] : ji[c,i,k] < j} k]; > > # Set of subsets of size m > set MSizeSubs{c in C} := J[c,mc[c]]; > > # Servers in subset c > set Subsets{c in C, ms in MSizeSubs[c]} := N[c, mc[c], ms]; > > solve; > > for {c in C}{ > for {ms in MSizeSubs[c]} { > > } > } > > data; > > set S := s1 s2 s3 s4 s5 s6 s7 s8; > > set C := c1 c2; > > set Sc[C] := c1 s1 s2 s3 s4 > c2 s5 s6 s7 s8; > > param mc := c1 4 > c2 4; > > end; -- Follow me at http://twitter.com/#!/xypron NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone _______________________________________________ Help-glpk mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-glpk
