4

I hope this is obvious to someone. I have only had a vanilla use of GLPK/MathProg. I am having trouble figuring out the syntax in GNU MathProg (within GLPK) to do the following, for example:

set PartsOfWeek;
set WeekDays;

data;
set PartsOfWeek := WorkWeek WeekEnd;

set WorkWeek := Mon Tue Wed Thu Fri;
set WeekEnd := Sat Sun;

set WeekDays := setof{d in (WorkWeek union WeekEnd)}(d);

The problem is that this is rejected by MathProg.

In general, I just want to be able to: - declare a Partition (here PartsOfWeek) and a set (here Weekdays) - build the partition from data - populate the set with the elements of the of the sets from the partition.

A better example might be with seasons and months.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
tipanverella
  • 3,477
  • 3
  • 25
  • 41
  • 1
    MathProg is a subset of AMPL. This [tutorial](http://pino.univalle.edu.co/~juanp77/MAESTRIA%20BARANQUILLA/SOFTWARE%20OPTIMIZACI%D3N/AMPL%20WIM/amplmod.pdf) can help you. – Ali Apr 25 '12 at 21:40

1 Answers1

8

with @ALi's literature reference help:

set seasons;
set months;
set monthsOfseason {seasons} within months;

data;
set seasons := winter spring summer fall;
set months := jan feb mar apr may jun jul aug sep oct nov dec;
set monthsOfseason[winter] := dec jan feb;
set monthsOfseason[spring] := mar apr may;
set monthsOfseason[summer] := jun jul aug;
set monthsOfseason[fall]   := sep oct nov;
tipanverella
  • 3,477
  • 3
  • 25
  • 41