0

当我在 CPLEX 中运行代码时,对于我的目标函数中的某些表达式,我收到此错误,“opl 无法提取表达式”。我的代码如下:

 /*********************************************
 * OPL 6.3 Model
 * Author: hp
 * Creation Date: Dec 14, 2016 at 6:16:18 PM
 *********************************************/

//Distribution Centers
int J=...;
range DC=1..J;
//Customers
int I=...;
range Customers=J+1..I;
//Vehicles
int V=...;
range Vehicle=1..V;
//Time Periods
int T=...;
range TP=1..T;
//Nodes
range Nodes=1..I;
//Operating Cost
int FCj[DC]=...;
//Vehicle_Cap
int VehicleCap[Vehicle]=...;
//Depot_Cap
int DepotCap=...;
//Transportation_Cost
float Cij[Nodes][Nodes]=...;
//TransCost_to_factory
float Cj[DC]=...;
//OrderCost
float OrderC[DC]=...;
//Demand
int Demand[Customers][TP]=...;

//HoldingCost
int HoldingC[DC]=...;
//return rate
float r=...;
//probability of quality problem
float w=...;
//repairing cost
float repairC=...;
//Manufacturing Cost
float m=...;
//repackaging cost
float repackagingC=...;
float Hivalue=...;

// optimal order
dvar int+ Qjt[DC][TP];

//DC
dvar boolean Xj[DC];
//DC allocation to customers
dvar boolean Yij[DC][Customers];
//Vehicle route
dvar boolean Xijvt[Nodes][Nodes][Vehicle][TP];
//sub-tour elimination
dvar int+    M[Customers][Vehicle][TP];

//Final Inventory
dvar int+   Sjt[DC][0..T];

//order decision variable
//dvar boolean Zjt[DC][TP];


