Class VehicleRoutingProblem
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder to build the routing-problem.static enumEnum that characterizes the fleet-size. -
Method Summary
Modifier and TypeMethodDescriptioncopyAndGetActivities(Job job) getActivities(Job job) Returns activityCosts.Returns type of fleetSize, either INFINITE or FINITE.Returns a copy of initial vehicle routes.getJobByIndex(int index) Returns the job at the given index.intgetJobIndex(Job job) Returns the index of the given job within this VRP.getJobs()Returns the unmodifiable job map.intReturns the maximum vehicle type key index.intintReturns the number of jobs (also the max job index).intReturns the number of vehicles (also the max vehicle index).intReturns the number of vehicle type keys (distinct vehicle types by type, location, time windows).Returns routing costs.getTypes()Returns the entire, unmodifiable collection of types.getVehicleByIndex(int index) Returns the vehicle at the given index.intgetVehicleIndex(Vehicle vehicle) Returns the index of the given vehicle within this VRP.Returns the entire, unmodifiable collection of vehicles.intgetVehicleTypeKeyIndex(VehicleTypeKey typeKey) Returns the index of the given vehicle type key within this VRP.toString()
-
Method Details
-
toString
-
getFleetSize
Returns type of fleetSize, either INFINITE or FINITE.By default, it is INFINITE.
- Returns:
- either FleetSize.INFINITE or FleetSize.FINITE
-
getJobs
Returns the unmodifiable job map.- Returns:
- unmodifiable jobMap
-
getJobsWithLocation
-
getJobsInclusiveInitialJobsInRoutes
-
getInitialVehicleRoutes
Returns a copy of initial vehicle routes.- Returns:
- copied collection of initial vehicle routes
-
getTypes
Returns the entire, unmodifiable collection of types.- Returns:
- unmodifiable collection of types
- See Also:
-
getVehicles
Returns the entire, unmodifiable collection of vehicles.- Returns:
- unmodifiable collection of vehicles
- See Also:
-
getTransportCosts
Returns routing costs.- Returns:
- routingCosts
- See Also:
-
getActivityCosts
Returns activityCosts. -
getAllLocations
-
getActivities
- Parameters:
job- for which the corresponding activities needs to be returned- Returns:
- associated activities
-
getNuActivities
public int getNuActivities()- Returns:
- total number of activities
-
getJobActivityFactory
- Returns:
- factory that creates the activities associated to a job
-
copyAndGetActivities
- 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
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
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
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
Returns the vehicle at the given index.- Parameters:
index- the index (1-based)- Returns:
- the vehicle, or null if index out of bounds
-
getJobByIndex
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
-