CPLEX: dvar declaration with conditions

喜你入骨 提交于 2021-02-11 16:50:38

问题


I am using CPLEX and declaring the dvar with the following:

dvar int+ Y[i in a][j in a][m in b] in 0..1

I do not want to create a variable when i = j.


回答1:


variable indexer are not allowed but you have 3 workarounds:

https://github.com/AlexFleischerParis/zooopl/blob/master/zooarrayvariableindexertupleset.mod https://github.com/AlexFleischerParis/zooopl/blob/master/zooarrayvariableindexerdexpr.mod https://github.com/AlexFleischerParis/zooopl/blob/master/zooarrayvariableindexerunion.mod

The first one is the most used and for your case this gives:

{int} a={1,2};
{int} b={4,5};

tuple t
{
  int i;
  int j;
}

{t} ijs={<i,j> | i,j in a:i!=j};

//dvar int+ Y[i in a][j in a][m in b] in 0..1

dvar int+ Y[ij in ijs][m in b] in 0..1;

subject to
{
  Y[<1,2>][4]==1;
}


来源:https://stackoverflow.com/questions/65477497/cplex-dvar-declaration-with-conditions

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