Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::vrp::Optimization Class Reference

Defines a vehicle routing problem that has to be optimized. More...

Inheritance diagram for gem::vrp::Optimization:
Collaboration diagram for gem::vrp::Optimization:

Public Member Functions

 Optimization ()=default
 Default constructor.
 Optimization (const Optimization &)=default
 Default copy constructor.
 Optimization (Optimization &&) noexcept=default
 Default move constructor noexcept is deduced.
Optimizationoperator= (const Optimization &)=default
 Default copy assignment operator.
Optimizationoperator= (Optimization &&) noexcept=default
 Default move assignment operator.
bool operator== (Optimization const &optimization) const
 Compares two Optimization objects for equality.
bool operator!= (Optimization const &optimization) const
 Compares two Optimization objects for equality.
LargeInteger getId () const noexcept
 Get the id of the optimization; used only to identify the optimization when you have to update or delete it.
const ConfigurationParametersRef getConfigurationParameters () const noexcept
 Get the ConfigurationParameters of the optimization.
OptimizationsetConfigurationParameters (const ConfigurationParameters &params) noexcept
 Set the ConfigurationParameters of the optimization.
const OrderListRef getOrders () const noexcept
 Get the orders that have to be visited.
OptimizationsetOrders (const OrderList &orders) noexcept
 Set the orders that have to be visited.
const VehicleListRef getVehicles () const noexcept
 Get the vehicles list of the optimization.
OptimizationsetVehicles (const VehicleList &vehicles) noexcept
 Set vehicles that will be used in the optimization.
const VehicleConstraintsListRef getVehiclesConstraints () const noexcept
 Get the VehicleConstraints list of the optimization.
OptimizationsetVehiclesConstraints (const VehicleConstraintsList &list) noexcept
 Set the VehicleConstraints list of the optimization.
const DepartureListRef getDepartures () const noexcept
 Get the departures points from where the vehicles have to start their routes.
OptimizationsetDepartures (const DepartureList &departureList) noexcept
 Set the departures points from where the vehicles have to start their routes.
const DestinationListRef getDestinations () const noexcept
 Get the destinations points where the vehicles will end their routes.
OptimizationsetDestinations (const DestinationList &destinationList) noexcept
 Set the destination points where the vehicles will end their routes.
EMatrixBuildType getMatrixBuildType () const noexcept
 Retrieves the method used for building the distance and time matrices.
OptimizationsetMatrixBuildType (EMatrixBuildType matrixBuildType) noexcept
 Sets the method to be used for constructing the distance and time matrices for the optimization.
const std::map< EVehicleType, FloatListList > & getDistanceMatrices () const noexcept
 Retrieves custom distance matrices set for each vehicle type.
OptimizationsetDistanceMatrices (const std::map< EVehicleType, FloatListList > &matrices) noexcept
 Sets custom distance matrices for each vehicle type.
const std::map< EVehicleType, IntListList > & getTimeMatrices () const noexcept
 Retrieves custom time matrices set for each vehicle type.
OptimizationsetTimeMatrices (const std::map< EVehicleType, IntListList > &matrices) noexcept
 Sets custom time matrices for each vehicle type.
const TimeRef getCreationTime () const noexcept
 Get the time when the optimization was created.
int getSolution (ProgressListener listener, RouteList &routes) noexcept
 Async returns the solution for an optimization.
int reoptimize (ProgressListener listener, Request &request) noexcept
 Async reoptimize the optimization.
int addOrders (ProgressListener listener, const OrderList &orders, Request &request, bool reoptimize=false, const std::map< vrp::EVehicleType, FloatListList > distancesToTheOtherLocations=std::map< vrp::EVehicleType, FloatListList >(), const std::map< vrp::EVehicleType, IntListList > timesToTheOtherLocations=std::map< vrp::EVehicleType, IntListList >()) noexcept
 Async adds orders to the optimization.
int updateOrder (ProgressListener listener, const Order &order) noexcept
 Async saves the updates made to the optimization order.
int deleteOrder (ProgressListener listener, Order &order) noexcept
 Async removes a order from the optimization.

Detailed Description

Defines a vehicle routing problem that has to be optimized.

Implements share-read / copy-on-write Api object over IOptimization.

Member Function Documentation

◆ addOrders()

int gem::vrp::Optimization::addOrders ( ProgressListener listener,
const OrderList & orders,
Request & request,
bool reoptimize = false,
const std::map< vrp::EVehicleType, FloatListList > distancesToTheOtherLocations = std::map<vrp::EVehicleTypeFloatListList>(),
const std::map< vrp::EVehicleType, IntListList > timesToTheOtherLocations = std::map<vrp::EVehicleTypeIntListList>() )
inlinenoexcept

Async adds orders to the optimization.

The orders will be added at the end of the existing optimization's orders list

