Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  VRP problem under soft time window

    Posted 06/26/19 07:56 AM

    Originally posted by: 18125514


    The main problem is the setting of the soft time window.The formula is as follows

         forall(i in A,j in N:j!=i,k in Trucks)

         ct16:x[i][j][k]==1 =>s[j]==maxl(0,(w[j][k]-b[j])*p[1][j],(a[j]-w[j][k])*p[2][j]);

    x[i][j][k] is the decision variable

    a[j] and b[j] is the time window

    p is the unit penalty cost

    s is the penalty cost

    Founded, found that the model is poorly accurate and inefficient.

    I wonder if it is accurate to establish the above time window? How to change this model

    Thanks.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: VRP problem under soft time window

    Posted 06/28/19 12:23 AM

    Originally posted by: EdKlotz


    First of all, have you confirmed that the model is "poorly accurate and inefficient" because of these time window constraints?   In other words, if you filter the time window constraints out by commenting them out in your code, does the model solve much faster?

     

    These logical constraint operators like => and max are nice in that they enable you to express complex constraints relatively easily.   But they ultimately need to be translated or linearized, and that process has to consider the most general case possible.   So, if the resulting formulation is problematic, maybe you should formulate some or all of these constraints yourself, since you can tailor the formulation more specifically to your particular constraints.    For example, with

    s[j]==maxl(0,(w[j][k]-b[j])*p[1][j],(a[j]-w[j][k])*p[2][j]);

    Assuming s[j] has a lower bound of 0 in its initial declaration, and that it appears in no other constraint (which I suspect is true), you can reformulate this as

    s[j] >= (w[j][k]-b[j])*p[1][j])

    s[j] >= (a[j]-w[j][k])*p[2][j])

    You could then handle the => parts as

    x[i][j][k]==1 => s[j] >= (w[j][k]-b[j])*p[1][j])

    x[i][j][k]==1 => s[j] >= (a[j]-w[j][k])*p[2][j])

     

    At first glance, this seems worse, in that you've replaced a single statement with 4 separate ones.   But if the translation of the single statement requires a large number of constraints, and possibly some tolerances to enforce equality constraints that are on the receiving end of the => operator, you may find this works better.   You could take it one step further and linearize the => constraints as well, assuming you can derive a reasonably small big M value as a proxy for infinite bounds.

     

    If you are still having trouble, maybe export an LP file and upload it here, or post some of the constraints in the LP file associated with these constraints.

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: VRP problem under soft time window

    Posted 06/29/19 11:17 AM

    Originally posted by: 18125514


    I think the main problem is the use of =>.

    Use in the model in load weight constraints and time window constraints =>.

    I feel that there may be some problems in this logic.

    MOD as below:

    /*********************************************
     * OPL 12.9.0.0 Model
     * Author: 86131
     * Creation Date: 2019年5月24日 at 下午10:17:34
     *********************************************/

    int     n       = ...;
    int     K       = ...;
    {int}   A  = asSet(1..n);//配送网点与客户点
    {int}   N  = asSet(2..n);
    {int}   Trucks  = asSet(1..K);//一组同质的车辆(人员) 
    float   T  =...;//单次收派的最大工作时间
    float   Z  =...;//一个极大正数
    float        Q[Trucks] = ...;//载重量上限
    float        d[N] = ...;//收件重量
    float        v[N] = ...;//派件重量

    float CC[1..n*n*K] = ...;
    float c[i in 1..n, j in 1..n,k in 1..K] = CC[k+K*(j-1)+n*K*(i-1)];//行走成本(时间)
    float        t[N][Trucks] =...;//客户 i的服务时间
    float        a[N] = ...;//客户 i要求的最早到达时间
    float        b[N] = ...;//客户 i要求的最晚到达时间*/
    dvar boolean x[A][A][Trucks];//车辆 k 是否访问过客户 i 和客户 j 所构成的弧
    dvar float+ q[A][Trucks];//车辆 k 离开客户i时所装载重量
    dvar float+ w[A][Trucks];//收派员 k 达到客户 i的时间,原文文中是k,这里符号冲突了

    dexpr float time[k in Trucks] =sum(i,j in A:j!=i)(c[i][j][k]*x[i][j][k])+sum(i in A,j in N:j!=i)(t[j][k]*x[i][j][k]);
    /************************************************/
    // Objective
    minimize sum (i,j in A:i!=j,k in Trucks) c[i][j][k]*x[i][j][k];
    subject to {
        forall(i in N)
          ct1:sum(j in A:j!=i,k in Trucks)(x[i][j][k])==1;
        forall(j in N)
          ct2:sum(i in A:i!=j,k in Trucks)(x[i][j][k])==1;
        forall(k in Trucks)
          ct3:sum(j in N)(x[1][j][k])==1;      
        forall(k in Trucks)
          ct4:sum(i in N)(x[i][1][k])==1; 
        forall(j in N)
          ct5:sum(k in Trucks)(x[1][j][k])<=1;  
        forall(i in N)
          ct6:sum(k in Trucks)(x[i][1][k])<=1;
        forall(k in Trucks,h in N)
          ct7:sum(i in A:i!=h)(x[i][h][k])-sum(j in A:j!=h)(x[h][j][k])==0;//改了A
        forall(k in Trucks)
          ct8:time[k]<=T;
        forall(k in Trucks) 
          ct9:q[1][k]==sum(j in N)(v[j]*sum(i in A:i!=j)(x[i][j][k])); 
           forall(i in A,j in N:j!=i,k in Trucks)
          ct10:x[i][j][k]==1=>(q[j][k]-q[i][k])==-(d[j]+v[j]);//不用考虑回原点 
        //forall(i in A,j in N:j!=i,k in Trucks)
          //ct10:(q[j][k]-q[i][k])>=-(d[j]+v[j])-Z*(1-x[i][j][k]);//不用考虑回原点  
        forall(i in A,j in A:j!=i,k in Trucks)
          ct11:x[i][j][k]==1=>q[i][k]<=Q[k];//之前有问题,q意思是离开客户i的载重量   
        forall(i in N,j in A:j!=i,k in Trucks)
          ct12:x[i][j][k]==1=>maxl(0,-d[i])<=q[i][k];      
        forall(j in N,k in Trucks)
             ct13:x[1][j][k]==1=>w[j][k] >= w[1][k]+c[1][j][k];//这里 w[1][k]表示离开原点1的时间     
        forall(i in N,j in N:j!=i,k in Trucks)
            ct14:x[i][j][k]==1=>w[j][k] >= w[i][k]+t[i][k]+c[i][j][k];   
         //forall(j in N,k in Trucks)
             //ct13:w[j][k] >= w[1][k]+c[1][j][k]-(1-x[1][j][k])*Z;//这里 w[1][k]表示离开原点1的时间 
         //forall(i in N,j in N:j!=i,k in Trucks)
             //ct14:w[j][k] >= w[i][k]+t[i][k]+c[i][j][k]-(1-x[i][j][k])*Z;//这里 w[1][k]表示离开原点1的时间  
        forall(i in A,j in N:j!=i,k in Trucks)
             ct15:x[i][j][k]==1=>a[j]<=w[j][k]; 
         forall(i in A,j in N:j!=i,k in Trucks)
             ct16:x[i][j][k]==1=>w[j][k]<=b[j];
             ct18:sum(i in A,k in Trucks)x[i][i][k]==0;    
      }

    Personal feeling problems mainly appear in the load weight constraint ct10-ct12 and time window constraint ct13-ct16.

    I don't know if => is correct, if not, how to represent the above constraints.

    In addition, with similar constraints such as adding an infinite number Z, the model does not apply.

    Thanks for solving my problem.


    #CPLEXOptimizers
    #DecisionOptimization