Record Class SolutionSpec

java.lang.Object
java.lang.Record
com.graphhopper.jsprit.core.problem.solution.spec.SolutionSpec
Record Components:
routes - the list of route specifications

public record SolutionSpec(List<RouteSpec> routes) extends Record
Specifies a complete solution.

This is pure data - no actual Solution, Route, or Activity objects are referenced. The spec is materialized into a real solution when building against a VRP.

Unassigned jobs are derived during materialization: any job in the VRP that is not referenced in any route spec is considered unassigned.

  • Constructor Details

    • SolutionSpec

      public SolutionSpec(List<RouteSpec> routes)
      Creates an instance of a SolutionSpec record class.
      Parameters:
      routes - the value for the routes record component
  • Method Details

    • of

      public static SolutionSpec of(RouteSpec... routes)
      Creates a solution spec with the given routes.
    • of

      public static SolutionSpec of(List<RouteSpec> routes)
      Creates a solution spec with the given routes.
    • empty

      public static SolutionSpec empty()
      Creates an empty solution spec (all jobs unassigned).
    • from

      public static SolutionSpec from(VehicleRoutingProblemSolution solution)
      Extracts a solution spec from an existing solution.

      This allows reusing a solution's structure as an initial solution for another VRP run or a modified problem.

      Parameters:
      solution - the solution to extract from
      Returns:
      a spec representing the solution's structure
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • routes

      public List<RouteSpec> routes()
      Returns the value of the routes record component.
      Returns:
      the value of the routes record component