GLPK MathProg sets and groups

∥☆過路亽.° 提交于 2019-12-12 12:08:29

问题


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.


回答1:


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;


来源:https://stackoverflow.com/questions/10323353/glpk-mathprog-sets-and-groups

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!