DNA //evolutions

Advanced Examples (JOpt.TourOptimizer)

This package contains advanced, feature-focused examples for JOpt.TourOptimizer. The intent is to help you identify which of your real-world business use cases can be covered by the product features and how to model them cleanly.

There is no required order. You can start with the feature that matches your current problem class and then branch out into adjacent topics (skills, territories, relations, PND, etc.).

Before you start

How to run an example

All examples are plain Java classes with a main(...) method (or an equivalent entrypoint). Typical ways to run:

  1. Open the repository in your IDE (e.g., IntelliJ, Eclipse etc.).
  2. Navigate to an example package under .../examples/advanced/....
  3. Run the example class (Run ▶).

Many examples subscribe to optimization event streams (progress, status, warnings, errors). If you are integrating into services or UIs, these subscriptions are the recommended entry points for telemetry and control flows.

Advanced feature index

Advanced package root: https://github.com/DNA-Evolutions/Java-TourOptimizer-Examples/tree/master/src/main/java/com/dna/jopt/touroptimizer/java/examples/advanced

PackageWhat it demonstratesExamples and deep dives
alternatedestinationAlternate start/end locations for routes (alternate destination).AlternateDestinationExample.java · AlternateDestinationExample.md
autofilterAutomatic pre-filtering of nodes that are very likely infeasible (time windows, skills, etc.) to speed up optimization.AutoFilterLateExample.java · AutoFilterParticularNodeExample.java · AutoFilter.md · ref · ref
clusteringClustering-based construction of an initial solution (city-to-city, inner-city, keeping clusters during optimization).ClusteringCityToCityExample.java · ClusteringCityToCityKeepClustersForOptimizationExample.java · +1 more · Clustering.md · ref
co2emissionMinimize CO₂ emissions by defining resource emission factors and optimizing accordingly.CO2EmissionOptimizationExample.java · CO2EmissionOptimization.md · ref
conditionBinding and excluding resources for nodes; skills/type constraints including expertise levels and cost models.MandatoryResourceConditionExample.java · PreferredResourceConditionExample.java · +5 more · BindingExcludingResourceCondition.md · ResourceType.md · ref
constraintaliasidConstraint Alias IDs to model teams and group-based mandatory assignment rules.ResourceConstraintAliasIdExample.java · ResourceConstraintAliasId.md
extrainfoAttach structured extra information to nodes/resources (e.g., store JSON-encoded POJOs).ExtraInfoExample.java · NodeExtraInfo.java · +1 more · ExtraInfo.md
firstlastnodeInfluence first/last placement using importance values (soft steering, not hard fixing).FirstLastNodeExample.java · FirstLastNode.md
includevisitdurationArrival windows vs finish-within windows: include visit duration into time windows.IncludeVisitDurationExample.java · IncludeVisitDuration.md
jointvisitdurationReduce total service time for colocated nodes via joint visit duration.JointVisitDurationExample.java · JointVisitDuration.md
looprunRun optimization stages in loops to implement external convergers or stop criteria.RunOptimizationInLoopExample.java · RunOptimizationInLoop.md
openclosedrouteOpen vs closed routes: end at last node vs return to home.OpenClosedRouteExample.java · OpenClosedRoute.md
openlocationUse Open Location Codes (Plus Codes) instead of latitude/longitude.OptimizationWithOpenLocationCodesExample.java · LatLon2PlusCodeBackAndForthExample.java · OpenLocationCode.md · ref
overnightstayMulti-day routing with overnight stays (“stay out”) and stay policies.OvernightStayExample.java · OvernightStay.md
performancemodePerformance mode for faster optimization on easy/low-restriction instances.PerformanceModeExample.java · PerformanceModeBigOptiExample.java · PerformanceMode.md · ref
pickupanddeliveryPickup & Delivery (PND): classic PND, fuzzy fulfillment, timed loads, flex loads, manufacturing planning, report extraction.PNDSimpleExample.java · PNDSimpleFuzzyExample.java · +8 more · PND.md · ref
progressfrequencyProgress reporting frequency and requesting progress snapshots at arbitrary times.ChangeOnProgressDefaultFrequencyExample.java · RequestOnProgressViaExternalTimeExample.java · OptimizationProgress.md
readoutfullprogressExtract full progress KPIs from the progress object (manual vs ParsedProgress util).ReadOutFullProgressExample.java · ReadOutFullProgressWithUtilExample.java · ReadOutFullProgress.md
relationshipNode relations: same route/visitor, different route/visitor, and relative time window relations; can be combined.SameRouteRelationExample.java · SameVisitorRelationExample.java · +5 more · Relations.md
requestresultRequest an intermediate best-so-far result while the optimization is still running.RequestResultExample.java · RequestResult.md
return2startReturn2Start: force intermediate returns to the resource home between visits (with dwell time).ReturnStartExample.java · ReturnStart.md · ref
visitdurationefficiencyResource visit duration efficiency: faster/slower resources, minimum visit duration caps, fixed-duration nodes.ResourceVisitDurationEfficiencyExample.java · ResourceVisitDurationEfficiency.md
waitonearlyarrivalAllow working immediately on early arrival, but enforce waiting for the first node of a route.WaitOnEarlyArrivalFirstNodeExample.java · WaitOnEarlyArrivalFirstNode.md
zonecodeDefine territories via ZoneCodes / ZoneNumbers; territories can vary per WorkingHours; border nodes can have multiple codes.UKPostCodeExample.java · ZoneNumberConstraintExample.java · ZoneConde.md · ref
zonecrossingPenalize crossings between zones (bridges/tunnels) to prevent zig-zag routes across costly borders.BridgeTunnelCrossingZoneNumberConstraintExample.java · BridgeTunnelCrossingZoneNumberConstraint.md · ref

Guidance on selecting the right feature

If your main pain is runtime

  • Start with AutoFilter (remove infeasible nodes early) and Performance Mode (reduced genetic operator set).
  • If your instance grows large, evaluate Clustering construction for better initial solutions and faster convergence.

If you need strong business rules (structural feasibility)

  • Use Relations for coupling nodes across route/resource/time.
  • Use ZoneCodes for territories (hard or soft) and ZoneCrossing to discourage expensive boundary crossings.
  • Use Return2Start or OvernightStay to model operationally mandatory depot returns or multi-day tours.

If you optimize logistics flows, not just routes

  • Use Pickup & Delivery (PND) when feasibility depends on load state (underload/overload), timed transport, or production planning.

Notes on documentation files

For many packages, this repository includes a dedicated Markdown document placed alongside the example sources. These documents are intended to be copied into other environments and provide:

  • conceptual explanation of the feature,
  • implementation guidance and modeling patterns,
  • links back to the corresponding Java example(s) and official documentation.

If you are maintaining an internal knowledge base, these Markdown files can be used directly as reference pages.


Authors

A product by DNA Evolutions
https://www.dna-evolutions.com