//Varaible
// Total Costs

 dexpr float TotalHoldingandOrderingCosts=sum (j in DC, t in TP) HoldingC[j]*Sjt[j][t]+sum (j in DC,t in TP) OrderC [j]* Qjt[j][t];
 dexpr float TotalDepotOperatingCost= sum (j in DC) Xj[j]*FCj[j];
 dexpr float TotalTransCostFactorytoDC= sum (j in DC, t in TP) Cj[j]*Qjt[j][t];
 dexpr float TotalTransCostDCtoCustomer= sum (i in Nodes, j in Nodes, v in Vehicle, t in TP) Cij[i][j]*Xijvt[i][j][v][t];
 dexpr float TotalTransCostDCToFactory= sum (j in DC, t in TP) w*r*Qjt[j][t]*Cj[j];
 dexpr float TotalManufacturingCost= sum (i in Customers, t in TP) Demand[i][t]*m;
 dexpr float TotalReworkingCost= sum (j in DC, t in TP) w*r*repairC*sum(i in Customers)Demand[i][t]*Yij[j][i];
 dexpr float TotalRepackagingCost= sum (j in DC, t in TP) r*(1-w)*repackagingC*sum(i in Customers)Demand[i][t]*Yij[j][i];

 //Objective Function

 minimize TotalHoldingandOrderingCosts+TotalDepotOperatingCost+TotalTransCostFactorytoDC+
          TotalTransCostDCtoCustomer+TotalTransCostDCToFactory+TotalManufacturingCost+
          TotalReworkingCost+TotalRepackagingCost;

 subject to{

const1: forall (i in Customers){
  sum (j in DC)Yij[j][i]==1;}


Const2: forall (j in DC){
  sum (i in Customers)Yij[j][i]<=Xj[j]*Hivalue;}


Const3: forall (i in Customers) {
  sum (j in Nodes, v in Vehicle, t in TP) Xijvt [i][j][v][t]==1;}


Const4: forall (i in Nodes, v in Vehicle, t in TP) {
  sum (j in Nodes) Xijvt[i][j][v][t]-sum (j in Nodes) Xijvt[i][j][v][t]==0;}


Const5: forall (v in Vehicle, t in TP) {
  sum (i in Customers, j in DC)Xijvt[j][i][v][t]<=1; }


Const6: forall (v in Vehicle, t in TP) {
  sum (j in Nodes, i in Customers) Demand[i][t]*Xijvt[i][j][v][t]<=VehicleCap[v];}


Const7: forall (j in DC, t in TP) {
  sum (i in Customers) Demand[i][t]*Yij[j][i]<=Xj[j]*DepotCap;}


Const8: forall (i in Customers, j in DC, v in Vehicle, t in TP){
  sum (g in Nodes) Xijvt[i][g][v][t]+sum (g in Nodes)Xijvt[g][j][v][t]-Yij[j][i]>=1;}


Const9: forall (i in Customers, h in Customers, v in Vehicle, t in TP){
  M[i][v][t]-M[h][v][t]+I*Xijvt[i][h][v][t]<=I-1;}


//Const10: forall (j in DC, t in TP){
 // sum (i in Customers) Demand[i][t]*Yij[j][i]<=Qjt[j][t];}


//Const11: forall (j in DC, t in TP){
  //Zjt[j][t]<=Xj[j]*Hivalue;}


Const10: forall (j in DC){
  Sjt[j][0]==0;}


Const11: forall (j in DC){  
  Sjt[j][1]==Sjt[j][0]+Qjt[j][1]-sum(i in Customers)Demand[i][1]*Yij[j][i];}


Const13: forall (j in DC, t in 2..T){
  Sjt[j][t]==Sjt[j][t-1]+Qjt[j][t]-sum(i in Customers)Demand[i][t]*Yij[j][i]+
  sum(i in Customers)Demand[i][t-1]*Yij[j][i]*r*(1-w);}


Const14: forall (j in DC, t in TP){
  Qjt[j][t] <= Hivalue*Xj[j]    ;}
}
execute DISPLAY {
      writeln("TotalHoldingandOrderingCosts=", TotalHoldingandOrderingCosts);
      writeln("TotalDepotOperatingCost=",TotalDepotOperatingCost);
      writeln("TotalTransCostFactorytoDC=",TotalTransCostFactorytoDC);
      writeln("TotalTransCostDCtoCustomer=",TotalTransCostDCtoCustomer);
      writeln("TotalTransCostDCToFactory=",TotalTransCostDCToFactory);
      writeln("TotalManufacturingCost=",TotalManufacturingCost);
      writeln("TotalReworkingCost=",TotalReworkingCost); 
      writeln( "TotalRepackagingCost=", TotalRepackagingCost);
        }   

    * OPL 6.3 Data
 * Author: hp
 * Creation Date: Dec 14, 2016 at 6:16:18 PM
 *********************************************/
J=2;
I=6;
V=3;
T=3;
r=0.2;
w=0.85;

FCj=[500 700];
VehicleCap=[600 600 600];
DepotCap=1000;
Cij=[[0 100 200 400 500 200]
     [200 0 100 300 100 300]
     [150 200 0 100 200 500]
     [100 200 200 0 100 100]
     [100 100 100 200 0 800]
     [300 350 250 150 100 0]];
Cj=[1 2];
OrderC=[0.2 0.1];
Demand=[[100 73 60]
        [50 40 68]
        [80 95 74]
        [30 68 94]];
HoldingC=[3 5];
repairC=0.5;
repackagingC=0.2;
m=2;
Hivalue=100000000;

令人困惑;我不知道是什么问题。有谁知道问题是什么?

4

1 回答 1

0

为了获得一些有用的放松,您可以将 const13 重写为

forall (j in DC, t in 2..T){
  const13a:Sjt[j][t]<=Sjt[j][t-1]+Qjt[j][t]-sum(i in Customers)Demand[i][t]*Yij[j][i]+
  sum(i in Customers)Demand[i][t-1]*Yij[j][i]*r*(1-w);}

  forall (j in DC, t in 2..T){
  const13b:Sjt[j][t]>=Sjt[j][t-1]+Qjt[j][t]-sum(i in Customers)Demand[i][t]*Yij[j][i]+
  sum(i in Customers)Demand[i][t-1]*Yij[j][i]*r*(1-w);}

问候

于 2016-12-19T06:29:44.250 回答