Return to start

This guide covers return to start, also called Return2Start, for resources that have to go back to their start location between visits, for example to reload. It shows the Java call, the JSON field and how the returns appear in the result, and it is for developers who model such depot returns with JOpt. It uses the nodes, resources and WorkingHours introduced in Basic elements.
What it does
Return to start lets a resource return to its start location after visiting a node and before visiting a subsequent node. The resource stays at the start location for a predefined time and then moves on to the next node. The return does not end the route: it is an intermediate stop inside the same route.
Return to start differs from a closed route. A closed route returns to the start location once, at the end of the route. Return to start inserts returns between visits, and it also works on open routes: ReturnStartExample sets its routes open with setIsClosedRoute(false) and still gets the intermediate returns.
When to use it
Use return to start when a resource has to go back to its base between tasks, for example:
- reloading or restocking goods, tools or spare parts;
- pickup and delivery patterns with a return after each delivery;
- regulated operations where vehicles return to a controlled yard between jobs;
- medical or lab logistics with handling steps at the depot;
- quality checks, paperwork or scanning that happen at the base;
- battery charging or an equipment swap at the depot.
When reloading is the only reason to go back, return to start relaxes the work for the optimizer: you define return-to-start nodes instead of loads and capacities for the nodes.
How to use it
Java
Return to start is set per node with setIsReturnStart, which takes the stay at the start location as a Duration. ReturnStartExample sets it on each of its nodes; the code below shows three of them:
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 code, intermediateStayAtHomeDuration is the time the resource stays at the start location before it moves on to the next node. setIsReturnStart on a node makes the resource return to the start location after visiting that node.
JSON input for the REST service
In the JSON input of the REST service, a node sets the stay at the start location in its field returnStartDuration. The API reference shows the node schema.
Read the result
One route from the output of an optimization run with return to start; the dates, times and costs are sample values:
----------------------- -----------------------------------
--------------------- 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" returns to its start location, stays there for 20 minutes and then drives to the next node, Essen.
Properties
Return to start has no property key of its own. The stay at the start location is set per node: with setIsReturnStart in Java and with returnStartDuration in JSON.
Limits
- Return to start does not track loads. If you need several goods types, partial fulfillment, timed loads or flexible loads, model them with pickup and delivery.
- Every return adds a drive to the start location. A return after many nodes can increase the travel time a lot and reduce the number of visits per day, so set it only on the nodes that need it.
- The stay at the start location takes working time. A stay that is too long reduces the visits that fit into a day and can make the problem infeasible.
Related examples
- Return to start example: the example explained, with modeling patterns and common pitfalls
- ReturnStartExample.java: the source code on GitHub
Related pages
- Pickup and delivery: loads and capacities for goods that the optimizer tracks
- Overnight stay: resources that stay at designated nodes between working days
- Basic elements: nodes, resources and WorkingHours
- DNA Evolutions website: the license agreement and further information about license plans
Authors
DNA Evolutions GmbH
Added: 2026-01-03 (JOpt core 7.5.2-j17) | Last updated: 2026-10-19
Reactive events and streams
How to follow a JOpt optimization run through its RxJava event streams, from progress and status to node filtering and results, and how they fit Spring WebFlux
Skill with expertise and cost model
How the cost models of a skill condition with expertise levels decide between resources whose level differs from the level a node requires.