[英]How to correct this constrains as an additional constrains in the main?
我试图在主体中编写下面的等式作为这种格式的附加约束,但是“setbounds”的第二行不起作用给了我一个错误,我要求正确吗?
main
{
For (i in 2..thisOplModel.Nbeams)
thisOplModel.ctEmptyy[i].setCoef(thisOplModel.A[i],1);
thisOplModel.ctEmptyy[i].setBounds(thisOplModel.A[i-1]+thisOplModel.B[i-1],thisOplModel.A[i-1]+thisOplModel.B[i-1]);
}
forall(i in beams)
ctEmptyy:0<=0;
//The equation is:
//(A[i]==A[i-1]+ B[i-1]);
让我向您展示斐波那契数列:
int n=10;
range r=0..n;
range r2=2..n;
dvar int+ fib[r];
subject to
{
fib[0]==1;
fib[1]==2;
forall(i in r2) ct:0<=0;
}
execute
{
writeln(fib);
}
main
{
thisOplModel.generate();
cplex.solve();
thisOplModel.postProcess();
for(var i in thisOplModel.r2)
{
thisOplModel.ct[i].setCoef(thisOplModel.fib[i], 1);
thisOplModel.ct[i].setCoef(thisOplModel.fib[i-1], -1);
thisOplModel.ct[i].setCoef(thisOplModel.fib[i-2], -1);
thisOplModel.ct[i].setBounds(0,0);
}
cplex.solve();
thisOplModel.postProcess();
}
给
[1 2 0 0 0 0 0 0 0 0 0]
[1 2 3 5 8 13 21 34 55 89 144]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.