import { LngLatLike } from 'maplibre-gl'; import { TravelMode } from '@src/common/interface'; import { NBRequestStatus } from './common'; /** * * Notes: * the expected order for all coordinates arrays is [lon, lat] * all timings are in seconds * all distances are in meters * a time_window object is a pair of timestamps in the form [start, end] * cost values in output are the one used in the optimization objective (currently equal to duration) * a "task" is either a job, a pickup or a delivery */ export interface OptimizationMvrpOrderRequestV2 { /** Indicate the locations that will be used for optimization */ locations: OptimizationMvrpOrderLocationV2; /** Describe the places to visit. The Job object describes a particular job or task that needs to be completed as part of the overall optimization process */ jobs?: OptimizationMvrpOrderJobV2[]; /** Describe available vehicles */ vehicles: OptimizationMvrpOrderVehicleV2[]; /** Describe pickup and delivery tasks */ shipments?: OptimizationMvrpOrderShipmentV2[]; /** Describe the optimization job. The description will be returned in the response */ description?: string; /** The Depot object describes a depot location that can be used as a starting point and/or ending point for the routes */ depots?: OptimizationMvrpOrderDepotV2[]; /** It represents the set of options that can be used to configure an optimization job */ options: OptimizationMvrpOrderOptionsV2; /** This parameter is related to the re-optimization feature. It allows for the previous optimization result to be provided in case new orders are received and the solution needs to be re-planned. The solution parameter should contain the same routes as the previous optimization result */ solution: OptimizationMvrpRouteV2[]; /** * The "Unassigned" field in the optimization request and response payloads are used to describe any tasks that were not assigned to a vehicle during the optimization process. This could happen because there were not enough vehicles available, the tasks could not be completed within their assigned time windows, or other constraints were not met. * If you're re-optimizing a previous job and there are unassigned tasks, the "Unassigned" field should be consistent with the previous optimization result, meaning that any previously unassigned tasks should still be unassigned in the new result. However, if you want to reduce the number of unassigned tasks, there are various strategies you can use, such as: * Extending the time windows for vehicles or tasks to give more flexibility * Adding more vehicles to the optimization problem * Adjusting the priority or weight of different tasks to balance the workload more evenly * Modifying other constraints or parameters to make the problem more solvable * Ultimately, the goal is to minimize the number of unassigned tasks while still meeting all the necessary constraints and objectives. */ unassigned: OptimizationMvrpOrderUnassignedV2[]; /** * api key for the request */ apiKey?: string; } export interface OptimizationMvrpOrderJobV2 { /** Indicate the job id. It cannot be duplicated to another Job’s id */ id: number; /** * Indicate the index of location in Locations. The valid value range is [0, length of locations) */ location_index: number; /** * Describe the job service duration. The unit is in second. The default value is 0 */ service?: number; /** * Describe multidimensional quantities for delivery. The amount of delivery will be added to the assigned vehicle’s initial load */ delivery?: number[]; /** * Describe multidimensional quantities for pickup */ pickup?: number[]; /** * Describe available periods for this job * * Example: [[1656487800,1656516600],[1656570000,1656620000]] * */ time_windows?: number[][]; /** * Describe mandatory skills for this job */ skills?: number[]; /** * Description of the job */ description?: string; /** * Describe the priority of this job. The valid value is in the range of [0, 100]. Its default value is 0. Priority only decides whether this job will be assigned, but has nothing to do with the sequence of jobs */ priority?: number; } export interface OptimizationMvrpOrderLocationV2 { /** a unique identifier for the location */ id: number; /** * Indicate the coordinates that will be used for route optimization. */ location: LngLatLike[]; /** * Describe if the location is curbside. */ approaches?: string[]; } export interface OptimizationMvrpOrderShipmentV2 { /** * It describes multidimensional quantities of a shipment in different units. */ amount?: number[]; /** * Describe the delivery point for this shipment */ delivery: { /** Describe this shipment step */ description: string; /** Indicate the id of this delivery. An error will be reported when there are duplicate ids for pickup/delivery Indicate the position of this delivery */ id: number; /** * The valid range of value is from 0 to length of locations object * * Indicate the location for this shipment step. The index references the locations present in the locations object */ location_index: number; /** * The service duration of this shipment step in seconds */ service?: number; /** * Describe the available time slots for service start for this shipment step object in UNIX Timestamp format. */ time_windows?: [number, number][]; }; /** * Describe the pickup point for this shipment */ pickup: { /** * Describe this shipment step */ description?: string; /** * Indicate the id of this shipment step. An error will be reported when there’re duplicate ids for pickup/delivery */ id: number; /** * Indicate the position of this shipment step. The valid range of value is [0, length of locations) */ location_index: number; /** * Describe the service duration of this shipment step. The default value is 0. The unit is in seconds. */ service?: number; /** * Describe the available periods for this shipment step */ time_windows?: [number, number][]; }; /** * Describe the priority of this shipment. The valid value is in the range of [0, 100]. Its default value is 0. Priority only decides whether this shipment will be assigned, but has nothing to do with the sequence of shipments */ priority?: number; /** Describe the mandatory skills for this shipment */ skills?: number[]; } export interface OptimizationMvrpOrderVehicleV2 { /** * Describe the breaks the driver will take */ break?: { /** * Describe this break */ description?: string; id: number; /** * Describe the break duration. Its default value is 0. The unit is in second */ service?: number; time_windows: number[][]; }; /** * Describe the cost for using this vehicle. The cost parameter represents the initial cost of using a vehicle and is used to limit the number of vehicles used for optimization. It is a positive integer value with no specific unit. The cost is added to the travel_cost, which is calculated based on user-defined values such as distance or duration. The cost parameter can be used in either absolute or relative values, allowing users to assign default relative values for different vehicle types or skills. Using relative costs provides flexibility for users to optimize their solution without knowing the actual costs of each vehicle, which may vary depending on other factors such as fuel cost or maintenance. The optimization engine will prefer using vehicles with a lower initial cost if some other parameters (location, time, etc) favor the configuration */ costs: { /** Assign a fixed cost for using a vehicle */ fixed?: number; }; /** * Add some description on this vehicle */ description?: string; /** * Describe the depot assigned to this vehicle. Note that if start_index is specified, then its value has to be the same as the specified depot’s location index. There is no restriction on the number of vehicles a depot can contain. One vehicle can only have one depot */ depot?: number; /** * The Capacity parameter is used to describe the multidimensional quantities of capacity for each vehicle. */ capacity?: number[]; /** * Indicate the index of the vehicle ending point in Locations. The valid value range is [0, length of locations). If this optional parameter is not used, the resulting route will end at the last visited task, whose choice is determined by the optimization process */ end_index?: number; /** * Describe this vehicle’s id. It cannot be duplicated to other vehicle’s IDs */ id: number; /** * Describe the max tasks that can be assigned to this vehicle */ max_tasks?: number; /** * It restricts the maximum distance or time a vehicle can operate during route optimization. This parameter is linked to the "travel_cost" parameter in "option.objective" which determines whether the "max_travel_cost" value will be considered as distance (in meters) or duration (in seconds). For example, if the "travel_cost" parameter is set to 'distance', the "max_travel_cost" value will be considered as the maximum allowable distance that a vehicle can travel during the route optimization. If the "travel_cost" parameter is set to 'duration', the "max_travel_cost" value will be considered as the maximum allowable time that a vehicle can operate during the route optimization. Setting a value for "max_travel_cost" can be useful in ensuring that vehicles do not exceed their operational limits, which can result in increased fuel costs, longer delivery times, and potential vehicle breakdowns */ max_travel_cost?: number; /** * It is a multi-dimensional feature that describes the skills and abilities of drivers or vehicles */ skills?: number[]; /** * Indicate the index of the vehicle starting point in Locations. The valid value range is [0, length of locations).Please note that in V2 this is a required parameter */ start_index: number; /** * The time_window field is used to describe the time period during which a vehicle is available to perform deliveries or pickups. It is a one-dimensional array, meaning it has a single value that represents the time window for the vehicle. It's important to note that this field should not be confused with the time_windows field used for shipments/jobs, which is a two-dimensional array used to describe the time window for each individual shipment or job. If the time_windows field is incorrectly used for the time_window field, the shift period setting constraint may fail silently, meaning that the vehicle may be assigned to tasks outside of its available time period, leading to incorrect results */ time_window?: [number, number]; } export interface OptimizationMvrpOrderDepotV2 { /** Add a description for this depot */ description?: string; /** Describe the id of this depot */ id: number; /** Describe the location of depot */ location_index: number; } export interface OptimizationMvrpOrderOptionsV2 { /** * Describes the soft constraints of the optimization job. Soft constraints are constraints that do not necessarily have to be satisfied, but the optimization algorithm will try to satisfy them as much as possible. For example, Suppose a vehicle exceeds this overtime limit of 300-time units while servicing a set of orders. In that case, it will be considered a violation of this constraint */ constraint?: { /** * It specifies the maximum amount of overtime a vehicle can have beyond its time window. Overtime is the time that a vehicle spends on a set of jobs after its time window has ended. If a vehicle's overtime exceeds this value, it will be considered a violation of this constraint */ max_vehicle_overtime?: number; /** * It specifies the maximum amount of lateness that a job or shipment can have beyond its time window. If a job or shipment's lateness exceeds this value, it will be considered a violation of this constraint */ max_visit_lateness?: number; }; /** * It describes the objective for the optimization job. It specifies whether the optimization should minimize or maximize a particular objective, such as the total distance traveled or the number of vehicles used */ objective?: { /** * Specify whether to minimize the number of depots used in optimization routes */ minimise_num_depots: boolean; /** * The travel_cost parameter in the API specifies the type of cost used by the solver to optimize the route planning. This parameter can take one of three values - distance, duration, or air_distance * * If the TravelCost parameter is set to distance, the solver will try to minimize the total distance traveled by vehicles in the route planning. This would be useful in cases where the primary objective is to reduce fuel consumption or travel expenses. * If the TravelCost parameter is set to duration, the solver will try to minimize the total time taken by the vehicles in the route planning. This would be useful in cases where the primary objective is to minimize delivery time or maximize the number of orders fulfilled within a given time window. * If the travel_cost parameter is set to air_distance, the solver will try to calculate the distance between two points using the great-circle distance formula (i.e., the shortest distance between two points on a sphere) instead of the actual road distance. This would be useful in cases where the delivery locations are far apart and the road distance between them is significantly longer than the actual straight-line distance. For example, in Drone Delivery services. * * Thus, users can choose the appropriate value for the travel_cost parameter based on their specific requirements - use distance for the solver to prefer a 'shortest route' algorithm and use duration for the solver to prefer the fastest route algorithm. */ travel_cost: string; }; /** * It describes the routing configurations for the optimization job. It specifies options such as whether to use time-dependent or time-independent routing, and whether to use a specific routing algorithm */ routing: { /** * Describe the service mode such as 4w and 6w. Please note that as part of the schema changes in V2 this parameter was made a part of the routing object */ mode?: TravelMode | string; /** * Specify the general time when the vehicle operates */ traffic_timestamp?: number; /** * Specify the truck size in three dimensions in the format of “height, width, length”. The unit is centimeters (cm). (This parameter only works when optimization mode is 6w) */ truck_size?: string; /** * Specify the weight of the truck including trailers and shipped goods in kilograms. Max value allowed is 100000. (This parameter only works when optimization mode is 6w) */ truck_weight?: number; }; } export interface OptimizationMvrpOrderUnassignedV2 { /** * Indicate the id of unassigned task */ id?: number; /** * Describe the coordinate of the unassigned task */ location?: number[]; /** * Describe the unassigned task type */ task_type?: string; } export interface OptimizationMvrpRetrieveRequestV2 { /** Unique Reference ID for the submitted VRP. It is the id returned from optimization POST response. */ id: string; /** * api key for the request */ apiKey?: string; } export interface OptimizationMvrpOrderResultV2 { id: string; message: string; status: NBRequestStatus; } /** * * Notes: * the expected order for all coordinates arrays is [lon, lat] * all timings are in seconds * all distances are in meters * a time_window object is a pair of timestamps in the form [start, end] * cost values in output are the one used in the optimization objective (currently equal to duration) * a "task" is either a job, a pickup or a delivery */ export interface OptimizationMvrpRetrieveResultV2 { /** This will return a value if it is set in the description top level property. */ description?: string; /** Describe the error if one occurs during processing data */ message: string; result: OptimizationMvrpRetrieveResultDataV2; /** Describes the process status */ status: NBRequestStatus; } export interface OptimizationMvrpRetrieveResultDataV2 { /** * 0: no error, 1: internal error, 2: input error, 3: routing error */ code?: number; error: string; routes: OptimizationMvrpRouteV2[]; summary: OptimizationMvrpSummaryV2; unassigned: OptimizationMvrpUnassignedV2[]; } export interface OptimizationMvrpRouteV2 { /** Describe the vehicle ID */ vehicle: number; /** The vehicle-overtime of this route */ vehicle_overtime: number; /** Describe the cost of this route. Right now it is equal to duration */ cost?: number; /** Describe the total deliveries in this route */ delivery?: number[]; /** Describe the total distance in this route */ distance?: number; /** Describe the duration of this route */ duration?: number; /** geometry */ geometry?: string; /** Describe the total pickups in this route */ pickup?: number[]; /** Describe the sum of priorities for this route */ priority?: number; /** Describe the total service time for this route */ service?: number; /** Describe the steps in this route */ steps?: OptimizationMvrpRouteStepV2[]; /** Description of the vehicle on the route */ description?: string; /** Describe the waiting time at this step */ waiting_time?: number; } export interface OptimizationMvrpRouteStepV2 { /** Describe the arrival time at this step */ arrival?: number; /** Describe this step */ description?: string; /** Describe the duration to this step. (The duration is accumulated here which means it includes the time spent on previous steps) */ duration?: number; /** Describe the id of this task */ id?: number; /** Describe the visit-lateness of this step */ late_by?: number; /** Describe the load of the vehicle after the completion of this step */ load?: number[]; /** Describe the coordinate at this step */ location?: number[]; /** Describe the location index at this step */ location_index?: number; /** Describe the service duration at this step */ service: number; /** Describe the task type of this step */ type: string; /** Describe the violations in this step */ violation?: { /** Describe the cause of violation */ cause?: string; duration?: number; }[]; /** Describe the waiting time at this step */ waiting_time?: number; } export interface OptimizationMvrpSummaryV2 { cost?: number; delivery?: number[]; distance?: number; duration?: number; num_late_visits?: number; num_vehicle_overtime?: number; pickup?: number[]; prioriy?: number; routes?: number; service?: number; total_vehicle_overtime?: number; total_visit_lateness?: number; unassigned?: number; violation?: { cause?: string; duration?: number; }; waiting_time?: number; } export interface OptimizationMvrpUnassignedV2 { id?: number; location?: number[]; task_type?: string; description?: string; } /** * A service solves for the optimization of a Multi(or single) vehicle routing problem. */ export declare class OptimizationMvrpServiceV2 { postVRP(opt: OptimizationMvrpOrderRequestV2): Promise; retrieve(opt: OptimizationMvrpRetrieveRequestV2): Promise; } //# sourceMappingURL=optimization-mvrp2.d.ts.map