basics
Class VehicleRoutingProblem.Builder

java.lang.Object
  extended by basics.VehicleRoutingProblem.Builder
Enclosing class:
VehicleRoutingProblem

public static class VehicleRoutingProblem.Builder
extends java.lang.Object

Builder to build the routing-problem.

Author:
stefan schroeder

Constructor Summary
VehicleRoutingProblem.Builder()
           
 
Method Summary
 VehicleRoutingProblem.Builder addAllJobs(java.util.Collection<Job> jobs)
          Adds a collection of jobs.
 VehicleRoutingProblem.Builder addAllVehicles(java.util.Collection<Vehicle> vehicles)
          Adds a collection of vehicles.
 VehicleRoutingProblem.Builder addJob(Job job)
          Adds a job which is either a service or a shipment.
 VehicleRoutingProblem.Builder addLocation(java.lang.String id, Coordinate coord)
           
 void addProblemConstraint(VehicleRoutingProblem.Constraint constraint)
           
 VehicleRoutingProblem.Builder addService(Service service)
          Adds a service to jobList.
 VehicleRoutingProblem.Builder addVehicle(Vehicle vehicle)
          Adds a vehicle.
 VehicleRoutingProblem.Builder addVehicleType(VehicleType type)
          Adds a vehicleType.
 VehicleRoutingProblem build()
          Builds the VehicleRoutingProblem.
 java.lang.String createLocation(double x, double y)
          Create a location (i.e.
 java.util.Collection<Service> getAddedServices()
          Gets an unmodifiable collection of already added services.
 java.util.Collection<Vehicle> getAddedVehicles()
          Gets an unmodifiable collection of already added vehicles.
 java.util.Map<java.lang.String,Coordinate> getLocationMap()
          Returns the unmodifiable map of locations (mapped by their id).
 Locations getLocations()
          Returns the locations collected by this builder.
static VehicleRoutingProblem.Builder newInstance()
          Returns a new instance of this builder.
 VehicleRoutingProblem.Builder setActivityCosts(VehicleRoutingActivityCosts activityCosts)
          Sets the activityCostFunction that considers also activities on a vehicle-route.
 VehicleRoutingProblem.Builder setFleetComposition(VehicleRoutingProblem.FleetComposition fleetComposition)
          Sets the fleetComposition.
 VehicleRoutingProblem.Builder setFleetSize(VehicleRoutingProblem.FleetSize fleetSize)
          Sets the type of fleetSize.
 VehicleRoutingProblem.Builder setNeighborhood(Neighborhood neighborhood)
          Sets the neighborhood.
 VehicleRoutingProblem.Builder setRoutingCost(VehicleRoutingTransportCosts costs)
          Sets routing costs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VehicleRoutingProblem.Builder

public VehicleRoutingProblem.Builder()
Method Detail

newInstance

public static VehicleRoutingProblem.Builder newInstance()
Returns a new instance of this builder.

Returns:
builder

createLocation

public java.lang.String createLocation(double x,
                                       double y)
Create a location (i.e. coordinate) and returns the key of the location which is Coordinate.toString().

Parameters:
x -
y -
Returns:
locationId
See Also:
Coordinate

getLocationMap

public java.util.Map<java.lang.String,Coordinate> getLocationMap()
Returns the unmodifiable map of locations (mapped by their id).

Returns:

getLocations

public Locations getLocations()
Returns the locations collected by this builder.

Locations are cached when adding a shipment, service, depot, vehicle.

Returns:
locations

addProblemConstraint

public void addProblemConstraint(VehicleRoutingProblem.Constraint constraint)

setRoutingCost

public VehicleRoutingProblem.Builder setRoutingCost(VehicleRoutingTransportCosts costs)
Sets routing costs.

Parameters:
costs -
Returns:
builder
See Also:
VehicleRoutingTransportCosts

setFleetSize

public VehicleRoutingProblem.Builder setFleetSize(VehicleRoutingProblem.FleetSize fleetSize)
Sets the type of fleetSize.

FleetSize is either FleetSize.INFINITE or FleetSize.FINITE

Parameters:
fleetSize -
Returns:

setFleetComposition

public VehicleRoutingProblem.Builder setFleetComposition(VehicleRoutingProblem.FleetComposition fleetComposition)
Sets the fleetComposition.

FleetComposition is either FleetComposition.HETEROGENEOUS or FleetComposition.HOMOGENEOUS

Parameters:
fleetComposition -
Returns:

addService

public VehicleRoutingProblem.Builder addService(Service service)
Adds a service to jobList.

If jobList already contains service, a warning message is printed, and the existing job will be overwritten.

Parameters:
service -
Returns:

addJob

public VehicleRoutingProblem.Builder addJob(Job job)
Adds a job which is either a service or a shipment.

Parameters:
job -
Returns:
Throws:
java.lang.IllegalStateException - if job is neither a shipment or a service.

addVehicle

public VehicleRoutingProblem.Builder addVehicle(Vehicle vehicle)
Adds a vehicle.

Parameters:
vehicle -
Returns:

addVehicleType

public VehicleRoutingProblem.Builder addVehicleType(VehicleType type)
Adds a vehicleType.

Parameters:
type -
Returns:
builder

setNeighborhood

public VehicleRoutingProblem.Builder setNeighborhood(Neighborhood neighborhood)
Sets the neighborhood.

Parameters:
neighborhood -
Returns:

setActivityCosts

public VehicleRoutingProblem.Builder setActivityCosts(VehicleRoutingActivityCosts activityCosts)
Sets the activityCostFunction that considers also activities on a vehicle-route.

Here you can consider missed time-windows for example. By default, this is set to a DefaultVehicleActivityCostFunction.

Parameters:
activityCosts -
Returns:
See Also:
VehicleRoutingTransportCosts, DefaultVehicleRouteCostFunction

build

public VehicleRoutingProblem build()
Builds the VehicleRoutingProblem.

If VehicleRoutingTransportCosts are not set, CrowFlyCosts is used.

Returns:
VehicleRoutingProblem

addLocation

public VehicleRoutingProblem.Builder addLocation(java.lang.String id,
                                                 Coordinate coord)

addAllJobs

public VehicleRoutingProblem.Builder addAllJobs(java.util.Collection<Job> jobs)
Adds a collection of jobs.

Parameters:
jobs -
Returns:

addAllVehicles

public VehicleRoutingProblem.Builder addAllVehicles(java.util.Collection<Vehicle> vehicles)
Adds a collection of vehicles.

Parameters:
vehicles -
Returns:

getAddedVehicles

public java.util.Collection<Vehicle> getAddedVehicles()
Gets an unmodifiable collection of already added vehicles.

Returns:
collection of vehicles

getAddedServices

public java.util.Collection<Service> getAddedServices()
Gets an unmodifiable collection of already added services.

Returns:
collection of services