Class VehicleRoute.Builder

java.lang.Object
com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute.Builder
Enclosing class:
VehicleRoute

public static class VehicleRoute.Builder extends Object
Builder that builds the vehicle route.
Author:
stefan
  • Method Details

    • newInstance

      public static VehicleRoute.Builder newInstance(Vehicle vehicle, Driver driver)
      Returns new instance of this builder.

      Construction-settings of vehicleRoute:

      startLocation == vehicle.getStartLocationId()

      endLocation == vehicle.getEndLocationId()

      departureTime == vehicle.getEarliestDepartureTime()

      latestStart == Double.MAX_VALUE

      earliestEnd == 0.0

      Parameters:
      vehicle - employed vehicle
      driver - employed driver
      Returns:
      this builder
    • newInstance

      public static VehicleRoute.Builder newInstance(Vehicle vehicle)
      Returns new instance of this builder.

      Construction-settings of vehicleRoute:

      startLocation == vehicle.getStartLocationId()

      endLocation == vehicle.getEndLocationId()

      departureTime == vehicle.getEarliestDepartureTime()

      latestStart == Double.MAX_VALUE

      earliestEnd == 0.0

      Parameters:
      vehicle - employed vehicle
      Returns:
      this builder
    • setJobActivityFactory

      public VehicleRoute.Builder setJobActivityFactory(JobActivityFactory jobActivityFactory)
    • setDepartureTime

      public VehicleRoute.Builder setDepartureTime(double departureTime)
      Sets the departure-time of the route, i.e. which is the time the vehicle departs from start-location.

      Note that departureTime cannot be lower than earliestDepartureTime of vehicle.

      Parameters:
      departureTime - departure time of vehicle being employed for this route
      Returns:
      builder
      Throws:
      IllegalArgumentException - if departureTime invalid input: '<' vehicle.getEarliestDeparture()
    • addService

      public VehicleRoute.Builder addService(Service service)
      Adds a service to this route. Activity is initialized with .getTimeWindow(). If you want to explicitly set another time window use .addService(Service service, TimeWindow timeWindow)

      This implies that for this service a serviceActivity is created with TourActivityFactory and added to the sequence of tourActivities.

      The resulting activity occurs in the activity-sequence in the order adding/inserting.

      Parameters:
      service - to be added
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if service is null
    • addService

      public VehicleRoute.Builder addService(Service service, TimeWindow timeWindow)
    • addBreak

      @Deprecated public VehicleRoute.Builder addBreak(Break currentbreak)
      Deprecated.
    • addBreak

      @Deprecated public VehicleRoute.Builder addBreak(Break currentbreak, TimeWindow timeWindow)
      Deprecated.
    • addBreak

      public VehicleRoute.Builder addBreak(Break currentbreak, TimeWindow timeWindow, Location location)
    • addPickup

      public VehicleRoute.Builder addPickup(Pickup pickup)
      Adds a pickup to this route.
      Parameters:
      pickup - pickup to be added
      Returns:
      the builder
    • addPickup

      public VehicleRoute.Builder addPickup(Pickup pickup, TimeWindow timeWindow)
    • addDelivery

      public VehicleRoute.Builder addDelivery(Delivery delivery)
      Adds a delivery to this route.
      Parameters:
      delivery - delivery to be added
      Returns:
      the builder
    • addDelivery

      public VehicleRoute.Builder addDelivery(Delivery delivery, TimeWindow timeWindow)
    • addPickup

      public VehicleRoute.Builder addPickup(Shipment shipment)
      Adds a the pickup of the specified shipment.
      Parameters:
      shipment - to be picked up and added to this route
      Returns:
      the builder
      Throws:
      IllegalArgumentException - if method has already been called with the specified shipment.
    • addPickup

      public VehicleRoute.Builder addPickup(Shipment shipment, TimeWindow pickupTimeWindow)
    • addDelivery

      public VehicleRoute.Builder addDelivery(Shipment shipment)
      Adds a the delivery of the specified shipment.
      Parameters:
      shipment - to be delivered and add to this vehicleRoute
      Returns:
      builder
      Throws:
      IllegalArgumentException - if specified shipment has not been picked up yet (i.e. method addPickup(shipment) has not been called yet).
    • addDelivery

      public VehicleRoute.Builder addDelivery(Shipment shipment, TimeWindow deliveryTimeWindow)
    • build

      public VehicleRoute build()
      Builds the route.
      Returns:
      VehicleRoute
      Throws:
      IllegalArgumentException - if there are still shipments that have been picked up though but not delivery.