Skip to content

Optimization Solution Comparison Tool

In logistics and route optimization, an automatically generated solution may appear suboptimal to human evaluators. While the optimizer considers complex constraints (e.g., time windows, skill requirements, visitor restrictions), customers tend to prefer geographically short and visually clean routes.

Common Customer Concerns

  • Unexpected geographical crossings: Routes may not always follow the shortest path due to constraints.
  • Route splitting: The optimizer may schedule work into multiple routes instead of a single one to prevent overtime.

The Optimization Solution Comparison Tool helps customers evaluate an optimization result by:

  1. Modifying an existing solution (e.g., swapping the order of two nodes, moving nodes to other routes).
  2. Comparing the original and modified solution, analyzing key differences.
  3. Providing a cost analysis to determine which solution is more optimal.

Overview


Problem Statement

Even though the optimizer finds the mathematically best solution, customers may perceive it differently. This tool allows users to test modifications and analyze their impact.

Example concerns:

  • "Why does the route cross this region multiple times?"
  • "Can't the optimizer keep all jobs in a single route?"
  • "Would swapping two locations reduce travel time?"

By using this tool, customers can modify a solution based on their intuition and then compare it with the optimizer's result.

Example

Please visit our GitHub-Page for Node Exchange Example and Node Move Example.

(If you are new to JOpt-TourOptimizer, please also read our page on setting up your first optimization.)


How the Comparison Works

The Optimization Solution Comparison Tool allows users to apply modifications to an existing solution and generate a detailed comparison report.

  1. Modify the optimization result (e.g., swap the visit order of two locations).
  2. Run a comparison analysis between the original and modified results.
  3. Analyze the trade-offs, such as distance reduction vs. potential constraint violations (e.g., late arrivals).
  4. Generate a detailed report, listing cost differences and constraint violations.

Use Case: Geographical Crossing Issue

Let's assume we run an optimization, and the result shows a geographical issue:

  • The optimizer schedules Duisburg before Krefeld, even though swapping them would reduce travel distance.
  • Customers may question why Duisburg is visited first when geographically, it seems better to go to Krefeld first.

Original Route (Before Modification)

  • Duisburg is visited before Krefeld.
  • Total distance: 272 km.
  • No late violations.

Original Optimization Result:

Placeholder for Original Route

Modified Route (After Swapping Duisburg & Krefeld)

  • Total distance: 238 km (34 km saved).
  • New issue: Late arrival at Duisburg (24.5 minutes).

Modified Optimization Result:

Placeholder for Modified Route

Comparison Summary

Metric Original Route Modified Route Difference
Total Distance (km) 272 km 238 km -34 km
Late Violations 0 min 24.5 min +24.5 min
Overall abstract Cost 306.71 316.39 +9.68

Result:
The optimizer's original solution is better because it avoids late violations, despite the longer travel distance.


Implementation Guide

1. Modify an Existing Optimization Result

To modify a result, use exchangeNodes to swap the order of two locations:

static IOptimizationResult exchangeNodes(IOptimization opti, String nodeOneId, String nodeTwoId)
        throws InterruptedException, ExecutionException, InvalidLicenceException, ConvertException,
        SerializationException, IOException {

    IModificationTask moveTask = new ExchangeOptimizableNodesModificationTask(nodeOneId, nodeTwoId);

    List<IModificationTask> tasks = new ArrayList<>();
    tasks.add(moveTask);

    return CompareResultExampleOptimization.applyTasksAndCreateModResult(opti, tasks);
}

This exchanges Duisburg and Krefeld, altering the original route.


2. Generate the Modified Optimization Result

After an optimization run is completed, modify the original result:

static IOptimizationResult createModResult(IOptimization opti, IOptimizationResult orgResult)
        throws InterruptedException, ExecutionException, InvalidLicenceException, ConvertException,
        SerializationException, IOException {

    // Modify result by swapping Duisburg and Krefeld
    IOptimizationResult modResult = exchangeNodes(opti, "Krefeld", "Duisburg");

    // Print results
    System.out.println("\n\n\n#########################  RESULT ORG  #########################\n\n\n");
    System.out.println(orgResult);

    System.out.println("\n\n\n#########################  RESULT MOD  #########################\n\n\n");
    System.out.println(modResult);

    return modResult;
}

3. Compare the Original and Modified Solution

The compareResults function evaluates both solutions:

static void compareResults(IOptimization opti, IOptimizationResult orgResult, IOptimizationResult modResult)
        throws ResultStructureNotMatchingException {

    // Compare
    Optional<JobAdvantageResult> comparisonResultOptional = JobAdvantagesController.compare(orgResult, modResult);

    if (comparisonResultOptional.isPresent()) {
        JobAdvantageResult comparisonResult = comparisonResultOptional.get();

        ICostAdvantagesInterpreter myInterpreter = new CostAdvantageInterpreter();

        System.out.println("\n\n\n#########################  COMPARISON RESULT  #########################\n\n\n");
        System.out.println(myInterpreter.generateTextReport(comparisonResult));

    } else {
        System.out.println("Comparison failed");
    }
}

Comparison Report Example

After running the comparison, the report summarizes key differences:

#########################  COMPARISON RESULT  #########################

1) =========== JOB - RESULT ==================
Original Cost: 306.71
Modified Cost: 316.39
Difference   : +9.68
Result       : Original job has lower cost.

2) =========== JOB - Violation Summaries ==================
Original Route: No late violations.
Modified Route: 1 late violation at Duisburg (24.5 minutes).

3) =========== Route Differences ==================
- Distance Reduced: 34 km saved.
- Late Violation: +24.5 minutes at Duisburg.

Next Steps:

  • Try modifying different node visit orders.
  • Compare route splits and work distribution changes.
  • Optimize based on real-world constraints such as lateness penalties vs. travel distance.

Closing Words

This tool is a powerful way to fine-tune optimizer results and provide customers with valuable insights. It ensures that route optimizations are both mathematically sound and understandable to human users.

Key Takeaways:

  • The Optimization Solution Comparison Tool helps analyze modifications.
  • It can convince customers that the optimizer's decision is correct.
  • If the modified solution is better, it may indicate insufficient computation time in the original optimization.
  • Customers can adjust optimizer settings based on insights from the comparison.

Authors

A product by DNA Evolutions ©.