Version 1

    Hello! I don't really know where to put this, it's a Drools question but it has to do with Business Resource Planner.

     

    I basically want to create a rule that helps me solve VRP in a certain way (I'm optimizing for distance):

     

    - I want it to have Time Windows, these rules work OK:

     

    // TIME WINDOW &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 
    rule "arrivalAfterDueTime"
    salience -1
        when
            $customer: TimeWindowedCustomer(dueTime < arrivalTime, $dueTime : dueTime, $arrivalTime : arrivalTime)
        then
            scoreHolder.addHardConstraintMatch(kcontext, (int)(10*($dueTime - $arrivalTime.intValue())) );
    end
    // ******************
    
    rule "Delivery in time window"
    salience -2
     when 
      $customer:TimeWindowedCustomer(nextCustomer != null,$arrivalTimeCustomer: arrivalTime)
      $actual:TimeWindowedCustomer(previousStandstill==$customer,$arrivalTimeCustomer>arrivalTime, $arrival:arrivalTime )
     then 
      scoreHolder.addHardConstraintMatch(kcontext, (int)(10*($arrival-$arrivalTimeCustomer)) );
    end
    

     

    But I want the truck to choose to deliver on more than one option of a day. Example: Time window is 8:00 am to 2:00 pm Monday through Thursday, so if a solution comes up that delivers on 3:00 pm on Monday, I want to have the rule consider Tuesday at 8:00 am instead if it's a better choice, and switch route order accordingly between days without going off the time windows.

     

    I hope I explained myself well, I don't know it this is the right forum for this topic, if not please forgive me and point me in the right direction.

     

    Thank you very much!