graphhopper / jsprit

jsprit is a java based, open source toolkit for solving rich vehicle routing problems
https://www.graphhopper.com/open-source/
Apache License 2.0
1.64k stars 605 forks source link

Jobs Cannot Picked up though valid timewindow #535

Open ricardocomfort opened 2 years ago

ricardocomfort commented 2 years ago

Hi everyone,

I am still pretty new to this VRP solution.

Recently , I received lots of issues from the user where many jobs practically can be picked up but somehow according to vrp, the new job is not possibly picked up.

There is one sample, J93569 Input to the VRP : Active Jobs: Shipment-JobID: J93567 NoOfPax: 1, Pickup Stop15029, Drop Stop: 15285, PickUp TimeWindow: (13:51:40 - 14:01:40) ETA Buffer: 10 Delivery-JobID: J93566 Drop Stop: 15274 , Drop Off Time Window (13:52:32 - 14:02:32) ETA Buffer: 10 Delivery-JobID: J93567 Drop Stop: 15285 , Drop Off Time Window (14:06:18 - 14:16:18) ETA Buffer: 10 Shipment-JobID: J93498 NoOfPax: 1, Pickup Stop15295, Drop Stop: 15161, PickUp TimeWindow: (16:00:00 - 16:10:00) ETA Buffer: 10 Shipment-JobID: J93499 NoOfPax: 1, Pickup Stop15161, Drop Stop: 15295, PickUp TimeWindow: (18:30:00 - 18:40:00) ETA Buffer: 10

The new Job Job ID: J93569, Pickup Stop: 15275, Drop Stop: 15285, Pickup time : 2021-12-06T13:54:39+11:00 TimeWindow: (13:54:39 - 14:29:39)

Out put from VRP : Start Time : 1:51:43 PM, Bus stop : 15276 J93567 : pick up → 2:00:54 pm , Bus Stop : 15029 (cost matrix 15276 to 15029 is 551 seconds / 9 minutes 11 seconds ) J93566 : drop off → 2:09:14 pm , Bus Stop : 15274 (cost matrix 15029 to 15274 is 500 / 8 minutes 20 seconds) J93567 : drop off → 2:15:32 pm , bus stop : 15285 (cost matrix 15274 to 15285 is 378 / 6 minutes 18 seconds) J93498 : pick up → 2:27:00 pm - 4 pm , bus stop : 15295 (cost matrix 15285 to 15295 is 688 seconds / 11 minutes 28 seconds) J93499 : pick up → 4.09:07 pm - 6.30 pm, bus stop : 15161 (cost matrix 15295 to 15161 is 547 seconds / 9 minutes 7 seconds) J93498 : drop off → 6:30 pm , bus stop : 15161 (cost matrix 15295 to 15161 is 547 seconds / 9 minutes 7 seconds) J93499 : drop off → 6:39 pm , bus stop : 15295 (cost matrix 15161 to 15295 is 559 seconds / 9 minutes 19 seconds)

The error returned in the code : Job No: J93569Unassigned Job ID :J93569 --> due to : 2 - cannot be visited within time window

By right as per human manual estimation, the job J93569, Pick Up TimeWindow: (13:54:39 - 14:29:39), can be picked up Pick up from Job Id J93567 : 15285 to Job ID J93569 : 15275 → 493 seconds (8 minutes 13 seconds) Drop off to Bus Stop for job id : J93569 : 15275 to 15285 → 488 seconds (8 minutes 8 seconds) Then go to next job id J93498 : Bus Stop : 15285 to 15295 → 688 seconds (11 minutes 28 seconds)

The hard activity constraint is as follows : constraintManager.addConstraint( new HardActivityConstraint(){ @Override public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {

                if ((prevAct instanceof PickupShipment || prevAct instanceof DeliverShipment) 
                    && prevAct.getClass().equals(nextAct.getClass()) 
                    && prevAct.getLocation().equals(nextAct.getLocation()) 
                    && prevAct.getArrTime() == nextAct.getArrTime() 
                    && !prevAct.getLocation().equals(newAct.getLocation())
                ) 
                {
                    return ConstraintsStatus.NOT_FULFILLED;
                }
                return ConstraintsStatus.FULFILLED;
            }                                      
    },com.graphhopper.jsprit.core.problem.constraint.ConstraintManager.Priority.CRITICAL);

J93569 Log.txt