[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] set of sets
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] set of sets |
Date: |
Wed, 28 May 2008 12:22:54 +0400 |
> 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;
. . .