Skip to content

Return To Start

The Return To Start feature allows a resource to return to its start location after visiting a node and before visiting a subsequent node. This feature can be used in pick-up and delivery problems, or in situations where a resource has to return to its start location after each visit, such as reloading goods before visiting another node.


Overview


Advantages

  • Relaxes the work for the optimizer by defining Return2Start nodes instead of load and capacities for the nodes
  • Allows for predefined time for a resource to spend at the start location before moving on to the next route

Implementation

Here is an example of how to implement the "Return2Start" feature in code:

private static void addNodes(IOptimization opti) {

    /*
     * As returning home does not count as route termination, the Resource has to
     * stay for a predefined time at the start location after a node visit before
     * moving on to the next route.
     */

    Duration intermediateStayAtHomeDuration = Duration.ofMinutes(20);

    // Define the OpeningHours of the nodes
    List<IOpeningHours> weeklyOpeningHours = new ArrayList<>();
    weeklyOpeningHours
        .add(new OpeningHours(ZonedDateTime.of(2020, MAY.getValue(), 6, 8, 0, 0, 0, ZoneId.of("Europe/Berlin")),
            ZonedDateTime.of(2020, MAY.getValue(), 6, 17, 0, 0, 0, ZoneId.of("Europe/Berlin"))));

    weeklyOpeningHours
        .add(new OpeningHours(ZonedDateTime.of(2020, MAY.getValue(), 7, 8, 0, 0, 0, ZoneId.of("Europe/Berlin")),
            ZonedDateTime.of(2020, MAY.getValue(), 7, 17, 0, 0, 0, ZoneId.of("Europe/Berlin"))));

    Duration visitDuration = Duration.ofMinutes(20);

    int importance = 1;

    // Define some Nodes to be visited
    INode koeln = new TimeWindowGeoNode("Koeln", 50.9333, 6.95, weeklyOpeningHours, visitDuration, importance);
    koeln.setIsReturnStart(intermediateStayAtHomeDuration);
    opti.addElement(koeln);

    INode essen = new TimeWindowGeoNode("Essen", 51.45, 7.01667, weeklyOpeningHours, visitDuration, importance);
    essen.setIsReturnStart(intermediateStayAtHomeDuration);
    opti.addElement(essen);

    INode dueren = new TimeWindowGeoNode("Dueren", 50.8, 6.48333, weeklyOpeningHours, visitDuration, importance);
    dueren.setIsReturnStart(intermediateStayAtHomeDuration);
    opti.addElement(dueren);
}

In this example, the intermediateStayAtHomeDuration variable is used to define the amount of time a resource should stay at the start location before moving on to the next route. The setIsReturnStart() method is then used on each node to specify that the resource should return to the start location before visiting that node.

Result

This is a single route result of the output of an optimization run using the Return2Start feature.

----------------------- -----------------------------------
--------------------- ROUTES ------------------------------
---------------------- ------------------------------------

-----------------------------------------------------------
Route information
...
Resource               : Jack from Aachen
Alternate destination  : false
Closed route           : false
...
-----------------------------------------------------------
Route cost             : 555.9835637275354
Route time       [min] : 509
Transit time     [min] : 389
Productive. time [min] : 120
...
Route Distance   [km]  : 513.561
Route Emission [kgCO2] : 193.61
...
Start Id               : Jack from Aachen
Termination Id         : ---

0.0 Wuppertal / Geo  / Arrival: 06.05.2020 09:11:40 (Europe/Berlin) , Departure: 06.05.2020 09:31:40 (Europe/Berlin) / Duration: 20 [min] / Driving: 71.67 [min], 94.602 [km]
0.1 Wuppertal -> Jack from Aachen / Geo  / Arrival: 06.05.2020 10:42:50 (Europe/Berlin) , Departure: 06.05.2020 11:02:50 (Europe/Berlin) / Duration: 20 [min] / Driving: 71.17 [min], 93.938 [km]
0.2 Essen / Geo  / Arrival: 06.05.2020 12:18:16 (Europe/Berlin) , Departure: 06.05.2020 12:38:16 (Europe/Berlin) / Duration: 20 [min] / Driving: 75.44 [min], 99.58 [km]
0.3 Essen -> Jack from Aachen / Geo  / Arrival: 06.05.2020 13:53:14 (Europe/Berlin) , Departure: 06.05.2020 14:13:14 (Europe/Berlin) / Duration: 20 [min] / Driving: 74.97 [min], 98.957 [km]
0.4 Koeln / Geo  / Arrival: 06.05.2020 15:01:13 (Europe/Berlin) , Departure: 06.05.2020 15:21:13 (Europe/Berlin) / Duration: 20 [min] / Driving: 47.99 [min], 63.34 [km]
0.5 Koeln -> Jack from Aachen / Geo  / Arrival: 06.05.2020 16:09:03 (Europe/Berlin) , Departure: 06.05.2020 16:29:03 (Europe/Berlin) / Duration: 20 [min] / Driving: 47.84 [min], 63.142 [km]

ViolationSumary: 
Cost TotalSum: 555.9835637275354,Cost Distance: 513.5617401164243,Cost RouteTime: 42.421823611111115

Between adjacent nodes, an autogenerated Return2Start node is added.

For example:

0.1 Wuppertal -> Jack from Aachen / Geo  / Arrival: 06.05.2020 10:42:50 (Europe/Berlin) , Departure: 06.05.2020 11:02:50 (Europe/Berlin) / Duration: 20 [min] / Driving: 71.17 [min], 93.938 [km]

After visiting the node Wuppertal, the resource "Jack from Aachen" has to return to its start/home, stay for 20 minutes, and proceed to the next node (Essen).


Example

Find Return2Start example on GitHub: ReturnStartExample.


Agreement

For reading our license agreement and for further information about license plans, please visit www.dna-evolutions.com.


Authors

A product by dna-evolutions ©