Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  y variable not working for CVRPTW

    Posted 06/10/20 03:41 AM

    Hi,

    I'm working on a CVRPTW, where my y variable needs to show at which time my vehicle(s) arrives at a customer. My problem is that it is not working correctly for all of my customers. At the end it will subtract the distance from my upper bound time window.

    Below my mod file:

    int v=...; //number of customers

    range V=1..v; //customers - where 1 is the depot

    int d[V]=...; //demand for each customer

    int k=...;//number of vehicles

    range K=1..k; //number of vehicles

    int C=...; //Capacity per vehicle

    int c[V][V]=...; //cost between customers and depot

    int e[V] = ...; // lower bound time window for each customer

    int l[V] =...; // upper bound time window for each customer

    int M=...; // big integer value

    int S=...; // cost to use a vehicle

    dvar boolean x[K][V][V]; // route driven between customer i and j

    dvar int+ y[V]; // arriving time

    dvar boolean g[K]; //if vehicle k is used

    dexpr float m = max(a,b in V) (l[a] + c[a][b] - e[b]);

    minimize sum(i,j in V, k in K) (c[i][j] * x[k][i][j]) + sum(k in K)(g[k] * S);

    subject to {

     forall (j in V : j!=1)

     sum (k in K, i in V) x[k][i][j] == 1;

      

     forall(i in V : i!=1)

     sum (k in K, j in V) x[k][i][j] == 1;

      

     forall (i in V, k in K)

      x[k][i][i] == 0;

      

     sum (j in V) x[k][1][j] == 1;

      

     forall (h in V : h !=1, k in K)

      sum(i in V) x[k][i][h] - sum(j in V) x[k][h][j] == 0;

       

      forall (k in K)

      sum(j in V, i in V : i!=1) (d[i] * x[k][i][j]) <= C;

       

      forall (j in V)

       sum(k in K) x[k][1][j] <= k;

      

      forall (i in V)

       e[i] <= y[i] <= l[i];

       

      forall (k in K)

       g[k] <= sum(i, j in V) x[k][i][j];

       

      forall (k in K)

      sum(i, j in V) x[k][i][j] <= g[k] * M;

        

      forall (i,j in V : i!=j && j!=1, k in K)

       y[i] +c[i][j] <= y[j] + m* (1-x[k][i][j]);

       

       forall (k in K) 

       y[1] == 0;

     }

    Right now I'm working with 45 customers (depot included, which is indicated by 1). 3 vehicles with a capacity of 500.

    Thank you in advance for the help!



    ------------------------------
    Arlien Kuijs
    ------------------------------

    #DecisionOptimization


  • 2.  RE: y variable not working for CVRPTW

    Posted 06/10/20 04:01 AM
    Can you please elaborate on what "it is not working" means? What exactly is the problem. It would also be nice to see your .dat (if possible) so that we can test your code here.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: y variable not working for CVRPTW

    Posted 06/10/20 04:42 AM
    Hi, 

    Thank you for your quick response!

    In the attachment I added my dat file.

    the first visited customers y values are correct, since it is adding up. Some of the y variables have really high numbers, this my upper bound time window and a couple just a bit below my upper bound.




    ------------------------------
    Arlien Kuijs
    ------------------------------