CPLEX模型无法运行,但我不知道为什么

时间:2019-01-14 14:03:36

标签: cplex opl

我不得不解决带有时间窗的功能性定向越野问题,我应该在CPLEX中实现它,但是时间窗的局限性不起作用。

有人可以解决这个问题吗?

我认为问题与时间范围有关,但我不确定。

// input data defined externally
// number of control points
int n = ...;
// set of control point indices
{int} N = ...;
// score at each control point
int p[N] = ...;
// distance matrix (travel time)
int t[0..n+1][0..n+1] = ...;
// maximum distance
int Tmax = ...;
 //time xindow
int O[N] = ...;
int C[N]= ...;
//demand
int demand[N] = ...;
//service time
int servicetime[N]= ...;
//Capacity
int Cap= ...;
//M variable
int M= 1000;
//decision variable
 dvar boolean x[0..n][1..n+1]; 
 dvar float B[0..n];
//objective function
dexpr float profit = sum(i in 1..n, j in 1..n+1) 
                        p[i]*x[i][j];
maximize profit;

//constraints
subject to {

  //Time Window 
    forall(i in N)
        O[i] <= B[i];

    forall(i in N)
      B[i] + servicetime[i] <= C[i];


   forall(i in N, j in N)
        B[i] + servicetime[i] + t[i][j] - B[j] <=  M * (1 - x[i][j]);

        //Capacity  
    sum(i in 1..n, j in 1..n+1) demand[i]*x[i][j] <= Cap                           
        //leave starting point
    sum(j in 1..n+1) x[0][j] == 1;
       //arrive at finishing point
    sum(i in 0..n) x[i][n+1] == 1;
      //flow conservation
    forall (k in N)
     sum(i in 0..n) x[i][k] == sum(j in 1..n+1) x[k][j]
    //visit controll points at most once
    forall(k in N)
      sum(i in 0..n) x[i][k] <= 1;
     //maximum tour duration
     sum(i in 0..n, j in 1..n+1)  t[i][j]*x[i][j] <= Tmax;}

0 个答案:

没有答案