CPLEX OPL错误5002错误

时间:2018-05-13 10:44:15

标签: cplex opl

我开始编写这个OPL代码,但我一直收到5002错误。我试图努力解决它,但没有什么真正对我有用。除此之外我找不到改造它的方法。代码中必定存在一些错误,现在我无法弄明白。有没有人能帮助我解决这个问题。我需要在星期一提交我的项目。

range operation=1..8;
range machine=1..2;
range tool=1..10;


dvar boolean y[operation,machine];
dvar boolean x[operation,tool];
dvar boolean w1;
dvar boolean w2;
dvar boolean w3;

float coef1[operation,machine]=[[133,133],
                                [71,71],
                                [42,42],
                                [83,83],
                                [91,91],
                                [63,63],
                                [108,108],
                                [125,125]];
float coef2[operation,machine]=[[60,60],
                                [252,252],
                                [302,302],
                                [79,79],
                                [500,500],
                                [440,440],
                                [445,445],
                                [151,151]];
float coef3[operation,machine]=[[4,4],
                                [4,4],
                                [4,4],
                                [6,6],
                                [6,6],
                                [6,6],
                                [4,4],
                                [6,6]];


maximize sum(i in operation,j in machine) y[i,j]*coef1[i,j];



subject to
{
sum(i in operation,j in machine) y[i,1]*coef2[i,1]<=384;
sum(i in operation,j in machine) y[i,2]*coef2[i,2]<=492; 

y[1,1]+y[1,2]==x[1,1]*x[1,7];
y[2,1]+y[2,2]==x[2,1]*x[2,4];
y[3,1]+y[3,2]==x[3,5]*x[3,8];
y[4,1]+y[4,2]==w1; //x[4,1]*x[4,2]*x[4,6]
y[5,1]+y[5,2]==x[5,3]*x[5,8];
y[6,1]+y[6,2]==w2; //x[6,3]*x[6,5]*x[6,8]
y[7,1]+y[7,2]==x[7,2]*x[7,4];
y[8,1]+y[8,2]==w3; //x[8,7]*x[8,8]*x[8,9]

w1<=x[4,1];
w1<=x[4,2];
w1<=x[4,6];
w1>=x[4,1]+x[4,2]+x[4,6]-2;

w2<=x[6,3];
w2<=x[6,5];
w2<=x[6,8];
w2>=x[6,3]+x[6,5]+x[6,8]-2;

w3<=x[8,7];
w3<=x[8,8];
w3<=x[8,9];
w3>=x[8,7]+x[8,8]+x[8,9]-2;


x[1,1]+x[2,1]+x[4,1]<=2;
x[4,2]+x[7,2]<=1;
x[6,3]<=1;
x[2,4]+x[7,4]<=2;
x[3,5]+x[5,5]+x[6,5]<=2;
x[4,6]<=2;
x[1,7]+x[8,7]<=1;
x[3,8]+x[6,8]+x[8,8]<=2;
x[8,9]<=1;
x[5,10]<=1;

y[1,1]+y[1,2]<=1; 
y[2,1]+y[2,2]<=1;
y[3,1]+y[3,2]<=1;
y[4,1]+y[4,2]<=1;
y[5,1]+y[5,2]<=1;
y[6,1]+y[6,2]<=1;
y[7,1]+y[7,2]<=1;
y[8,1]+y[8,2]<=1;

sum (i in operation,j in machine) y[i,1]*coef3[i,j]<=6;
sum (i in operation,j in machine) y[i,2]*coef3[i,j]<=6;
 }

1 个答案:

答案 0 :(得分:0)

同样的问题https://www.ibm.com/developerworks/community/forums/html/topic?id=5e82ca06-e5dd-42f0-8849-1989cdda122b&ps=25

 range operation=1..8;

range machine=1..2;
range tool=1..10;


dvar boolean y[operation,machine];
dvar boolean x[operation,tool];
dvar boolean w1;
dvar boolean w2;
dvar boolean w3;

float coef1[operation,machine]=[[133,133],
                                [71,71],
                                [42,42],
                                [83,83],
                                [91,91],
                                [63,63],
                                [108,108],
                                [125,125]];
float coef2[operation,machine]=[[60,60],
                                [252,252],
                                [302,302],
                                [79,79],
                                [500,500],
                                [440,440],
                                [445,445],
                                [151,151]];
float coef3[operation,machine]=[[4,4],
                                [4,4],
                                [4,4],
                                [6,6],
                                [6,6],
                                [6,6],
                                [4,4],
                                [6,6]];


maximize sum(i in operation,j in machine) y[i,j]*coef1[i,j];



subject to
{
sum(i in operation,j in machine) y[i,1]*coef2[i,1]<=384;
sum(i in operation,j in machine) y[i,2]*coef2[i,2]<=492;

y[1,1]+y[1,2]==(x[1,1]==1) && (x[1,7]==1);
y[2,1]+y[2,2]==(x[2,1]==1) && (x[2,4]==1);
y[3,1]+y[3,2]==(x[3,5]==1)&&(x[3,8]==1);
y[4,1]+y[4,2]==w1; //x[4,1]*x[4,2]*x[4,6]
y[5,1]+y[5,2]==(x[5,3]==1) && (x[5,8]==1);
y[6,1]+y[6,2]==w2; //x[6,3]*x[6,5]*x[6,8]
y[7,1]+y[7,2]==(x[7,2]==1) && (x[7,4]==1);
y[8,1]+y[8,2]==w3; //x[8,7]*x[8,8]*x[8,9]

w1<=x[4,1];
w1<=x[4,2];
w1<=x[4,6];
w1>=x[4,1]+x[4,2]+x[4,6]-2;

w2<=x[6,3];
w2<=x[6,5];
w2<=x[6,8];
w2>=x[6,3]+x[6,5]+x[6,8]-2;

w3<=x[8,7];
w3<=x[8,8];
w3<=x[8,9];
w3>=x[8,7]+x[8,8]+x[8,9]-2;


x[1,1]+x[2,1]+x[4,1]<=2;
x[4,2]+x[7,2]<=1;
x[6,3]<=1;
x[2,4]+x[7,4]<=2;
x[3,5]+x[5,5]+x[6,5]<=2;
x[4,6]<=2;
x[1,7]+x[8,7]<=1;
x[3,8]+x[6,8]+x[8,8]<=2;
x[8,9]<=1;
x[5,10]<=1;

y[1,1]+y[1,2]<=1;
y[2,1]+y[2,2]<=1;
y[3,1]+y[3,2]<=1;
y[4,1]+y[4,2]<=1;
y[5,1]+y[5,2]<=1;
y[6,1]+y[6,2]<=1;
y[7,1]+y[7,2]<=1;
y[8,1]+y[8,2]<=1;

sum (i in operation,j in machine) y[i,1]*coef3[i,j]<=6;
sum (i in operation,j in machine) y[i,2]*coef3[i,j]<=6;
}

工作正常

问候