GLPK MathProg集和组 [英] GLPK MathProg sets and groups
问题描述
我希望这对某人是显而易见的.我只有GLPK/MathProg的香草使用. 我在弄清楚GNU MathProg(在GLPK中)的语法有困难,例如:
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);
问题在于,这被MathProg拒绝了.
The problem is that this is rejected by MathProg.
通常,我只希望能够: -声明一个分区(在这里是PartsOfWeek)和一个集合(在这里是工作日) -从数据构建分区 -用分区中集合的元素填充集合.
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.
推荐答案
使用@ALi的文献参考帮助:
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;
这篇关于GLPK MathProg集和组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!