Google Cloud Optimization V1 Client - Class Vehicle (1.0.2)

Reference documentation and code samples for the Google Cloud Optimization V1 Client class Vehicle.

Models a vehicle in a shipment problem. Solving a shipment problem will build a route starting from start_location and ending at end_location for this vehicle. A route is a sequence of visits (see ShipmentRoute).

Generated from protobuf message google.cloud.optimization.v1.Vehicle

Namespace

Google \ Cloud \ Optimization \ V1

Methods

__construct

Constructor.

Parameters
Name Description
data array

Optional. Data for populating the Message object.

↳ travel_mode int

The travel mode which affects the roads usable by the vehicle and its speed. See also travel_duration_multiple.

↳ route_modifiers RouteModifiers

Optional. A set of conditions to satisfy that affect the way routes are calculated for the given vehicle.

↳ start_location Google\Type\LatLng

Geographic location where the vehicle starts before picking up any shipments. If not specified, the vehicle starts at its first pickup. If the shipment model has duration and distance matrices, start_location must not be specified.

↳ start_waypoint Waypoint

Waypoint representing a geographic location where the vehicle starts before picking up any shipments. If neither start_waypoint nor start_location is specified, the vehicle starts at its first pickup. If the shipment model has duration and distance matrices, start_waypoint must not be specified.

↳ end_location Google\Type\LatLng

Geographic location where the vehicle ends after it has completed its last VisitRequest. If not specified the vehicle's ShipmentRoute ends immediately when it completes its last VisitRequest. If the shipment model has duration and distance matrices, end_location must not be specified.

↳ end_waypoint Waypoint

Waypoint representing a geographic location where the vehicle ends after it has completed its last VisitRequest. If neither end_waypoint nor end_location is specified, the vehicle's ShipmentRoute ends immediately when it completes its last VisitRequest. If the shipment model has duration and distance matrices, end_waypoint must not be specified.

↳ start_tags array

Specifies tags attached to the start of the vehicle's route. Empty or duplicate strings are not allowed.

↳ end_tags array

Specifies tags attached to the end of the vehicle's route. Empty or duplicate strings are not allowed.

↳ start_time_windows array<TimeWindow>

Time windows during which the vehicle may depart its start location. They must be within the global time limits (see ShipmentModel.global_* fields). If unspecified, there is no limitation besides those global time limits. Time windows belonging to the same repeated field must be disjoint, i.e. no time window can overlap with or be adjacent to another, and they must be in chronological order. cost_per_hour_after_soft_end_time and soft_end_time can only be set if there is a single time window.

↳ end_time_windows array<TimeWindow>

Time windows during which the vehicle may arrive at its end location. They must be within the global time limits (see ShipmentModel.global_* fields). If unspecified, there is no limitation besides those global time limits. Time windows belonging to the same repeated field must be disjoint, i.e. no time window can overlap with or be adjacent to another, and they must be in chronological order. cost_per_hour_after_soft_end_time and soft_end_time can only be set if there is a single time window.

↳ travel_duration_multiple float

Specifies a multiplicative factor that can be used to increase or decrease travel times of this vehicle. For example, setting this to 2.0 means that this vehicle is slower and has travel times that are twice what they are for standard vehicles. This multiple does not affect visit durations. It does affect cost if cost_per_hour or cost_per_traveled_hour are specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle is standard, and this multiple is considered 1.0. WARNING: Travel times will be rounded to the nearest second after this multiple is applied but before performing any numerical operations, thus, a small multiple may result in a loss of precision. See also extra_visit_duration_for_visit_type below.

↳ unloading_policy int

Unloading policy enforced on the vehicle.

↳ load_limits array|Google\Protobuf\Internal\MapField

