Class VehicleRoutingProblem.Builder
- Enclosing class:
VehicleRoutingProblem
- Author:
- stefan schroeder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAllJobs(Collection<? extends Job> jobs) Adds a collection of jobs.addAllVehicles(Collection<? extends Vehicle> vehicles) Adds a collection of vehicles.addInitialRouteSpec(RouteSpec spec) Adds a single route specification.Adds an initial vehicle route.Adds a collection of initial vehicle routes.addJob(AbstractJob job) Adds a job which is either a service or a shipment.Adds a job which is either a service or a shipment.addLocation(String locationId, Coordinate coordinate) Deprecated.addNonJobActivities(Collection<? extends AbstractActivity> nonJobActivities) addVehicle(AbstractVehicle vehicle) Adds a vehicle.addVehicle(Vehicle vehicle) Adds a vehicle.build()Builds theVehicleRoutingProblem.Returns an unmodifiable collection of already added jobs.Gets an unmodifiable collection of already added vehicles.Gets an unmodifiable collection of already added vehicle-types.Returns the unmodifiable map of collected locations (mapped by their location-id).Returns the locations collected SO FAR by this builder.Returns a new instance of this builder.setActivityCosts(VehicleRoutingActivityCosts activityCosts) Sets the activity-costs.setFleetSize(VehicleRoutingProblem.FleetSize fleetSize) Sets the type of fleetSize.setInitialRouteSpecs(List<RouteSpec> specs) Sets the initial route specifications, replacing any previously added specs.setJobActivityFactory(JobActivityFactory jobActivityFactory) Sets routing costs.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
newInstance
Returns a new instance of this builder.- Returns:
- builder
-
getLocationMap
Returns the unmodifiable map of collected locations (mapped by their location-id).- Returns:
- map with locations
-
getLocations
Returns the locations collected SO FAR by this builder.Locations are cached when adding a shipment, service, depot, vehicle.
- Returns:
- locations
-
setRoutingCost
Sets routing costs.- Parameters:
costs- the routingCosts- Returns:
- builder
- See Also:
-
setJobActivityFactory
-
setFleetSize
Sets the type of fleetSize.FleetSize is either FleetSize.INFINITE or FleetSize.FINITE. By default it is FleetSize.INFINITE.
- Parameters:
fleetSize- the fleet size used in this problem. it can either be FleetSize.INFINITE or FleetSize.FINITE- Returns:
- this builder
-
addJob
Adds a job which is either a service or a shipment.Note that job.getId() must be unique, i.e. no job (either it is a shipment or a service) is allowed to have an already allocated id.
- Parameters:
job- job to be added- Returns:
- this builder
- Throws:
IllegalStateException- if job is neither a shipment nor a service, or jobId has already been added.
-
addJob
Adds a job which is either a service or a shipment.Note that job.getId() must be unique, i.e. no job (either it is a shipment or a service) is allowed to have an already allocated id.
- Parameters:
job- job to be added- Returns:
- this builder
- Throws:
IllegalStateException- if job is neither a shipment nor a service, or jobId has already been added.
-
addInitialVehicleRoute
Adds an initial vehicle route.- Parameters:
route- initial route- Returns:
- the builder
-
addInitialVehicleRoutes
Adds a collection of initial vehicle routes.- Parameters:
routes- initial routes- Returns:
- the builder
-
setInitialRouteSpecs
Sets the initial route specifications, replacing any previously added specs.The specs will be materialized into actual routes during
build(). This is the preferred way to define initial (locked) routes as it avoids the chicken-and-egg problem of needing a VRP to create routes.Note: Jobs in these routes will be locked and cannot be removed by the algorithm. If you want a starting solution that can be fully optimized, use
algorithm.addInitialSolution()instead.- Parameters:
specs- the route specifications- Returns:
- the builder
-
addInitialRouteSpec
Adds a single route specification.The spec will be materialized into an actual route during
build().- Parameters:
spec- the route specification- Returns:
- the builder
-
addVehicle
Adds a vehicle.- Parameters:
vehicle- vehicle to be added- Returns:
- this builder
-
addVehicle
Adds a vehicle.- Parameters:
vehicle- vehicle to be added- Returns:
- this builder
-
setActivityCosts
Sets the activity-costs.By default it is set to zero.
- Parameters:
activityCosts- activity costs of the problem- Returns:
- this builder
- See Also:
-
addNonJobActivities
public VehicleRoutingProblem.Builder addNonJobActivities(Collection<? extends AbstractActivity> nonJobActivities) -
build
Builds theVehicleRoutingProblem.If
VehicleRoutingTransportCostsare not set,CrowFlyCostsis used.- Returns:
VehicleRoutingProblem
-
addLocation
@Deprecated public VehicleRoutingProblem.Builder addLocation(String locationId, Coordinate coordinate) Deprecated. -
addAllJobs
Adds a collection of jobs.- Parameters:
jobs- which is a collection of jobs that subclasses Job- Returns:
- this builder
-
addAllVehicles
Adds a collection of vehicles.- Parameters:
vehicles- vehicles to be added- Returns:
- this builder
-
getAddedVehicles
Gets an unmodifiable collection of already added vehicles.- Returns:
- collection of vehicles
-
getAddedVehicleTypes
Gets an unmodifiable collection of already added vehicle-types.- Returns:
- collection of vehicle-types
-
getAddedJobs
Returns an unmodifiable collection of already added jobs.- Returns:
- collection of jobs
-