Decision Optimization

Decision Optimization

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

 View Only
  • 1.  VRP with multiple time windows in CP

    Posted Tue February 01, 2022 09:58 AM
    Hi everyone,

    I am looking for a prototype of the VRP with multiple time windows in CP. For instance a store receives deliveries on Mondays from 12:00 am- 5:00 am or 9:00 pm-11:59 pm.  

    I have already a prototype for a VRP in CP with one time-window, but I don't know how to change it to handle a double time-window, because I am a neophyte in CP.

    Thanks.

    ------------------------------
    Nourredine Hail
    ------------------------------

    #DecisionOptimization


  • 2.  RE: VRP with multiple time windows in CP

    Posted Thu February 03, 2022 09:47 AM
    I figured this out. No help is needed. Thanks.

    ------------------------------
    Nourredine Hail
    ------------------------------



  • 3.  RE: VRP with multiple time windows in CP

    Posted Thu February 03, 2022 12:53 PM
    Edited by System Admin Fri January 20, 2023 04:40 PM
    Hi

    a model with only one time window could be 

    using CP;
    
    range rTrucks = 1 .. 10;
    range rVisits = 1 .. 100;
    
    tuple TW{ int v;  int s; int e; }
    TW tw[v in rVisits] = <v, v, 2 * v> ;
    
    dvar interval visit[t in rTrucks, v in rVisits] optional in tw[v].s .. tw[v].e size 1;
    
    constraints{
      forall(t in rTrucks) 
      	noOverlap( all(v in rVisits) visit[t, v]);
    }​

    then you can extend it to multiple time windows for each visit

    using CP;
    
    range rTrucks = 1 .. 10;
    range rVisits = 1 .. 100;
    
    tuple TW{ int v;  int s; int e; }
    {TW} tws with v in rVisits = ...;//read all possible time windows 
    
    dvar interval visit[t in rTrucks, v in rVisits] optional size 1;
    dvar interval twVisit[t in rTrucks, tw in tws] optional in tw.s .. tw.e size 1 ;
    
    constraints{
      forall(t in rTrucks) 
      	noOverlap( all(v in rVisits) visit[t, v]);
      	
      forall(t in rTrucks, v in rVisits)
        alternative(visit[t,v], all( <v,s,e> in tws) twVisit[t, <v,s,e>]);
    }​


    ------------------------------
    David Gravot
    ------------------------------



  • 4.  RE: VRP with multiple time windows in CP

    Posted Thu February 03, 2022 01:53 PM

    Salut David,

     

    Merci beaucoup.

     

    I like your approach; mine was using startOf and endOf and 2 mutual exclusive Boolean decision variables, one for each Time Window.

     

    Have a great night.

     

    Cheers.

     


     

    Description: Description: email-signature-image_0014_H_COC-CTR_Surprint_1_-TO-3__BIL_ENG.png

    Nourredine Hail, PhD in Applied Mathematics
    Senior Operations Research & Data Scientist

    Data Analytics Governance team
    Canadian Tire Corporation
    2111 Steeles Avenue East, Brampton, ON, L6T4L5
    Phone: 905.792.5983  
    nourredine.hail@cantire.com

    "Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young."  Henry Ford