Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLPK MathProg sets and groups

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.

like image 698
tipanverella Avatar asked Feb 21 '23 17:02

tipanverella


1 Answers

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;
like image 116
tipanverella Avatar answered Apr 28 '23 05:04

tipanverella