[英]how can I write this code in a more compact way on cplex?
How can I write this code in a more compact way on CPLEX?如何在 CPLEX 上以更紧凑的方式编写此代码?
forall (j in J)
forall (i in I1)
{
if ( macc [i][j] == 1 || 2 || 4 || 5 || 7 || 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18 || 19) {
y[i][j][m] == 1;
}
else {
if (macc [i][j] == 3) {
y[i][j][3] == 1 || y[i][j][4] == 1;
}
}
you can use "in" with data in an if condition:您可以在 if 条件下对数据使用“in”:
{int} s={1,2,4,5,7,11,12,13,14,15,16,17,18,19};
int m=2;
dvar int x;
subject to
{
if (m in s) x==2;
}
works fine工作正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.