admin管理员组文章数量:1334169
So I am solving a transportation optimization model with some changes on my own. The model runs successfully but when I see the values of the decision variables it showing me a 3D array with all values as 0.
.mod file
int m = ...;
int n = ...;
int o = ...;
range I = 1..m;
range J = 1..n;
range K = 1..o;
float d[I][J] = ...;
float s[I] = ...;
float f = ...;
float v = ...;
float q = ...;
float u[I][J][K];
dvar float x[I][J][K];
dvar int y[I][J][K];
float data[1..9][1..261] = ...;
minimize sum(i in I, j in J, k in K) f*y[i][j][k] + sum(i in I, j in J, k in K) v*d[i][j]*y[i][j][k];
subject to {
Constraint1: forall(j in J, k in K) sum(i in I) x[i][j][k] == sum(i in I) u[i][j][k];
Constraint2: forall(i in I) sum(j in J, k in K) x[i][j][k] <= s[i];
Constraint3: forall(i in I, j in J, k in K) x[i][j][k] <= q*y[i][j][k];
Constraint4: forall(i in I, j in J, k in K) x[i][j][k] >= 0;
Constraint5: forall(i in I, j in J, k in K) y[i][j][k] >= 0;
}
execute {
for (var k = 1; k <= 3; k++) {
for (var i = 1; i <= 3; i++) {
for (var j = 1; j <= 261; j++) {
// Calculate the row index based on k and i
var row = (k - 1) * 3 + i; // 3 rows per k
u[i][j][k] = data[row][j]; // Offset by 1 for customer index
}
}
}
}
.dat file
m = 3;
n = 261;
o = 3;
SheetConnection Sheet ("ProjectData.xlsx");
d from SheetRead (Sheet, "CPLEX! C6:JC8");
s from SheetRead (Sheet, "Data! C3:C5");
f from SheetRead (Sheet, "Data! B16");
v from SheetRead (Sheet, "Data! B17");
q from SheetRead (Sheet, "Data! B18");
data from SheetRead (Sheet, "CPLEX! C16:JC24");
I have checked the values of all parameters to see if the value is correct and that is coming out to be the case. CPLEX is not giving me any reason as well why my model will not run. I am on student CPLEX version if it helps.
So I am solving a transportation optimization model with some changes on my own. The model runs successfully but when I see the values of the decision variables it showing me a 3D array with all values as 0.
.mod file
int m = ...;
int n = ...;
int o = ...;
range I = 1..m;
range J = 1..n;
range K = 1..o;
float d[I][J] = ...;
float s[I] = ...;
float f = ...;
float v = ...;
float q = ...;
float u[I][J][K];
dvar float x[I][J][K];
dvar int y[I][J][K];
float data[1..9][1..261] = ...;
minimize sum(i in I, j in J, k in K) f*y[i][j][k] + sum(i in I, j in J, k in K) v*d[i][j]*y[i][j][k];
subject to {
Constraint1: forall(j in J, k in K) sum(i in I) x[i][j][k] == sum(i in I) u[i][j][k];
Constraint2: forall(i in I) sum(j in J, k in K) x[i][j][k] <= s[i];
Constraint3: forall(i in I, j in J, k in K) x[i][j][k] <= q*y[i][j][k];
Constraint4: forall(i in I, j in J, k in K) x[i][j][k] >= 0;
Constraint5: forall(i in I, j in J, k in K) y[i][j][k] >= 0;
}
execute {
for (var k = 1; k <= 3; k++) {
for (var i = 1; i <= 3; i++) {
for (var j = 1; j <= 261; j++) {
// Calculate the row index based on k and i
var row = (k - 1) * 3 + i; // 3 rows per k
u[i][j][k] = data[row][j]; // Offset by 1 for customer index
}
}
}
}
.dat file
m = 3;
n = 261;
o = 3;
SheetConnection Sheet ("ProjectData.xlsx");
d from SheetRead (Sheet, "CPLEX! C6:JC8");
s from SheetRead (Sheet, "Data! C3:C5");
f from SheetRead (Sheet, "Data! B16");
v from SheetRead (Sheet, "Data! B17");
q from SheetRead (Sheet, "Data! B18");
data from SheetRead (Sheet, "CPLEX! C16:JC24");
I have checked the values of all parameters to see if the value is correct and that is coming out to be the case. CPLEX is not giving me any reason as well why my model will not run. I am on student CPLEX version if it helps.
Share Improve this question asked Nov 20, 2024 at 15:17 Aziz AgasiAziz Agasi 631 silver badge8 bronze badges 1- Hi, without the Excel file nobody can reproduce your issue. Plus, why do you say your model could not run ? According to me , cplex found a solution and that solution is full o 0s – Alex Fleischer Commented Nov 20, 2024 at 16:54
1 Answer
Reset to default 0I think that the issue could be that you wrote
float u[I][J][K];
which means all u are 0
int m = 3;
int n = 261;
int o = 3;
range I = 1..m;
range J = 1..n;
range K = 1..o;
float d[i in I][j in J] = rand(10);
float s[i in I] = rand(10)+200000;
float f = 2;
float v = 3;
float q = 8000;
float u[i in I][j in J][k in K]=rand(10);
dvar float x[I][J][K];
dvar int y[I][J][K];
float data[i in 1..9][j in 1..261] = rand(10);
minimize sum(i in I, j in J, k in K) f*y[i][j][k] + sum(i in I, j in J, k in K) v*d[i][j]*y[i][j][k];
subject to {
Constraint1: forall(j in J, k in K) sum(i in I) x[i][j][k] == sum(i in I) u[i][j][k];
Constraint2: forall(i in I) sum(j in J, k in K) x[i][j][k] <= s[i];
Constraint3: forall(i in I, j in J, k in K) x[i][j][k] <= q*y[i][j][k];
Constraint4: forall(i in I, j in J, k in K) x[i][j][k] >= 0;
Constraint5: forall(i in I, j in J, k in K) y[i][j][k] >= 0;
}
execute {
for (var k = 1; k <= 3; k++) {
for (var i = 1; i <= 3; i++) {
for (var j = 1; j <= 261; j++) {
// Calculate the row index based on k and i
var row = (k - 1) * 3 + i; // 3 rows per k
u[i][j][k] = data[row][j]; // Offset by 1 for customer index
}
}
}
}
gives a non null solution
本文标签: oplCplex showing value of decision variables as 0Stack Overflow
版权声明:本文标题:opl - Cplex showing value of decision variables as 0 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742350225a2458341.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论