Parameters
[in]listenerOperation progress listener. Returns:
[in]ordersThe orders data to be added, as a list of Order objects
[out]requestIf the optimization is reoptimized, then a request is created for this operation. Use the request's id to get the current status of the operation.
[in]reoptimizeIf the optimization should be reoptimized after addition or not. If is not reoptimized, the added orders will not be in the solution of the optimization.
[in]distancesToTheOtherLocationsThe distances from each added order's location to the other orders of the optimization, for each vehicle type used (if the matrices are set by the user)
[in]timesToTheOtherLocationsThe times from each added order's location to the other orders of the optimization, for each vehicle type used (if the matrices are set by the user)
Returns
Error code if the operation couldn't start. If operation successfully started the progress and completion notifications will come via the listener
See also
EMatrixBuildType

◆ deleteOrder()

int gem::vrp::Optimization::deleteOrder ( ProgressListener listener,
Order & order )
inlinenoexcept

Async removes a order from the optimization.

It will also be deleted from the route in which it is visited. The start order of the optimization or its routes can't be deleted!

Parameters
[in]orderThe order that will be deleted. If the operation succeeded the object will have the id 0.
[in]listenerOperation progress listener. Returns:
Returns
Error code if the operation couldn't start. If operation successfully started the progress and completion notifications will come via the listener

◆ getConfigurationParameters()

const ConfigurationParametersRef gem::vrp::Optimization::getConfigurationParameters ( ) const
inlinenoexcept

Get the ConfigurationParameters of the optimization.

Returns
A constant reference to the ConfigurationParameters object.

◆ getCreationTime()

const TimeRef gem::vrp::Optimization::getCreationTime ( ) const
inlinenoexcept

Get the time when the optimization was created.

Returns
The moment when the optimization was created, in UTC.

◆ getDepartures()

const DepartureListRef gem::vrp::Optimization::getDepartures ( ) const
inlinenoexcept

Get the departures points from where the vehicles have to start their routes.

Returns
a list of Departure objects which represents the start point for each vehicle. If the list has only one Departure and the number of vehicles is > 1, then all the vehicles start from this Departure.

◆ getDestinations()

const DestinationListRef gem::vrp::Optimization::getDestinations ( ) const
inlinenoexcept

Get the destinations points where the vehicles will end their routes.

Returns
a list of Destination objects which represents the end point for each vehicle. If the list has only one Destination and the number of vehicles is > 1, then all the vehicles end at this Destination.

◆ getDistanceMatrices()

const std::map< EVehicleType, FloatListList > & gem::vrp::Optimization::getDistanceMatrices ( ) const
inlinenoexcept

Retrieves custom distance matrices set for each vehicle type.

This is used when distances between locations vary based on the type of vehicle, and precise control over routing is needed.

Returns
A map of vehicle types to their respective distance matrices.

◆ getId()

LargeInteger gem::vrp::Optimization::getId ( ) const
inlinenoexcept

Get the id of the optimization; used only to identify the optimization when you have to update or delete it.

Returns
The id of the optimization as LargeInteger
See also
Service::updateOptimization(), Service::deleteOptimization()

◆ getMatrixBuildType()

EMatrixBuildType gem::vrp::Optimization::getMatrixBuildType ( ) const
inlinenoexcept

Retrieves the method used for building the distance and time matrices.

Returns
The matrix build type as an EMatrixBuildType enumeration value.

◆ getOrders()

const OrderListRef gem::vrp::Optimization::getOrders ( ) const
inlinenoexcept

Get the orders that have to be visited.

Returns
Optimization's orders as an OrderList reference.

◆ getSolution()

int gem::vrp::Optimization::getSolution ( ProgressListener listener,
RouteList & routes )
inlinenoexcept

Async returns the solution for an optimization.

Parameters
[out]routesThe result Route objects list
[in]listenerOperation progress listener. Returns:
Returns
Error code if the operation couldn't start. If operation successfully started the progress and completion notifications will come via the listener

◆ getTimeMatrices()

const std::map< EVehicleType, IntListList > & gem::vrp::Optimization::getTimeMatrices ( ) const
inlinenoexcept

Retrieves custom time matrices set for each vehicle type.

Similar to distance matrices but specifies the travel time between locations for different vehicle types.

Returns
A map of vehicle types to their respective time matrices.

◆ getVehicles()

const VehicleListRef gem::vrp::Optimization::getVehicles ( ) const
inlinenoexcept

Get the vehicles list of the optimization.

Returns
Optimization's vehicles as an VehicleList reference.

◆ getVehiclesConstraints()

const VehicleConstraintsListRef gem::vrp::Optimization::getVehiclesConstraints ( ) const
inlinenoexcept

Get the VehicleConstraints list of the optimization.

Returns
a list with a VehicleConstraints object for each vehicle used or a list with only one VehicleConstraints object which will be applied to all the vehicles used

◆ operator!=()

bool gem::vrp::Optimization::operator!= ( Optimization const & optimization) const
inline

Compares two Optimization objects for equality.

Parameters
optimizationAnother Optimization object to compare against.
Returns
True if both Optimization objects represent the same data, false otherwise.

◆ operator=() [1/2]

Optimization & gem::vrp::Optimization::operator= ( const Optimization & )
default

Default copy assignment operator.

Replaces the contents of this object with a copy of another Optimization object.

Returns
A reference to the current object.

◆ operator=() [2/2]

Optimization & gem::vrp::Optimization::operator= ( Optimization && )
defaultnoexcept

