Breaks scheduled at wrong time in solution

Hi

I have added scheduled breaks to my problem and while they do add ok and the breaks do finish at the right time (i.e start time + duration) they start at the wrong time - i.e. at the start of the shift.

Here is a short block of code used to set the break which is at 10am for 30minutes

Double breakStart = 36000; // 10am in seconds since start of day
Double breakDuration = 1800; // 30 minutes
Break sBreak = Break.Builder.newInstance(“Break-”+Double.toString(breakStart))
.setName(“Break”)
.addTimeWindow(breakStart, breakStart+180.0) // allow a 5 minute variance on start of break
.setServiceTime(breakDuration)
.build();
vehicleBuilder.setBreak(sBreak);
VehicleImpl vehicle = vehicleBuilder.build();
vrpBuilder.addVehicle(vehicle);

I also tried .setTimeWindow() in the code above but it made no difference.

Im sure it must be something simple I’m doing wrong but my hair is almost gone and I’m no further ahead :slight_smile:

Here is the solution printout showing that the break finishes at the correct time but starts at the wrong time ala 08:30 which is the start of the shift.

| route | vehicle | activity | job | arrTime | endTime | costs
±--------±---------------------±----------------------±----------------±----------------±----------------±----------------+

| 1 | 352964050794131 | start | - | undef | 08:30 | 0 |

| 1 | 352964050794131 | break | Break-36000.0 | 08:30 | 10:30 | 0 |

| 1 | 352964050794131 | pickupShipment | 895_2 | 10:31 | 10:31 | 1466 |

| 1 | 352964050794131 | pickupShipment | 895_4 | 10:31 | 10:31 | 1466 |

| 1 | 352964050794131 | pickupShipment | 895_3 | 10:31 | 10:31 | 1466 |

| 1 | 352964050794131 | pickupShipment | 895_6 | 10:31 | 10:31 | 1466 |

| 1 | 352964050794131 | deliverShipment | 895_6 | 10:33 | 10:44 | 3487 |

| 1 | 352964050794131 | pickupShipment | 898_8 | 10:48 | 12:00 | 6117 |

| 1 | 352964050794131 | pickupShipment | 898_9 | 12:00 | 12:00 | 6117 |

| 1 | 352964050794131 | deliverShipment | 898_9 | 12:03 | 12:13 | 8778 |

| 1 | 352964050794131 | deliverShipment | 895_3 | 12:17 | 12:27 | 12529 |

| 1 | 352964050794131 | deliverShipment | 895_4 | 12:49 | 13:01 | 32493 |

| 1 | 352964050794131 | deliverShipment | 895_2 | 13:43 | 13:58 | 59691 |

| 1 | 352964050794131 | deliverShipment | 898_8 | 13:58 | 14:08 | 59691 |

| 1 | 352964050794131 | end | - | 14:08 | undef | 59691 |

±-------------------------------------------------------------------------------------------------------------------------------+

08:30 is the arrival time; 10:00 is the start time; and 10:30 is the end time of the break.

Do the shipments bear time windows?

Yes they do. The pickup and one delivery are before mid-day. The rest of the deliveries are at any time.

what about earliest start time?

Did you set the cost param for waiting time (in VehicleType)? If not try to assign a reasonable value so that waiting will be penalyzed. This should also penalyze waiting for a break (which I always find funny anyway …).

1 Like

Hi Stefan

That pretty well fixed it. For a break from 0900 to 0930 it started the break at 0855 and finished at 0930.

Could you offer guidance on what a reasonable value for cost per waiting time is or how to derive a reasonable value?

I tried values of 3 and 10 with no seeming difference. Can I assume that this cost is used in conjunction with cost per distance and therefore should be higher than any given cost per distance value in order to get priority ?

regards
Grant

1 Like

I usually derive such values from actual driver costs, e.g. cost per hour --> wage.

Got it.

Thanks Stefan and others who replied. Much appreciated.

regards
Grant