Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Vrpmtw using Cp

    Posted Tue April 25, 2017 06:07 PM

    Originally posted by: AMM1


    Hi

    i am trying to model vrp with multiple time windowsy model works but its slow and in many cases it gives no solution

    How can i put the time windows constraint in a better way ? In order to make it faster

    the time windows constraint i wrote it as following 

     

    tuple timewin {
    key int l1;  
    key int l2; 
    key int l3;
    key int l4;
    key int l5;
    key int l6;
    key int l7;
    key int l8;
    key int l9;
    //key int l10;}
    timewin lowerbound[d in Demands]=...; 

    (where l1,l2,l3,,,, is the lower bound of the time windows ) 

    tuple timewin2 {
    key int u1;  
    key int u2;
    key int u3;
    key int u4;
    key int u5;
    key int u6;
    key int u7;
    key int u8;
    key int u9;
    //key int u10;} 

    timewin2 upperbound[d in Demands]=...; 

    (where u1,u2,u3,,,, is the upper bound of the time windows )

    and i added the constraint:

    upperbound[d].u1 >=startOf(visit[d])>= lowerbound[d].l1   ||  upperbound[d].u2>=startOf(visit[d])>= lowerbound[d].l2 || upperbound[d].u3>=startOf(visit[d])>=lowerbound[d].l3||upperbound[d].u4 >=startOf(visit[d])>= lowerbound[d].l4   || upperbound[d].u5>=startOf(visit[d])>= lowerbound[d].l5 || upperbound[d].u6>=startOf(visit[d])>=lowerbound[d].l6||upperbound[d].u7>=startOf(visit[d])>=lowerbound[d].l7|| upperbound[d].u8>=startOf(visit[d])>=lowerbound[d].l8|| upperbound[d].u9>=startOf(visit[d])>=lowerbound[d].l9;                   

    Note:    not all the clients have 9 time windows ; but i duplicated the last time window for  all of those who dont have 9 time windows so that i can write the tuple in the data file.   

      


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Vrpmtw using Cp

    Posted Wed April 26, 2017 03:44 AM

    Originally posted by: PhilippeLaborie


    Instead of logical constraints, I think you should better use the forbidExtent constraints together with a step function representing the time-windows. And you do not need this fixed number of time-windows. Here is an example:
     

    tuple TimeWindow { int s; int e; }
    {TimeWindow} TimeWindows = ...; // Example TimeWindows = { <10,20>, <30,35> };
    
    tuple Step { int v; key int x; };
    sorted {Step} Steps = 
       { <0, w.s> | w in TimeWindows } union 
       { <1, w.e> | w in TimeWindows };
    
    // Value of the step function is 1 inside time windows, 0 outside
    stepFunction ForbiddenTimes = stepwise (s in Steps) { s.v -> s.x; 0 };
    
    subject to {
      // ...
      forbidExtent(visit, ForbiddenTimes);
    }
    

    Philippe


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Vrpmtw using Cp

    Posted Wed April 26, 2017 06:53 AM

    Originally posted by: AMM1


    hello  me philippe ;

    thank you for your reply 

    but i still have problem is that i have 100 clients with each have different number of time windows

    some have 6 ,7,8,9 time windows

    so how can i do the above for 100 clients?


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Vrpmtw using Cp

    Posted Wed April 26, 2017 07:23 AM

    Originally posted by: PhilippeLaborie


    I don't think it is a problem, you can use an array of step functions indexed by the clients:
     

    tuple TimeWindow { int s; int e; }
    {TimeWindow} TimeWindows[d in Demands] = ...; 
    // Example: TimeWindows = [ { <10,20>, <30,35> }, { <0,25> } ];
    
    tuple Step { int v; key int x; };
    sorted {Step} Steps[d in Demands] = 
       { <0, w.s> | w in TimeWindows[d] } union 
       { <1, w.e> | w in TimeWindows[d] };
    
    // Value of the step function is 1 inside time windows, 0 outside
    stepFunction ForbiddenTimes[d in Demands] = stepwise (s in Steps[d]) { s.v -> s.x; 0 };
    
    subject to {
      // ...
      forall(d in Demands) {
        forbidExtent(visit[d], ForbiddenTimes[d]);
      }
    }
    

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: Vrpmtw using Cp

    Posted Wed April 26, 2017 10:04 AM

    Originally posted by: AMM1


    THANK you mr philippe it worked :)

    but the solutions i got still so bad ( they are  worse than the results i got before )

    and i still have alot of problems give me no solutions.

    so can  conclude that CP is not suitable for solving this problem ? or the code can be modified .


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: Vrpmtw using Cp

    Posted Wed April 26, 2017 10:12 AM

    Originally posted by: PhilippeLaborie


    Not necessarily. Could you post your complete model, possibly together with a small instance where the search does not find a solution ?

     


    #DecisionOptimization
    #OPLusingCPOptimizer