Class VehicleRoutingProblem

java.lang.Object
com.graphhopper.jsprit.core.problem.VehicleRoutingProblem

public class VehicleRoutingProblem extends Object
Contains and defines the vehicle routing problem.

A routing problem is defined as jobs, vehicles, costs and constraints.

To construct the problem, use VehicleRoutingProblem.Builder. Get an instance of this by using the static method VehicleRoutingProblem.Builder.newInstance().

By default, fleetSize is INFINITE, transport-costs are calculated as euclidean-distance (CrowFlyCosts), and activity-costs are set to zero.

Author:
stefan schroeder
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getFleetSize

      public VehicleRoutingProblem.FleetSize getFleetSize()
      Returns type of fleetSize, either INFINITE or FINITE.

      By default, it is INFINITE.

      Returns:
      either FleetSize.INFINITE or FleetSize.FINITE
    • getJobs

      public Map<String,Job> getJobs()
      Returns the unmodifiable job map.
      Returns:
      unmodifiable jobMap
    • getJobsWithLocation

      public Collection<Job> getJobsWithLocation()
    • getJobsInclusiveInitialJobsInRoutes

      public Map<String,Job> getJobsInclusiveInitialJobsInRoutes()
    • getInitialVehicleRoutes

      public Collection<VehicleRoute> getInitialVehicleRoutes()
      Returns a copy of initial vehicle routes.
      Returns:
      copied collection of initial vehicle routes
    • getTypes

      public Collection<VehicleType> getTypes()
      Returns the entire, unmodifiable collection of types.
      Returns:
      unmodifiable collection of types
      See Also:
    • getVehicles

      public Collection<Vehicle> getVehicles()
      Returns the entire, unmodifiable collection of vehicles.
      Returns:
      unmodifiable collection of vehicles
      See Also:
    • getTransportCosts

      public VehicleRoutingTransportCosts getTransportCosts()
      Returns routing costs.
      Returns:
      routingCosts
      See Also:
    • getActivityCosts

      public VehicleRoutingActivityCosts getActivityCosts()
      Returns activityCosts.
    • getAllLocations

      public Collection<Location> getAllLocations()
    • getActivities

      public List<AbstractActivity> getActivities(Job job)
      Parameters:
      job - for which the corresponding activities needs to be returned
      Returns:
      associated activities
    • getNuActivities

      public int getNuActivities()
      Returns:
      total number of activities
    • getJobActivityFactory

      public JobActivityFactory getJobActivityFactory()
      Returns:
      factory that creates the activities associated to a job
    • copyAndGetActivities

      public List<AbstractActivity> copyAndGetActivities(Job job)
      Parameters:
      job - for which the corresponding activities needs to be returned
      Returns:
      a copy of the activities that are associated to the specified job
    • getVehicleIndex

      public int getVehicleIndex(Vehicle vehicle)
      Returns the index of the given vehicle within this VRP.

      Note: Indices are VRP-specific. A vehicle can have different indices in different VRP instances. This is the preferred way to get vehicle indices instead of using HasIndex.getIndex().

      Parameters:
      vehicle - the vehicle
      Returns:
      the index (1-based), or fallback to vehicle.getIndex() if vehicle not found in VRP
    • getJobIndex

      public int getJobIndex(Job job)
      Returns the index of the given job within this VRP.

      Note: Indices are VRP-specific. A job can have different indices in different VRP instances. This is the preferred way to get job indices instead of using HasIndex.getIndex().

      Parameters:
      job - the job
      Returns:
      the index (1-based), or fallback to job.getIndex() if job not found in VRP
    • getVehicleTypeKeyIndex

      public int getVehicleTypeKeyIndex(VehicleTypeKey typeKey)
      Returns the index of the given vehicle type key within this VRP.

      Note: Indices are VRP-specific. A vehicle type key can have different indices in different VRP instances. This is the preferred way to get vehicle type key indices instead of using AbstractVehicle.AbstractTypeKey.getIndex().

      Parameters:
      typeKey - the vehicle type key
      Returns:
      the index (1-based), or fallback to typeKey.getIndex() if not found in VRP
    • getNuVehicleTypeKeys

      public int getNuVehicleTypeKeys()
      Returns the number of vehicle type keys (distinct vehicle types by type, location, time windows).
      Returns:
      number of vehicle type keys
    • getMaxVehicleTypeKeyIndex

      public int getMaxVehicleTypeKeyIndex()
      Returns the maximum vehicle type key index.
      Returns:
      max type key index
    • getVehicleByIndex

      public Vehicle getVehicleByIndex(int index)
      Returns the vehicle at the given index.
      Parameters:
      index - the index (1-based)
      Returns:
      the vehicle, or null if index out of bounds
    • getJobByIndex

      public Job getJobByIndex(int index)
      Returns the job at the given index.
      Parameters:
      index - the index (1-based)
      Returns:
      the job, or null if index out of bounds
    • getNuVehicles

      public int getNuVehicles()
      Returns the number of vehicles (also the max vehicle index).
      Returns:
      number of vehicles
    • getNuJobs

      public int getNuJobs()
      Returns the number of jobs (also the max job index).
      Returns:
      number of jobs