4

我希望这对某人来说是显而易见的。我只使用了 GLPK/MathProg。我无法弄清楚 GNU MathProg(在 GLPK 中)执行以下操作的语法,例如:

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);

问题是这被 MathProg 拒绝了。

一般来说,我只想能够: - 声明一个分区(这里是 PartsOfWeek)和一个集合(这里是 Weekdays) - 从数据构建分区 - 用分区中集合的元素填充集合。

一个更好的例子可能是季节和月份。

4

1 回答 1

8

借助@ALi 的文献参考帮助:

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;
于 2012-04-26T21:02:58.233 回答