谁能帮我解决这个 CPLEX 模型?
Can anyone help me with this CPLEX Model?
我正在尝试根据 :
计算树的每个部分 [i][j] 的库存成本
X={x[i][j]}
x[i][j] = 1 if has stock at ij
x[i][j] = 0 if has no stock at
库存视准备时间而定,他们自己取决于之前是否有库存如下:
a[i][j] = t[i][j] if it's the end node
= t[i][j] + max(s€sons of the brunch){ a[i+1][s] * (1 - x[i][s]}
好吧,代码编译没有任何结构错误,但是数组 a 和决策变量没有得到任何响应
//getting all the sons
range L=0..ligne;
range C=1..colone;
int sons[L][C][C];
int a[L][L];
execute
{
for (var i in Li){
for (var j in C){
for (var k in C){
if (parent[i+1][k] == j){
sons[i][j][k] = k;
}else
sons[i][j][k] = 0;
}
}
a[i][0]=0;
}
for (var j in C){
for (var k in C)
sons[ligne][j][k]=0;
}
}
//the variable and the objective function and constraints
dvar boolean x[L][Ci];
dexpr float TotalCost = aih_cost*adup*(1.5+var_factor)*lt_factor*sum(i in L,j in C)( unit_price[i][j]*rqtf[i][j]*x[i][j]*a[i][j] );
minimize TotalCost;
subject to {
forall(i in Li){
forall(j in C){
forall(k in C)
(1-x[i+1][sons[i][j][k]]) * a[i+1][sons[i][j][k]] + t_process[i][j] - a[i][j] >= 0;
}
}
a[0][1]<=service_t;
}
我希望至少有一个建议的 x 数组和一些准备时间“a”。
您的模型可能不可行。
您可以通过转动
来为约束添加名称
forall(i in Li){
forall(j in C){
forall(k in C)
(1-x[i+1][sons[i][j][k]]) * a[i+1][sons[i][j][k]] + t_process[i][j] - a[i][j] >= 0;
}
}
a[0][1]<=service_t;
进入
forall(i in Li){
forall(j in C){
forall(k in C)
ct1:(1-x[i+1][sons[i][j][k]]) * a[i+1][sons[i][j][k]] + t_process[i][j] - a[i][j] >= 0;
}
}
ct2:a[0][1]<=service_t;
然后你可以放松一下,这对你有帮助。
Cplex 默认使用求解器 cplex 解决线性问题和 MILP。
对于我的问题,“a”和“x”之间的依赖关系赋予它二次维度。
要解决此类问题,需要使用 CP 优化器 cpo,它通常用于约束规划,但它也可以解决非线性问题。
或者在其他尝试中,我将问题引入一个新的决策变量 y=a*x 并向模型添加了大量约束。
我正在尝试根据 :
计算树的每个部分 [i][j] 的库存成本X={x[i][j]}
x[i][j] = 1 if has stock at ij
x[i][j] = 0 if has no stock at
库存视准备时间而定,他们自己取决于之前是否有库存如下:
a[i][j] = t[i][j] if it's the end node
= t[i][j] + max(s€sons of the brunch){ a[i+1][s] * (1 - x[i][s]}
好吧,代码编译没有任何结构错误,但是数组 a 和决策变量没有得到任何响应
//getting all the sons
range L=0..ligne;
range C=1..colone;
int sons[L][C][C];
int a[L][L];
execute
{
for (var i in Li){
for (var j in C){
for (var k in C){
if (parent[i+1][k] == j){
sons[i][j][k] = k;
}else
sons[i][j][k] = 0;
}
}
a[i][0]=0;
}
for (var j in C){
for (var k in C)
sons[ligne][j][k]=0;
}
}
//the variable and the objective function and constraints
dvar boolean x[L][Ci];
dexpr float TotalCost = aih_cost*adup*(1.5+var_factor)*lt_factor*sum(i in L,j in C)( unit_price[i][j]*rqtf[i][j]*x[i][j]*a[i][j] );
minimize TotalCost;
subject to {
forall(i in Li){
forall(j in C){
forall(k in C)
(1-x[i+1][sons[i][j][k]]) * a[i+1][sons[i][j][k]] + t_process[i][j] - a[i][j] >= 0;
}
}
a[0][1]<=service_t;
}
我希望至少有一个建议的 x 数组和一些准备时间“a”。
您的模型可能不可行。 您可以通过转动
来为约束添加名称 forall(i in Li){
forall(j in C){
forall(k in C)
(1-x[i+1][sons[i][j][k]]) * a[i+1][sons[i][j][k]] + t_process[i][j] - a[i][j] >= 0;
}
}
a[0][1]<=service_t;
进入
forall(i in Li){
forall(j in C){
forall(k in C)
ct1:(1-x[i+1][sons[i][j][k]]) * a[i+1][sons[i][j][k]] + t_process[i][j] - a[i][j] >= 0;
}
}
ct2:a[0][1]<=service_t;
然后你可以放松一下,这对你有帮助。
Cplex 默认使用求解器 cplex 解决线性问题和 MILP。 对于我的问题,“a”和“x”之间的依赖关系赋予它二次维度。
要解决此类问题,需要使用 CP 优化器 cpo,它通常用于约束规划,但它也可以解决非线性问题。
或者在其他尝试中,我将问题引入一个新的决策变量 y=a*x 并向模型添加了大量约束。