Class PDPSolution

java.lang.Object
org.ddolib.examples.pdp.PDPSolution

public class PDPSolution extends Object
Represents a solution to a Pickup and Delivery Problem (PDP) instance.

This class stores the sequence of visited nodes (solution), the total cost or value of the solution, and a reference to the original PDPProblem instance.

The toString() method provides a detailed textual representation of the solution, including for each node whether it is a pickup, a delivery, or an unrelated node, as well as the vehicle content after visiting that node.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int[]
    The sequence of nodes representing the solution, including pickups, deliveries, and unrelated nodes.
    double
    The total value (cost or distance) of the solution.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PDPSolution(PDPProblem problem, int[] solution, double value)
    Constructs a PDP solution with the given problem, solution sequence, and value.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a human-readable representation of the solution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • solution

      public int[] solution
      The sequence of nodes representing the solution, including pickups, deliveries, and unrelated nodes.
    • value

      public double value
      The total value (cost or distance) of the solution.
  • Constructor Details

    • PDPSolution

      public PDPSolution(PDPProblem problem, int[] solution, double value)
      Constructs a PDP solution with the given problem, solution sequence, and value.
      Parameters:
      problem - the PDP problem instance
      solution - the sequence of nodes representing the solution
      value - the total cost or distance of the solution
  • Method Details

    • toString

      public String toString()
      Returns a human-readable representation of the solution.

      Each line represents a node visited in order. For pickups and deliveries, the output indicates the change in vehicle content and the associated pickup/delivery relationship. For unrelated nodes, only the node and current vehicle content are shown.

      Overrides:
      toString in class Object
      Returns:
      a formatted string showing the solution path and vehicle contents