[Help-glpk] Set of sets

2008-12-09 Thread xypron

Hello Andrew,

sets of sets are not to be properly supported by GLPK:

The for statement does not support set of sets:
set M{1..2};
solve;
for {m in M}
  display m;
data;
set M[1] := 1 2;
set M[2] := A B C;

results in
M must be subscripted

Setof does not support set of sets:
set M := setof{ i in {1..3} } {1..i};

results in
integrand following setof{...} has invalid type

set M:= {{1..2}, {1..3}};
results in a set of tuples ( {1..2} cross {1..3} ). It should better return
a set of sets.

Same for
set M:= {({1..2}), ({1..3})};

Same for 
set A := {1..2};
set B := {1..3};
set M:= {A,B};

cf. http://lists.gnu.org/archive/html/help-glpk/2008-05/msg00043.html

Best regards

Xypron

-- 
View this message in context: 
http://www.nabble.com/Set-of-sets-tp20926306p20926306.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.



___
Help-glpk mailing list
Help-glpk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] Set of sets

2008-12-09 Thread xypron

Hello Andrew,

I would like to be able to create a set of sets from data read with the
table statement.

Can this be achieved with the current syntax?

Best regards

Xypron
-- 
View this message in context: 
http://www.nabble.com/Set-of-sets-tp20926306p20927045.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.



___
Help-glpk mailing list
Help-glpk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] Set of sets

2008-12-09 Thread Andrew Makhorin
 I would like to be able to create a set of sets from data read with the
 table statement.

 Can this be achieved with the current syntax?

Yes, though currently this cannot be performed efficiently for large
sets.

First you read data, say, in the following plain set:

set RAW, dimen 3;

and then build the set you need with the setof operator:

set S{i in ...} := setof{(i,j,k) in RAW} (j,k);

I suppose that in mathprog there should be a special operator to
convert a plain set to a set of sets in an efficient way. (I encountered
such problem on modeling very large sparse flow networks.) I will
continue this discussion in a new thread.



___
Help-glpk mailing list
Help-glpk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] set of sets

2008-05-28 Thread Andrew Makhorin
 I am writing a timetabling program in GMPL and I #39;d like to
 write some incompatibility constraints of courses generally, e.g. I
 want to say that no more than 1 of {A1, A2, A3} can appear in the same
 slot, and no more than 1 of {B1, B2} can appear in the same slot

 something like.. 

 set incompatitible := (A1, A2, A3) (B1, B2);

 min.

 s.t. no_incomp{s in SLOTS}: sum{s in SLOTS, i in incomp}
 allocation[slot, course in i] = 1; /* allocation is binary decision
 variable

 Question: 
 1. Can I even have a set of sets of different size? 
 2. How can I express the above? 

 I have read the manual for quite a while but I can #39;t seem to
 find something similar. I #39;d appreciate if you can point to the
 right direction.

You might declare a set (array) of sets as follows:

set incomp[1..N];

where incomp[1] is a first set of incompatible courses, incomp[2] is
a second set, etc., assuming the following initialization in the data
section:

set incomp[1] := A1 A2 A3;
set incomp[2] := B1 B2;
. . .




___
Help-glpk mailing list
Help-glpk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-glpk