我正在Cplex中执行MIP代码。该问题具有可行的解决方案,但CPLEX解决方案不可行。而且,它并没有显示任何松弛,但是它放松了容量限制1和2。我认为它与运行配置有关,但我不知道问题出在什么地方。
模型如下:
//Parameters
//DKPCs
int I=...;
range DKPCs=1..I;
//Small DKPCs
int S=...;
range SDKPCS=1..S;
//Big and Medium DKPCs
range BDKPCs=S+1..I;
//Depots
range Depots=1..2;
//Free capacity of depots
float Cj[Depots]=...;
//The unit storage cost of product i
float Hi[DKPCs]=...;
//Volume
float Vi[DKPCs]=...;
//The unit lost sale cost of product i
float Si[DKPCs]=...;
//The probability of selling product i if it were available in the DK depots
float Pi[DKPCs]=...;
//The initial inventory of consignment depot for product i
int Ki[DKPCs]=...;
// Total demand for product i in time period
int Di[DKPCs]=...;
int M=...;
//Decision Varaibles
//The assigned consignment capacity for product i
dvar int+ Yi[DKPCs];
//if product i is selected for consignment capacity
dvar boolean Xi[DKPCs];
//if product i is available in the DK deopts in the problem time period
dvar boolean Zi[DKPCs];
//Formulation
//Total Cost
dexpr float TotalStorageCost=sum (i in DKPCs)(Yi[i]+Ki[i]*Xi[i]-1/2*Di[i]*Xi[i])*Hi[i];
dexpr float TotalLostSaleCost=sum (i in DKPCs)(1-Zi[i])*(Di[i]-Ki[i])*Si[i]*Pi[i];
dexpr float TotalSmallProductsVolume= sum (i in SDKPCS)Vi[i]*Yi[i];
dexpr float TotalBigProductsVolume= sum (i in BDKPCs)Vi[i]*Yi[i];
minimize TotalStorageCost+TotalLostSaleCost;
subject to {
const1: forall (i in SDKPCS, j in 1..1){
Vi[i]*Yi[i]<=Cj[1];}
const2: forall (i in BDKPCs, j in 2..2){
Vi[i]*Yi[i]<=Cj[2];}
const3: forall (i in DKPCs){
Yi[i]<=M*Xi[i];}
//const4: forall (i in DKPCs){
// Ki[i]-Di[i]<=M*(1-Xi[i])-1;}
const5: forall (i in DKPCs){
Ki[i]-Di[i]<=M*Zi[i]-1;}
const6: forall (i in DKPCs){
Xi[i]*(Di[i]-Ki[i])<=Yi[i];}
const7: forall (i in DKPCs){
Yi[i]<=M*Zi[i];}
const8: forall (i in DKPCs){
(Di[i]-Ki[i])*Zi[i]<=M*Xi[i];}
const9: forall (i in DKPCs){
Yi[i]>=0;}}
execute DISPLAY {
writeln("TotalStorageCost=", TotalStorageCost);
writeln("TotalLostSaleCost=",TotalLostSaleCost);
writeln("TotalSmallProductsVolume=",TotalSmallProductsVolume);
writeln("TotalBigProductsVolume=",TotalBigProductsVolume);
}
并且数据如下:
I=10;
S=3;
Cj=[2,500];
Hi=[38 33 23 23 23 33 43 43 47 41];
Vi=[0.02 0.03 0.01 0.38 1.02 1.86 0.48 1.00 1.31 1.19];
Si=[63 81 174 119 157 177 125 101 97 176];
Pi=[0.83 0.69 0.10 0.07 0.51 0.20 0.92 0.60 0.32 0.33];
Ki=[20 24 13 22 16 24 13 12 20 13];
Di=[67 20 212 406 417 423 134 425 103 447];
M=999999999999999999;
的确。我的建议:关闭presolve。
添加
execute
{
cplex.preind=0;
}
在模型的开头
加号,如果您使用datacheck 2
execute
{
cplex.datacheck=2;
}
您会得到
CPLEX警告1041:在约束50中,变量'Xi(1)'具有一个 系数为1e + 18,请考虑使用指标。
因此,可以使用逻辑约束来代替使用大的M。
如果x是二进制决策变量,y是整数决策变量,则可以在OPL中编写
(x==(y>=7));