Capacities of the vehicle (weight, volume, # of pallets for example). The keys in the map are the identifiers of the type of load, consistent with the keys of the Shipment.load_demands field. If a given key is absent from this map, the corresponding capacity is considered to be limitless.

↳ cost_per_hour float

Vehicle costs: all costs add up and must be in the same unit as Shipment.penalty_cost. Cost per hour of the vehicle route. This cost is applied to the total time taken by the route, and includes travel time, waiting time, and visit time. Using cost_per_hour instead of just cost_per_traveled_hour may result in additional latency.

↳ cost_per_traveled_hour float

Cost per traveled hour of the vehicle route. This cost is applied only to travel time taken by the route (i.e., that reported in ShipmentRoute.transitions), and excludes waiting time and visit time.

↳ cost_per_kilometer float

Cost per kilometer of the vehicle route. This cost is applied to the distance reported in the ShipmentRoute.transitions and does not apply to any distance implicitly traveled from the arrival_location to the departure_location of a single VisitRequest.

↳ fixed_cost float

Fixed cost applied if this vehicle is used to handle a shipment.

↳ used_if_route_is_empty bool

This field only applies to vehicles when their route does not serve any shipments. It indicates if the vehicle should be considered as used or not in this case. If true, the vehicle goes from its start to its end location even if it doesn't serve any shipments, and time and distance costs resulting from its start --> end travel are taken into account. Otherwise, it doesn't travel from its start to its end location, and no break_rule or delay (from TransitionAttributes) are scheduled for this vehicle. In this case, the vehicle's ShipmentRoute doesn't contain any information except for the vehicle index and label.

↳ route_duration_limit Vehicle\DurationLimit

Limit applied to the total duration of the vehicle's route. In a given OptimizeToursResponse, the route duration of a vehicle is the difference between its vehicle_end_time and vehicle_start_time.

↳ travel_duration_limit Vehicle\DurationLimit

Limit applied to the travel duration of the vehicle's route. In a given OptimizeToursResponse, the route travel duration is the sum of all its transitions.travel_duration.

↳ route_distance_limit DistanceLimit

Limit applied to the total distance of the vehicle's route. In a given OptimizeToursResponse, the route distance is the sum of all its transitions.travel_distance_meters.

↳ extra_visit_duration_for_visit_type array|Google\Protobuf\Internal\MapField

Specifies a map from visit_types strings to durations. The duration is time in addition to VisitRequest.duration to be taken at visits with the specified visit_types. This extra visit duration adds cost if cost_per_hour is specified. Keys (i.e. visit_types) cannot be empty strings. If a visit request has multiple types, a duration will be added for each type in the map.

↳ break_rule BreakRule

Describes the break schedule to be enforced on this vehicle. If empty, no breaks will be scheduled for this vehicle.

↳ label string

Specifies a label for this vehicle. This label is reported in the response as the vehicle_label of the corresponding ShipmentRoute.

↳ ignore bool

If true, used_if_route_is_empty must be false, and this vehicle will remain unused. If a shipment is performed by an ignored vehicle in injected_first_solution_routes, it is skipped in the first solution but is free to be performed in the response. If a shipment is performed by an ignored vehicle in injected_solution_constraint and any related pickup/delivery is constrained to remain on the vehicle (i.e., not relaxed to level RELAX_ALL_AFTER_THRESHOLD), it is skipped in the response. If a shipment has a non-empty allowed_vehicle_indices field and all of the allowed vehicles are ignored, it is skipped in the response.

↳ break_rule_indices array

Deprecated: No longer used. Indices in the break_rule field in the source ShipmentModel. They correspond to break rules enforced on the vehicle. As of 2018/03, at most one rule index per vehicle can be specified.

↳ capacities array<CapacityQuantity>

Deprecated: Use Vehicle.load_limits instead.

↳ start_load_intervals array<CapacityQuantityInterval>

Deprecated: Use Vehicle.LoadLimit.start_load_interval instead.

↳ end_load_intervals array<CapacityQuantityInterval>

Deprecated: Use Vehicle.LoadLimit.end_load_interval instead.

getTravelMode

The travel mode which affects the roads usable by the vehicle and its speed. See also travel_duration_multiple.

Returns
Type Description
int

setTravelMode

The travel mode which affects the roads usable by the vehicle and its speed. See also travel_duration_multiple.

Parameter
Name Description
var int
Returns
Type Description
$this

getRouteModifiers

Optional. A set of conditions to satisfy that affect the way routes are calculated for the given vehicle.

Returns
Type Description
RouteModifiers|null

hasRouteModifiers

clearRouteModifiers

setRouteModifiers

Optional. A set of conditions to satisfy that affect the way routes are calculated for the given vehicle.

Parameter
Name Description
var RouteModifiers
Returns
Type Description
$this

getStartLocation

Geographic location where the vehicle starts before picking up any shipments. If not specified, the vehicle starts at its first pickup.

If the shipment model has duration and distance matrices, start_location must not be specified.

Returns
Type Description
Google\Type\LatLng|null

hasStartLocation

clearStartLocation

setStartLocation

Geographic location where the vehicle starts before picking up any shipments. If not specified, the vehicle starts at its first pickup.

If the shipment model has duration and distance matrices, start_location must not be specified.

Parameter
Name Description
var Google\Type\LatLng
Returns
Type Description
$this

getStartWaypoint

Waypoint representing a geographic location where the vehicle starts before picking up any shipments. If neither start_waypoint nor start_location is specified, the vehicle starts at its first pickup.

If the shipment model has duration and distance matrices, start_waypoint must not be specified.

Returns
Type Description
Waypoint|null

hasStartWaypoint

clearStartWaypoint

setStartWaypoint

Waypoint representing a geographic location where the vehicle starts before picking up any shipments. If neither start_waypoint nor start_location is specified, the vehicle starts at its first pickup.

If the shipment model has duration and distance matrices, start_waypoint must not be specified.

Parameter
Name Description
var Waypoint
Returns
Type Description
$this

getEndLocation

Geographic location where the vehicle ends after it has completed its last VisitRequest. If not specified the vehicle's ShipmentRoute ends immediately when it completes its last VisitRequest.

If the shipment model has duration and distance matrices, end_location must not be specified.

Returns
Type Description
Google\Type\LatLng|null

hasEndLocation

clearEndLocation

setEndLocation

Geographic location where the vehicle ends after it has completed its last VisitRequest. If not specified the vehicle's ShipmentRoute ends immediately when it completes its last VisitRequest.

If the shipment model has duration and distance matrices, end_location must not be specified.

Parameter
Name Description
var Google\Type\LatLng
Returns
Type Description
$this

getEndWaypoint

Waypoint representing a geographic location where the vehicle ends after it has completed its last VisitRequest. If neither end_waypoint nor end_location is specified, the vehicle's ShipmentRoute ends immediately when it completes its last VisitRequest.

If the shipment model has duration and distance matrices, end_waypoint must not be specified.

Returns
Type Description
Waypoint|null

hasEndWaypoint

clearEndWaypoint

setEndWaypoint

Waypoint representing a geographic location where the vehicle ends after it has completed its last VisitRequest. If neither end_waypoint nor end_location is specified, the vehicle's ShipmentRoute ends immediately when it completes its last VisitRequest.

If the shipment model has duration and distance matrices, end_waypoint must not be specified.

Parameter
Name Description
var Waypoint
Returns
Type Description
$this

getStartTags

Specifies tags attached to the start of the vehicle's route.

Empty or duplicate strings are not allowed.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setStartTags

Specifies tags attached to the start of the vehicle's route.

Empty or duplicate strings are not allowed.

Parameter
Name Description
var string[]
Returns
Type Description
$this

getEndTags

Specifies tags attached to the end of the vehicle's route.

Empty or duplicate strings are not allowed.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setEndTags

Specifies tags attached to the end of the vehicle's route.

Empty or duplicate strings are not allowed.

Parameter
Name Description
var string[]
Returns
Type Description
$this

getStartTimeWindows

Time windows during which the vehicle may depart its start location.

They must be within the global time limits (see ShipmentModel.global_* fields). If unspecified, there is no limitation besides those global time limits. Time windows belonging to the same repeated field must be disjoint, i.e. no time window can overlap with or be adjacent to another, and they must be in chronological order. cost_per_hour_after_soft_end_time and soft_end_time can only be set if there is a single time window.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setStartTimeWindows

Time windows during which the vehicle may depart its start location.

They must be within the global time limits (see ShipmentModel.global_* fields). If unspecified, there is no limitation besides those global time limits. Time windows belonging to the same repeated field must be disjoint, i.e. no time window can overlap with or be adjacent to another, and they must be in chronological order. cost_per_hour_after_soft_end_time and soft_end_time can only be set if there is a single time window.

Parameter
Name Description
var array<TimeWindow>
Returns
Type Description
$this

getEndTimeWindows

Time windows during which the vehicle may arrive at its end location.

They must be within the global time limits (see ShipmentModel.global_* fields). If unspecified, there is no limitation besides those global time limits. Time windows belonging to the same repeated field must be disjoint, i.e. no time window can overlap with or be adjacent to another, and they must be in chronological order. cost_per_hour_after_soft_end_time and soft_end_time can only be set if there is a single time window.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setEndTimeWindows

Time windows during which the vehicle may arrive at its end location.

They must be within the global time limits (see ShipmentModel.global_* fields). If unspecified, there is no limitation besides those global time limits. Time windows belonging to the same repeated field must be disjoint, i.e. no time window can overlap with or be adjacent to another, and they must be in chronological order. cost_per_hour_after_soft_end_time and soft_end_time can only be set if there is a single time window.

Parameter
Name Description
var array<TimeWindow>
Returns
Type Description
$this

getTravelDurationMultiple

Specifies a multiplicative factor that can be used to increase or decrease travel times of this vehicle. For example, setting this to 2.0 means that this vehicle is slower and has travel times that are twice what they are for standard vehicles. This multiple does not affect visit durations.

It does affect cost if cost_per_hour or cost_per_traveled_hour are specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle is standard, and this multiple is considered 1.0. WARNING: Travel times will be rounded to the nearest second after this multiple is applied but before performing any numerical operations, thus, a small multiple may result in a loss of precision. See also extra_visit_duration_for_visit_type below.

Returns
Type Description
float

hasTravelDurationMultiple

clearTravelDurationMultiple

setTravelDurationMultiple

Specifies a multiplicative factor that can be used to increase or decrease travel times of this vehicle. For example, setting this to 2.0 means that this vehicle is slower and has travel times that are twice what they are for standard vehicles. This multiple does not affect visit durations.

It does affect cost if cost_per_hour or cost_per_traveled_hour are specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle is standard, and this multiple is considered 1.0. WARNING: Travel times will be rounded to the nearest second after this multiple is applied but before performing any numerical operations, thus, a small multiple may result in a loss of precision. See also extra_visit_duration_for_visit_type below.

Parameter
Name Description
var float
Returns
Type Description
$this

getUnloadingPolicy

Unloading policy enforced on the vehicle.

Returns
Type Description
int

setUnloadingPolicy

Unloading policy enforced on the vehicle.

Parameter
Name Description
var int
Returns
Type Description
$this

getLoadLimits

Capacities of the vehicle (weight, volume, # of pallets for example).

The keys in the map are the identifiers of the type of load, consistent with the keys of the Shipment.load_demands field. If a given key is absent from this map, the corresponding capacity is considered to be limitless.

Returns
Type Description
Google\Protobuf\Internal\MapField

setLoadLimits

Capacities of the vehicle (weight, volume, # of pallets for example).

The keys in the map are the identifiers of the type of load, consistent with the keys of the Shipment.load_demands field. If a given key is absent from this map, the corresponding capacity is considered to be limitless.

Parameter
Name Description
var array|Google\Protobuf\Internal\MapField
Returns
Type Description
$this

getCostPerHour

Vehicle costs: all costs add up and must be in the same unit as Shipment.penalty_cost.

Cost per hour of the vehicle route. This cost is applied to the total time taken by the route, and includes travel time, waiting time, and visit time. Using cost_per_hour instead of just cost_per_traveled_hour may result in additional latency.

Returns
Type Description
float

setCostPerHour

Vehicle costs: all costs add up and must be in the same unit as Shipment.penalty_cost.

Cost per hour of the vehicle route. This cost is applied to the total time taken by the route, and includes travel time, waiting time, and visit time. Using cost_per_hour instead of just cost_per_traveled_hour may result in additional latency.

Parameter
Name Description
var float
Returns
Type Description
$this

getCostPerTraveledHour

Cost per traveled hour of the vehicle route. This cost is applied only to travel time taken by the route (i.e., that reported in ShipmentRoute.transitions), and excludes waiting time and visit time.

Returns
Type Description
float

setCostPerTraveledHour

Cost per traveled hour of the vehicle route. This cost is applied only to travel time taken by the route (i.e., that reported in ShipmentRoute.transitions), and excludes waiting time and visit time.

Parameter
Name Description
var float
Returns
Type Description
$this

getCostPerKilometer

Cost per kilometer of the vehicle route. This cost is applied to the distance reported in the ShipmentRoute.transitions and does not apply to any distance implicitly traveled from the arrival_location to the departure_location of a single VisitRequest.

Returns
Type Description
float

setCostPerKilometer

Cost per kilometer of the vehicle route. This cost is applied to the distance reported in the ShipmentRoute.transitions and does not apply to any distance implicitly traveled from the arrival_location to the departure_location of a single VisitRequest.

Parameter
Name Description
var float
Returns
Type Description
$this

getFixedCost

Fixed cost applied if this vehicle is used to handle a shipment.

Returns
Type Description
float

setFixedCost

Fixed cost applied if this vehicle is used to handle a shipment.

Parameter
Name Description
var float
Returns
Type Description
$this

getUsedIfRouteIsEmpty

This field only applies to vehicles when their route does not serve any shipments. It indicates if the vehicle should be considered as used or not in this case.

If true, the vehicle goes from its start to its end location even if it doesn't serve any shipments, and time and distance costs resulting from its start --> end travel are taken into account. Otherwise, it doesn't travel from its start to its end location, and no break_rule or delay (from TransitionAttributes) are scheduled for this vehicle. In this case, the vehicle's ShipmentRoute doesn't contain any information except for the vehicle index and label.

Returns
Type Description
bool

setUsedIfRouteIsEmpty

This field only applies to vehicles when their route does not serve any shipments. It indicates if the vehicle should be considered as used or not in this case.

If true, the vehicle goes from its start to its end location even if it doesn't serve any shipments, and time and distance costs resulting from its start --> end travel are taken into account. Otherwise, it doesn't travel from its start to its end location, and no break_rule or delay (from TransitionAttributes) are scheduled for this vehicle. In this case, the vehicle's ShipmentRoute doesn't contain any information except for the vehicle index and label.

Parameter
Name Description
var bool
Returns
Type Description
$this

getRouteDurationLimit

Limit applied to the total duration of the vehicle's route. In a given OptimizeToursResponse, the route duration of a vehicle is the difference between its vehicle_end_time and vehicle_start_time.

Returns
Type Description
Vehicle\DurationLimit|null

hasRouteDurationLimit

clearRouteDurationLimit

setRouteDurationLimit

Limit applied to the total duration of the vehicle's route. In a given OptimizeToursResponse, the route duration of a vehicle is the difference between its vehicle_end_time and vehicle_start_time.

Parameter
Name Description
var Vehicle\DurationLimit
Returns
Type Description
$this

getTravelDurationLimit

Limit applied to the travel duration of the vehicle's route. In a given OptimizeToursResponse, the route travel duration is the sum of all its transitions.travel_duration.

Returns
Type Description
Vehicle\DurationLimit|null

hasTravelDurationLimit

clearTravelDurationLimit

setTravelDurationLimit

Limit applied to the travel duration of the vehicle's route. In a given OptimizeToursResponse, the route travel duration is the sum of all its transitions.travel_duration.

Parameter
Name Description
var Vehicle\DurationLimit
Returns
Type Description
$this

getRouteDistanceLimit

Limit applied to the total distance of the vehicle's route. In a given OptimizeToursResponse, the route distance is the sum of all its transitions.travel_distance_meters.

Returns
Type Description
DistanceLimit|null

hasRouteDistanceLimit

clearRouteDistanceLimit

setRouteDistanceLimit

Limit applied to the total distance of the vehicle's route. In a given OptimizeToursResponse, the route distance is the sum of all its transitions.travel_distance_meters.

Parameter
Name Description
var DistanceLimit
Returns
Type Description
$this

getExtraVisitDurationForVisitType

Specifies a map from visit_types strings to durations. The duration is time in addition to VisitRequest.duration to be taken at visits with the specified visit_types. This extra visit duration adds cost if cost_per_hour is specified. Keys (i.e.

visit_types) cannot be empty strings. If a visit request has multiple types, a duration will be added for each type in the map.

Returns
Type Description
Google\Protobuf\Internal\MapField

setExtraVisitDurationForVisitType

Specifies a map from visit_types strings to durations. The duration is time in addition to VisitRequest.duration to be taken at visits with the specified visit_types. This extra visit duration adds cost if cost_per_hour is specified. Keys (i.e.

visit_types) cannot be empty strings. If a visit request has multiple types, a duration will be added for each type in the map.

Parameter
Name Description
var array|Google\Protobuf\Internal\MapField
Returns
Type Description
$this

getBreakRule

Describes the break schedule to be enforced on this vehicle.

If empty, no breaks will be scheduled for this vehicle.

Returns
Type Description
BreakRule|null

hasBreakRule

clearBreakRule

setBreakRule

Describes the break schedule to be enforced on this vehicle.

If empty, no breaks will be scheduled for this vehicle.

Parameter
Name Description
var BreakRule
Returns
Type Description
$this

getLabel

Specifies a label for this vehicle. This label is reported in the response as the vehicle_label of the corresponding ShipmentRoute.

Returns
Type Description
string

setLabel

Specifies a label for this vehicle. This label is reported in the response as the vehicle_label of the corresponding ShipmentRoute.

Parameter
Name Description
var string
Returns
Type Description
$this

getIgnore

If true, used_if_route_is_empty must be false, and this vehicle will remain unused.

If a shipment is performed by an ignored vehicle in injected_first_solution_routes, it is skipped in the first solution but is free to be performed in the response. If a shipment is performed by an ignored vehicle in injected_solution_constraint and any related pickup/delivery is constrained to remain on the vehicle (i.e., not relaxed to level RELAX_ALL_AFTER_THRESHOLD), it is skipped in the response. If a shipment has a non-empty allowed_vehicle_indices field and all of the allowed vehicles are ignored, it is skipped in the response.

Returns
Type Description
bool

setIgnore

If true, used_if_route_is_empty must be false, and this vehicle will remain unused.

If a shipment is performed by an ignored vehicle in injected_first_solution_routes, it is skipped in the first solution but is free to be performed in the response. If a shipment is performed by an ignored vehicle in injected_solution_constraint and any related pickup/delivery is constrained to remain on the vehicle (i.e., not relaxed to level RELAX_ALL_AFTER_THRESHOLD), it is skipped in the response. If a shipment has a non-empty allowed_vehicle_indices field and all of the allowed vehicles are ignored, it is skipped in the response.

Parameter
Name Description
var bool
Returns
Type Description
$this

getBreakRuleIndices

Deprecated: No longer used.

Indices in the break_rule field in the source ShipmentModel. They correspond to break rules enforced on the vehicle. As of 2018/03, at most one rule index per vehicle can be specified.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setBreakRuleIndices

Deprecated: No longer used.

Indices in the break_rule field in the source ShipmentModel. They correspond to break rules enforced on the vehicle. As of 2018/03, at most one rule index per vehicle can be specified.

Parameter
Name Description
var int[]
Returns
Type Description
$this

getCapacities

Deprecated: Use Vehicle.load_limits instead.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setCapacities

Deprecated: Use Vehicle.load_limits instead.

Parameter
Name Description
var array<CapacityQuantity>
Returns
Type Description
$this

getStartLoadIntervals

Deprecated: Use Vehicle.LoadLimit.start_load_interval instead.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setStartLoadIntervals

Deprecated: Use Vehicle.LoadLimit.start_load_interval instead.

Parameter
Name Description
var array<CapacityQuantityInterval>
Returns
Type Description
$this

getEndLoadIntervals

Deprecated: Use Vehicle.LoadLimit.end_load_interval instead.

Returns
Type Description
Google\Protobuf\Internal\RepeatedField

setEndLoadIntervals

Deprecated: Use Vehicle.LoadLimit.end_load_interval instead.

Parameter
Name Description
var array<CapacityQuantityInterval>
Returns
Type Description
$this