【问题标题】:How to solve no solution problem in Cplex?如何解决 Cplex 中的无解问题?
【发布时间】:2022-01-25 00:23:15
【问题描述】:

这个问题是关于确定哪个工厂生产哪种产品和产品数量。 这是 excel 文件中日期表的链接:https://docs.google.com/spreadsheets/d/1oxAQ8DxYnlROjdhaKtYXTH4TJ0md6P0m/edit?usp=sharing&ouid=108002941647410415561&rtpof=true&sd=true

我的 .mod:

int nbPlants=3;
int nbProducts=14;
int nbCustomer=18;
int nbMaterial=6;
range Plant=1..nbPlants;
range Product=1..nbProducts;
range Customer=1..nbCustomer;
range Material=1..nbMaterial;


float TotalResource[Material][Plant]=...;
//Table 3
float ProductCost[Product][Plant] = ...;
//Table Demand
float Demand[Product][Customer] = ...;  
//Table 2
range ProdPlant=1..nbProducts*nbPlants;
float CoefResource0[ProdPlant][Material]=...;
float CoefResource[i in Product][j in Plant][e in Material]=CoefResource0[(i-1)*nbPlants+j][e];
float MaxProdRate[Product][Plant] = ...;

dvar int+ ProdRate[Product][Plant]; // quantities of product i that j produce
dvar boolean z[Product][Plant]; // z = 1 if j produce i
dvar boolean y[Material][Plant];// y = 1 if j use material e

// Objective function
minimize 
    sum(i in Product,j in Plant)ProductCost[i][j]*ProdRate[i][j]*z[i][j];

subject to {
  //Products produced have to be equal or more than demand
  forall (i in Product, j in Plant,c in Customer)
 { ProdRate[i][j]>= Demand[i][c] ;}
  //Production Rate less than max (te/week)
  forall (i in Plant, j in Plant) 
  { ProdRate[i][j] <= MaxProdRate[i][j]*z[i][j] ;}
  //If j produce i then te/week*h/te < h/week
  forall(i in Product, e in Material, j in Plant)
   sum(j in Plant,e in Material)ProdRate[i][j]*CoefResource[i][j][e] <= TotalResource[e][j]*y[e][j];
}

这是我的 .dat 文件:

SheetConnection sheet("prj-seperate.xlsx");
 
TotalResource=
[[120 105 105]
 [105 105 120]
 [105 120 120]
 [150   0   0]
 [105   0   0]
 [105   0   0]];

Demand=
[[ 18   0   0  15  0  0   0  0  0  0  0  10   0  0   0 15   0   0]
 [  0  99 155 150  0  0 114 50 50  0 50  31  21  0   0  0 103   0]
 [  0  55  50 126 92 50   0  0  0  0  0   0   0  0   0 68   0   0]
 [106 203 266   0  0  0 140 45  0 17 31   0 100 50 150  0 110   0]
 [  0  76   0   0  0  0   0 40  0  0 20   0   0  0   0  0   0   0]
 [252   0  66   0  0 68   0 23  0  0  0 100   0  0   0  0  44 100]
 [  0  30  17   5  0  0   0  0 52  0  0  13  15  0  10  5  12   0]
 [  0   0   0  27  0  0   0  0  0  0  0   0   0  7   0 20   0   0]
 [ 43   0   0   0 21 20  34  5  7  5  0   0   0  0   0  0   0   0]
 [  0   0   0   0  0  0   0  0  0  0  0  38   0  0   0  0   0 266]
 [  0  20   0   0  0  0   0  0  0  0 20   0   0  0  15  0   0   0]
 [  0   0   0  25  0  0   0  0  0  0  0   0   0  0   0 20   0   0] 
 [ 70   0  15   0 50 10  68  0  0 16 15   0  50  0   0  0  13   0]
 [ 34   0   0   0  0 10   0  0  0  0 20   0   0  0  10  0   0   0]];

 MaxProdRate=
[[ 158    0 972]
 [2268 1411 778]
 [1701 1058 607]
 [1512 1328 540]
 [   0  996   0]
 [ 812  664 416]
 [ 642  664 416]
 [ 482    0 312]
 [ 320    0 208]
 [ 504    0   0]
 [   0  530 403]
 [ 661  469   0]
 [ 441  330 270]
 [ 221    0   0]];

//Unit Production Costs
ProductCost=
[[ 61.27  59.45  61.44]
 [ 61.27  59.45  61.44]
 [ 61.27  59.45  61.44]
 [ 61.27  59.45  61.44]
 [ 61.27  59.45  61.44]
 [ 61.27  59.45  61.44]
 [256.90 268.50 270.80]
 [256.90 268.50 270.80]
 [256.90 268.50 270.80]
 [ 61.27  59.45  61.44]
 [256.90 268.50 270.80]
 [256.90 268.50 270.80]
 [256.90 268.50 270.80]
 [256.90 268.50 270.80]];
CoefResource0 from SheetRead(sheet,"CoefResource0");

感谢您阅读我的帖子。

【问题讨论】:

    标签: python c++ arrays matrix


    【解决方案1】:

    如果你标记你的约束:

    subject to {
      //Products produced have to be equal or more than demand
      forall (i in Product, j in Plant,c in Customer)
     { ct1:ProdRate[i][j]>= Demand[i][c] ;}
      //Production Rate less than max (te/week)
      forall (i in Plant, j in Plant) 
      { ct2:ProdRate[i][j] <= MaxProdRate[i][j]*z[i][j] ;}
      //If j produce i then te/week*h/te < h/week
      forall(i in Product, e in Material, j in Plant)
       ct3:sum(j in Plant,e in Material)ProdRate[i][j]*CoefResource[i][j][e] <= TotalResource[e][j]*y[e][j];
    }
    

    然后你会在 IDE 中得到一些放松和冲突,让你理解为什么模型不可行

    【讨论】:

      猜你喜欢
      • 2019-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多