Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Help! Problem with mathematical model using OPL

    Posted 01/26/11 07:28 AM

    Originally posted by: quawarty


    Hi,

    I am trying to write a mathematical model for a special VRP problem.
    It consists of transporting an amount of products (i.e 2 products)from a set of pickup customers to a set of a delivery customers by a vehicle with a given capacity (here it is equal to 3)available at the depot. Service at each customer (delivery or pickup customers) must start and end within a given time windows. The time windows indicate when the goods can be picked up and dropped off. In addition, I assume that a product picked up fro a pickup customer can be delivered to any delivery customer. The objective is to construct routes such that the total travel distance is minimized.
    You will find below the mathematical model using OPL.
    However, the result are strange! I don't know where I make mistakes.
    Could you please help me?

    Thank you for you help.

    Model.mod
    //Notation//
    //----------------------------------//
    int n = 5;
    range P = 1..2;/* set of products*/
    range N = 0..n+1;/* set of customers and depots (N.B. depot is represented by the two vertices )*/
    range N0 = 1..n;/* set of customers */
    range N_1 = 0..n;
    range N_0 = 1..n+1;
    //Parameters//
    //------------------------------------//
    int qN0[P] =...; /* amount of product p provided or required by customer */
    int di in Nj in N = rand()%(3+5+1)-5; /* travel distance between customer*/
    int Q = 3;/* vehicle capacity*/

    int t[N][N] = ...; /* travel time between customers*/
    int TsN_1 = ...; /* service time at a customer*/
    int e[N] = 0, 0, 0, 0, 0, 0, 0; /* lower bound of the time windows*/
    int l[N] = 10, 13, 27, 34, 24, 44, 41;/* upper bound of the time windows*/
    int M = 10000; /* a big number*/
    //--------------------------------------------------//
    //Decision variables//
    //--------------------------------------------------//
    dvar int+ f[N][N][P]; /* load of the vehicle by product p passing through the arc (i,j)*/
    dvar int+ T[N]; /*continous variable indicationg the time at which the vehicle strats serving pickup customer*/
    dvar boolean x[N][N][P];/* = 1 if the arc (i,j)*/
    //--------------------------------------------------//
    //Objective fucntion//
    //--------------------------------------------------//
    minimize
    sum (i in N, j in N, k in P) d[i][j] * x[i][j][k]; /* Minimize the total distance */
    /* Constraint: customer is visited exactly once*/
    subject to
    {

    forall (i in N0, k in P)
    sum (j in N) x[i][j][k] == 1;
    forall (j in N0, k in P)
    sum (i in N) x[i][j][k] == 1;
    /* Constraint: flow conservation*/
    forall(j in N0, k in P)
    sum(i in N) x[i][j][k] - sum (i in N) x[j][i][k] == 0;
    forall (k in P)sum(i in N) x[i][0][k] == 0;
    forall (k in P)x[0]n+1[k] == 0;
    forall (k in P) sum (i in N)xn+1[i][k] == 0;
    /*Conservation flow for demands*/

    forall(j in N0, k in P)
    sum (i in N) f[j][i][k] - sum (i in N) f[i][j][k] == sum(k in P) q[j][k];

    /*capacity constraint*/
    forall(i in N, j in N, k in P)
    f[i][j][k] <= Q * x[i][j][k];

    /*constraints ensures that the time windows*/
    forall(i in N)
    e[i]<= T[i] <= l[i];

    forall (j in N_0, i in N_1, k in P)
    T[j] >= T[i] + Ts[i] + t[i][j] - M *(1 - x[i][j][k]);

    }
    data.dat
    q =[2, 1
    3,0
    -1, 0
    -2, -1
    -2, 0];
    t = [0 1 7 10 9 6 0
    1 0 2 8 7 9 1
    7 2 0 3 6 8 7
    10 8 3 0 4 11 10
    9 7 6 4 0 5 9
    6 9 8 11 5 0 6
    0 1 7 10 9 6 0];
    Ts = 0, 1, 2, 3, 1, 1;
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Help! Problem with mathematical model using OPL

    Posted 01/26/11 09:10 AM
    Hi,

    do you get objective -12?
    What looks strange in your model is that d which looks like a distance can take negative values.

    Do you mean

    int d[i in N][j in N] = rand()%(3+5+1)-5;
    


    ?

    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Help! Problem with mathematical model using OPL

    Posted 01/26/11 11:04 AM

    Originally posted by: quawarty


    Thank you for your reply.

    yes I have got -12.

    Normally, I should have a positive number.
    Perhaps, it is due to the data.

    int di in Nj in N = rand()%(3+5+1)-5;
    I mean that d take value between 3 and 5 (3,5).
    I am not sure if it is correct.
    Thank you.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Help! Problem with mathematical model using OPL

    Posted 01/26/11 11:36 AM
    Hi

    I think you should rather write

    int d[i in N][j in N] = rand(3)+3;
    


    Regards

    Alex Fleischer
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Help! Problem with mathematical model using OPL

    Posted 01/28/11 07:58 AM

    Originally posted by: quawarty


    Thank you !
    #DecisionOptimization
    #OPLusingCPLEXOptimizer