Default move assignment operator.

Moves the contents of another Optimization object into this one.

Returns
A reference to the current object.

◆ operator==()

bool gem::vrp::Optimization::operator== ( Optimization const & optimization) const
inline

Compares two Optimization objects for equality.

Parameters
optimizationAnother Optimization object to compare against.
Returns
True if both Optimization objects represent the same data, false otherwise.

◆ reoptimize()

int gem::vrp::Optimization::reoptimize ( ProgressListener listener,
Request & request )
inlinenoexcept

Async reoptimize the optimization.

Parameters
[in]listenerOperation progress listener. Returns:
[out]requestThe request created for this operation. Use the request's id to get the current status of the operation.
Returns
Error code if the operation couldn't start. If operation successfully started the progress and completion notifications will come via the listener

◆ setConfigurationParameters()

Optimization & gem::vrp::Optimization::setConfigurationParameters ( const ConfigurationParameters & params)
inlinenoexcept

Set the ConfigurationParameters of the optimization.

Parameters
paramsThe new configuration parameters set for this optimization
Returns
A reference to this Optimization object after the modification.

◆ setDepartures()

Optimization & gem::vrp::Optimization::setDepartures ( const DepartureList & departureList)
inlinenoexcept

Set the departures points from where the vehicles have to start their routes.

You can set one departure for each vehicle or the same one for all the vehicles (the parameter "departureList" will have only one element).

Parameters
departureListThe list of Departure objects
Returns
A reference to this Optimization object after modification.

◆ setDestinations()

Optimization & gem::vrp::Optimization::setDestinations ( const DestinationList & destinationList)
inlinenoexcept

Set the destination points where the vehicles will end their routes.

This method can be used when the route type is ERouteType::RT_CustomEnd. You can set one Destination for each vehicle or the same one for all the vehicles (the parameter "destinationList" will have only one element).

Parameters
destinationListThe list of Destination objects
Returns
A reference to this Optimization object after modification.
See also
ERouteType, ConfigurationParameters::setRouteType()

◆ setDistanceMatrices()

Optimization & gem::vrp::Optimization::setDistanceMatrices ( const std::map< EVehicleType, FloatListList > & matrices)
inlinenoexcept

Sets custom distance matrices for each vehicle type.

Allows specifying exact distances between locations for different types of vehicles, providing fine-grained control over route optimization.

Parameters
matricesA map of vehicle types to their respective distance matrices.
Returns
A reference to this Optimization object.

◆ setMatrixBuildType()

Optimization & gem::vrp::Optimization::setMatrixBuildType ( EMatrixBuildType matrixBuildType)
inlinenoexcept

Sets the method to be used for constructing the distance and time matrices for the optimization.

This can significantly impact the optimization's realism and accuracy.

Parameters
matrixBuildTypeThe matrix build type as an EMatrixBuildType enumeration value.
Returns
A reference to this Optimization object.

◆ setOrders()

Optimization & gem::vrp::Optimization::setOrders ( const OrderList & orders)
inlinenoexcept

Set the orders that have to be visited.

Required field.

Parameters
ordersThe orders to be visited
Returns
A reference to this Optimization object after the modification.

◆ setTimeMatrices()

Optimization & gem::vrp::Optimization::setTimeMatrices ( const std::map< EVehicleType, IntListList > & matrices)
inlinenoexcept

Sets custom time matrices for each vehicle type.

This method allows for the specification of travel times between locations, tailored to different types of vehicles.

Parameters
matricesA map of vehicle types to their respective time matrices.
Returns
A reference to this Optimization object.

◆ setVehicles()

Optimization & gem::vrp::Optimization::setVehicles ( const VehicleList & vehicles)
inlinenoexcept

Set vehicles that will be used in the optimization.

If you set more than 1 vehicle, the algorithm may find a solution where not all the vehicles are used; but if you want to be sure that all of them are used, you can set in the VehicleConstraints the minimum number of orders to visit or the minimum distance to 1.

Parameters
vehiclesThe vehicles which will be used
Returns
A reference to this Optimization object after the modification.
See also
VehicleConstraints::setMinNumberOfOrders(), VehicleConstraints::setMinDistance()

◆ setVehiclesConstraints()

Optimization & gem::vrp::Optimization::setVehiclesConstraints ( const VehicleConstraintsList & list)
inlinenoexcept

Set the VehicleConstraints list of the optimization.

If you use multiple vehicles (number of vehicles > 1), you can set a set of vehicle constraints for each vehicle or you can set only one set that will be applied to all the vehicles used. So the size of the "list" parameter should be equal to the number of vehicles or 1.

Parameters
listThe list of vehicle constraints
Returns
A reference to this Optimization object after the modification.

◆ updateOrder()

int gem::vrp::Optimization::updateOrder ( ProgressListener listener,
const Order & order )
inlinenoexcept

Async saves the updates made to the optimization order.

It will be also be updated in the route were it is used. The coordinates of a order cannot be changed.

Parameters
[in]orderThe new order data, as Order object
[in]listenerOperation progress listener. Returns:
Returns
Error code if the operation couldn't start. If operation successfully started the progress and completion notifications will come via the listener