Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Vehicle routing constraint

  • 1.  Vehicle routing constraint

    Posted Mon July 02, 2018 10:33 AM

    Originally posted by: snpny


    Hi,

    Im new in CPLEX and I am tyring to run a vehicle routing problem on CPLEX, but feasible solution cant be found, probably because of mistakes in writing subtour elemination constraints and so I have unfeasible solution. I will be really appreciate if you can help me!

    Here is one troubled constrain;

    forall (i in busstops, j in busstops: j!=i)
        c06:
        u[i]-u[j]+ Q*x[<i,j>] + 
    
    (x[<j,i>]*(Q-q[i]-q[j])) <= Q-q[j];
    
    CPLEX solve this constraint for node {2,3} and {2,4} as follows;   
    
    u[2]+u[3]*(-1)+x[<2,3>]*30+0 <= (-6)+30
    u[2]+u[4]*(-1)+x[<2,4>]*30+0 <= (-7)+30

    As it is seen the bold part always calculated as zero. I have same results with other similar constraints. 

     

    Im also attaching paramteres and objective function.

    int n=...;

     range routingpoints= 1..n+1;
     range busstops= 2..n;
     tuple node {
         int i;
         int j;
      }
     setof (node) nodes= {<i,j> | i,j in routingpoints : i!=j};

     float p=...;
     float f=...;
     float Q=...;
     float D=...;
     float q[routingpoints]=...;
     float d[nodes]=...;
     dvar boolean x[nodes];
     dvar int+ m;
     dvar int+ u[busstops];
     dvar int+ v[busstops];
     minimize sum(<i,j> in nodes) d[<i,j>]*x[<i,j>]*p + f*m;

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Vehicle routing constraint

    Posted Mon July 02, 2018 12:09 PM

    Could it be that Q-q[i]-q[j] is always 0? Right now that is the only reason I can imagine for the behavior you report.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Vehicle routing constraint

    Posted Mon July 02, 2018 01:03 PM

    Originally posted by: snpny


    thanks your answer, but no :( for all arc (2-3,2-4,2-5,...,5-4) it gives zero which is definitely not true. 

    I dont want to make it more complicated but, when I deleting one multiplier from bold part, I dont know why but it works. I mean;

    u[i]-u[j]+ Q*x[<i,j>] + 
    (Q-q[i]-q[j]) <= Q-q[j];
    u[2]+u[3]*(-1)+x[<2,3>]*30+
    (-6)+(-5)+30 <= (-6)+30
    

    or 

    u[i]-u[j]+ Q*x[<i,j>] + x[<j,i>] <= Q-q[j];

    u[2]+u[3]*(-1)+x[<2,3>]*30+
    x[<3,2>] <= (-6)+30
    

    I really dont understand what is wrong with multiplication..


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Vehicle routing constraint

    Posted Mon July 02, 2018 03:39 PM

    I tried to reproduce your problem here but failed. Whatever I do, I get the expected constraints.

    Can you attach your full .mod and full .dat so that I can do here exactly what you are doing?

    Also, how do you print out these constraints?


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Vehicle routing constraint

    Posted Tue July 03, 2018 08:19 AM

    Originally posted by: snpny


    Here is my full .mod and .dat files with formulation .pdf 

    Thanks in advance!

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Vehicle routing constraint

    Posted Tue July 03, 2018 08:50 AM

    I still cannot reproduce the problem here. Constraint c06 has references to x({2,3}) as well as x({3,2}) for me. Just as expected. Here is one of these constraints from the exported LP file:

     c06(2)(3): 30 x({2,3}) + 19 x({3,2}) + u(2) - u(3) <= 24

    So again, how exactly do you print out these constraints?


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Vehicle routing constraint

    Posted Tue July 03, 2018 09:30 AM

    Originally posted by: snpny


    Here is how I print out c06 constraint. As you can see it gives always zero directly, I dont know if it is due to the some general setting of my model, or smt else 


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Vehicle routing constraint

    Posted Wed July 11, 2018 02:46 AM

    Originally posted by: snpny


    Do you have any idea regarding what I finally send?


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Vehicle routing constraint

    Posted Wed July 11, 2018 04:51 AM

    This is a bug in the IDE. The constraint displayed in the table is actually not what CPLEX uses internally. The "0" you see there is the actual solution value of the term, not the term itself.

    Can you try to use "Launch" instead of "Solve" or "Debug"? That should display the correct constraint then.

    Another workaround is to export the LP file and then just look at that file (not as convenient as the IDE but on the plus side you will see exactly what the solver will see).


    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Vehicle routing constraint

    Posted Wed July 11, 2018 08:53 AM

    Originally posted by: snpny


    Thank you, now I can see the correct constraint.

    The problem now is that, CPLEX does not return a feasible solution although my problem setup is quite simplistic. It always returns a relaxed solution which generally not logic. Please let me know what do you think?


    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Vehicle routing constraint

    Posted Thu July 12, 2018 04:31 AM

    If you see that your problem is infeasible then you should analyze that infeasibility and figure out what CPLEX thinks is wrong (see the corresponding chapter in the user manual).


    #CPLEXOptimizers
    #DecisionOptimization