Class VehicleImpl.Builder

java.lang.Object
com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl.Builder
Enclosing class:
VehicleImpl

public static class VehicleImpl.Builder extends Object
Builder that builds the vehicle.

By default, earliestDepartureTime is 0.0, latestDepartureTime is Double.MAX_VALUE, it returns to the depot and its VehicleType is the DefaultType with typeId equal to 'default' and a capacity of 0.

Author:
stefan
  • Method Details

    • setType

      public VehicleImpl.Builder setType(VehicleType type)
      Sets the VehicleType.
      Parameters:
      type - the type to be set
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if type is null
    • setUserData

      public VehicleImpl.Builder setUserData(Object userData)
      Sets user specific domain data associated with the object.

      The user data is a black box for the framework, it only stores it, but never interacts with it in any way.

      Parameters:
      userData - any object holding the domain specific user data associated with the object.
      Returns:
      builder
    • setReturnToDepot

      public VehicleImpl.Builder setReturnToDepot(boolean returnToDepot)
      Sets the flag whether the vehicle must return to depot or not.

      If returnToDepot is true, the vehicle must return to specified end-location. If you omit specifying the end-location, vehicle returns to start-location (that must to be set). If you specify it, it returns to specified end-location.

      If returnToDepot is false, the end-location of the vehicle is endogenous.

      Parameters:
      returnToDepot - true if vehicle need to return to depot, otherwise false
      Returns:
      this builder
    • setStartLocation

      public VehicleImpl.Builder setStartLocation(Location startLocation)
      Sets start location.
      Parameters:
      startLocation - start location
      Returns:
      start location
    • setEndLocation

      public VehicleImpl.Builder setEndLocation(Location endLocation)
    • setEarliestStart

      public VehicleImpl.Builder setEarliestStart(double earliest_startTime)
      Sets earliest-start of vehicle which should be the lower bound of the vehicle's departure times.
      Parameters:
      earliest_startTime - the earliest start time / departure time of the vehicle at its start location
      Returns:
      this builder
    • setLatestArrival

      public VehicleImpl.Builder setLatestArrival(double latest_arrTime)
      Sets the latest arrival at vehicle's end-location which is the upper bound of the vehicle's arrival times.
      Parameters:
      latest_arrTime - the latest arrival time of the vehicle at its end location
      Returns:
      this builder
    • addAllSkills

      public VehicleImpl.Builder addAllSkills(Collection<String> skills)
    • addSkill

      public VehicleImpl.Builder addSkill(String skill)
    • build

      public VehicleImpl build()
      Builds and returns the vehicle.

      if VehicleType is not set, default vehicle-type is set with id="default" and capacity=0

      if startLocationId || locationId is null (=> startLocationCoordinate || locationCoordinate must be set) then startLocationId=startLocationCoordinate.toString() and locationId=locationCoordinate.toString() [coord.toString() --> [x=x_val][y=y_val])

      if endLocationId is null and endLocationCoordinate is set then endLocationId=endLocationCoordinate.toString()

      if endLocationId==null AND endLocationCoordinate==null then endLocationId=startLocationId AND endLocationCoord=startLocationCoord Thus endLocationId can never be null even returnToDepot is false.

      Returns:
      vehicle
      Throws:
      IllegalArgumentException - if both locationId and locationCoord is not set or (endLocationCoord!=null AND returnToDepot=false) or (endLocationId!=null AND returnToDepot=false)
    • newInstance

      public static VehicleImpl.Builder newInstance(String vehicleId)
      Returns new instance of vehicle builder.
      Parameters:
      vehicleId - the id of the vehicle which must be a unique identifier among all vehicles
      Returns:
      vehicle builder
    • newInstance

      public static VehicleImpl.Builder newInstance(Vehicle baseVehicle)
      Returns new instance of vehicle builder and initializes every attribute with a attributes of baseVehicle
      Parameters:
      baseVehicle - base vehicle that is used to initialize the vehicle builder
      Returns:
      this builder
    • addSkills

      public VehicleImpl.Builder addSkills(Skills skills)
    • setBreak

      public VehicleImpl.Builder setBreak(Break aBreak)