The "binary" in your param definition suggests that out of the cross-product of 
classes and students, you only really want a subset of them.

It might be better, and easier, to have a two-dimensional set.  Page 47 of the 
GMPL manual shows how to do the data section using "+" and "-" to represent 
membership in the set, and it looks very much like your table below.  
Paraphasing the example, this shows the set A having (1,2), (2,2), (2,3):


set A : 1 2 3 4 :=

1 - + - -

2 - + + -

3 + - - +

4 - + - + ;


________________________________
From: [email protected] 
[[email protected]] On Behalf Of Timothy 
Calderwood [[email protected]]
Sent: Monday, December 02, 2013 2:09 PM
To: [email protected]
Subject: [Help-glpk] Generate Set from Param data

I have a list of students defined as a set. I have also a param defined for 
historical information that contains the set of students. As seen below...

set Students;
param HistoricalInfo {c in Classes, s in Students}, binary;

Our project might have any number of students, from 50 to over a 1000. I rather 
not have to list the students twice, once in the set of students, a second time 
in param Historical Info.

set Students := David, Jerry, Fannie, Student4, Student5, Student6, Student7, 
Student8;
param HistoricalInfo (tr):
                 English     Math    Science        SocialStudies    Elective :=
Jerry          1            0        0            0                0
David         1            0        1            0                0
Fannie       0            1        0            1                0
Student4    1            1        0            1                0
Student5    0            1        0            1                0
Student6    0            1        1            0                1
Student7    1            1        0            0                1
Student8    0            0        0            0                1;

My question is, is there a way to define set Students from the param data so 
the students only need to be listed once?

Thanks for you time and help...

________________________________
This e-mail and any attachments may be confidential or legally privileged. If 
you received this message in error or are not the intended recipient, you 
should destroy the e-mail message and any attachments or copies, and you are 
prohibited from retaining, distributing, disclosing or using any information 
contained herein. Please inform us of the erroneous delivery by return e-mail. 
Thank you for your cooperation.
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to