What does this array initialisation mean? CPLEX

情到浓时终转凉″ 提交于 2019-12-11 15:22:33

问题


I am very new to CPLEX and am trying to understand a friends example so i may produce a model myself, however I am confused as to how one of the decision variables has been created. The notation is unfamiliar to me and also the fact that they are using a set of tuples as well as ranges in it's definition. Any help explaining what is going on and what the line of code does would be greatly appreciated.

tuple bus{int busnumber; float capacity; string start_location; string stop_location; int maxleg;};

{bus} busfleet=...; 

int maxroute=...;

range route = 1..maxroute;
range route0 = 1..maxroute-1;

tuple job {string start_location; string stop_location; int runafter; int runbefore; int runstop; float demand;};

{job} jobs=...;
{job} initialjobs=...;
{job} jobs1=...;
{job} alljobs = initialjobs union jobs union jobs1;

//variable
dvar boolean scheduleofbus[busfleet, route, alljobs, alljobs];

My confusion concerns the final line, where "scheduleofbus" is defined. What does this initialization of the array do? If possible could you also help define it's dimensions, what selecting an element of it would do etc. Any help would be greatly appreciated. Many thanks in advance. =)


回答1:


The line

dvar boolean scheduleofbus[busfleet, route, alljobs, alljobs];

could equivalently be written as

dvar boolean scheduleofbus[busfleet][route][alljobs][alljobs];

which may be a bit more obvious. It defines a 4-dimensional boolean decision variable. The index set for this variable is the cartesian product of the elements in busfleet, route, alljobs and alljobs (yes, alljobs appears twice).

In other words, you have a variable for each combination of bus, route and pair of jobs.



来源:https://stackoverflow.com/questions/57543376/what-does-this-array-initialisation-mean-cplex

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