0

我正在做一个项目,其中我有一个导入到 cplex 的节点之间的距离矩阵。我这样做:

tuple arc{
 float x;
 float y;
 float d;
 float Ttime;       //Time to travell the arc
 }

 tuple vehicle{
 key int id;
 int STdepot;   //Starting Depot (1 or 2)
 int MaxCars;       //Maximum number of cars in a vehicle
 float AvSpeed;     //Average Speed of a vehicle
 }

tuple cavities{
key int id;
float x;
float y;
float rate;         //Consumption Rate
float iniStock;     //Initial Stock to be consumed at cavitie x
float deadline;     //Deadline to arrive at cavitie x
int ProdCons;       //Production Consumed at cavitie x

}

tuple CAVtype{
key int id;
int CarsCons;       //Consuming cars of 12 or 20
}

tuple nodes{
key int id;
float x;        //Coordinates in X
float y;        //Coordinates in Y
string type;
}       
 setof(arc)         OD = ...;   //DistanceMatrix
 setof(vehicle)     K=...;      //Vehicles
 setof(cavities)    C=...;      //Cavities
 setof(CAVtype)     T=...;      // Cavities Type
 setof(nodes)       N=...;      //Nodes

  float d[N][N];
  float t[N][N];    

execute preProcess{

  cplex.tilim=300;
  for(var i in N){
    for(var j in N){
        d[i][j] = 9999;
        t[i][j] = 9999;
    }
  }

  for(var arc in OD){
  var origin = N.get(arc.x);      
  var destination = N.get(arc.y);

      d[origin][destination] = arc.d;
      t[origin][destination] = arc.Ttime;
  }  
 }

它导入所有内容,但是当我添加限制时,距离矩阵不受尊重,变量显示没有连接的节点之间的连接。另外,最后一个限制改变了 q 的值,为什么会这样?我该如何解决这个问题?

提前致谢。

目标函数和限制如下:

    dexpr float MachineStoppage = sum(k in K,i in N,j in N) d[i][j] * x[i][j][k] + 
 sum(g in C,k in K) penalize *phi[g] + sum(i in N,g in C) u[i][g];              //(1)

minimize MachineStoppage;

//*******************************|Restrictions|***********************************************************
subject to{

forall (i in C, k in K)                                         //(2)
  FlowConservation:
 sum(j in N: i.id!=j.id) x[<i.id>][j][k] == z[<i.id>][k];

forall (i in C, k in K)                                         //(3)
  FlowConservation2:
 sum(j in N: i.id!=j.id) x[j][<i.id>][k] == z[<i.id>][k];


 forall(i in N, k in K: i.type == "d" && k.STdepot!= i.id)                                          //(5)
   DepartingFromAnyDepot:
  sum(j in N: i.id!=j.id) x[i][j][k] == 0;


 forall(i in N)                      
   sum(k in K) z[i][k]==1; 

 forall(i in N,j in N,k in K: i!=j && j.id!=0)                          //(8)
   ArrivalTimeTracking1:
  w[k][i] + t[i][j] <= w[k][j] + M*(1-x[i][j][k]);


 forall(i in N,j in N,k in K: i!=j && j.id!=0)                          //(9)
   ArrivalTimeTracking2:
  w[k][i] + t[i][j] >= w[k][j]- M*(1-x[i][j][k]);

 forall(k in K, g in C, i in N)                                         //(10)
   ReplenishmentDelay:
 //w[k][<g.id>] <= g.deadline + phi[g];
  w[k][<g.id>] <= g.deadline + phi[g];

 forall(i in N, g in C, k in K)                                        //(11)
   QuantitiesToBeDeliveredToTheCavities:                            
  q[k][g] == ((g.rate*w[k][<g.id>]) + u[i][g] + (g.ProdCons-g.iniStock));

 forall(i in N,g in C,k in K)                                          //(12)
   LimitofQuantitiesToBeDelivered:
   q[k][g] >= z[i][k] * g.ProdCons;
  //q[k][g] >= z[<i.id>][k] * g.ProdCons;

 forall(h in T, k in K)                                                //(13)
   NumberOfCarsOfEachTypeinEachVehicle:
  sum(i in N,g in C) q[k][g] <= h.CarsCons*y[k][h];

/*
 forall(k in K, g in C)                                                //(14)
   MaximumOfCarsinaVehicle:
  sum(h in T) y[k][h] <=b;
*/
4

1 回答 1

1

你确定你没有得到一个轻松的解决方案吗?在文档中

IDE 和 OPL > CPLEX Studio IDE > IDE 教程

您可以查看“放松不可行模型”部分。

于 2018-03-05T13:53:29.477 回答