#include <solution_serializer.h>
|
static std::vector< std::vector< int64_t > > | SplitRoutes (const std::vector< int64_t > &solution, int64_t separator) |
| Public-facing builders.
|
|
static RoutingSolution | FromSplitRoutes (absl::Span< const std::vector< int64_t > > routes, std::optional< int64_t > depot=std::nullopt) |
|
Describes completely a solution to a routing problem in preparation of its serialization as a string.
Definition at line 54 of file solution_serializer.h.
◆ Route
◆ RoutingSolution()
operations_research::RoutingSolution::RoutingSolution |
( |
std::vector< Route > | routes, |
|
|
std::vector< int64_t > | total_demands, |
|
|
std::vector< int64_t > | total_distances, |
|
|
int64_t | total_cost = -1, |
|
|
int64_t | total_distance = -1, |
|
|
double | total_time = -1.0, |
|
|
std::string_view | name = "" ) |
|
inline |
◆ FromSplitRoutes()
RoutingSolution operations_research::RoutingSolution::FromSplitRoutes |
( |
absl::Span< const std::vector< int64_t > > | routes, |
|
|
std::optional< int64_t > | depot = std::nullopt ) |
|
static |
Builds a RoutingSolution object from a vector of routes, each represented as a vector of nodes being traversed. All the routes are supposed to start and end at the depot if specified.
Definition at line 68 of file solution_serializer.cc.
◆ operator!=()
bool operations_research::RoutingSolution::operator!= |
( |
const RoutingSolution & | other | ) |
const |
|
inline |
◆ operator==()
bool operations_research::RoutingSolution::operator== |
( |
const RoutingSolution & | other | ) |
const |
|
inline |
◆ SerializeToSolutionFile()
std::string operations_research::RoutingSolution::SerializeToSolutionFile |
( |
RoutingOutputFormat | format | ) |
const |
|
inline |
Serializes the full solution to the given file, including metadata like instance name or total cost, depending on the format. For TSPLIB, solution files are typically called "tours".
Definition at line 170 of file solution_serializer.h.
◆ SerializeToString()
std::string operations_research::RoutingSolution::SerializeToString |
( |
RoutingOutputFormat | format | ) |
const |
|
inline |
Serializes the bare solution to a string, i.e. only the routes for the vehicles, without other metadata that is typically present in solution files.
Definition at line 152 of file solution_serializer.h.
◆ SetAuthors()
void operations_research::RoutingSolution::SetAuthors |
( |
std::string_view | authors | ) |
|
|
inline |
◆ SetName()
void operations_research::RoutingSolution::SetName |
( |
std::string_view | name | ) |
|
|
inline |
◆ SetTotalCost()
void operations_research::RoutingSolution::SetTotalCost |
( |
int64_t | total_cost | ) |
|
|
inline |
◆ SetTotalDistance()
void operations_research::RoutingSolution::SetTotalDistance |
( |
int64_t | total_distance | ) |
|
|
inline |
◆ SetTotalTime()
void operations_research::RoutingSolution::SetTotalTime |
( |
double | total_time | ) |
|
|
inline |
◆ SplitRoutes()
std::vector< std::vector< int64_t > > operations_research::RoutingSolution::SplitRoutes |
( |
const std::vector< int64_t > & | solution, |
|
|
int64_t | separator ) |
|
static |
Public-facing builders.
Splits a list of nodes whose routes are separated by the given separator (TSPLIB uses -1; it is crucial that the separator cannot be a node) into a vector per route, for use in FromSplit* functions.
The solution vector separates routes by -1: split this vector into a vector per route, where the other helpers can make the rest of the way to a proper RoutingSolution object.
Definition at line 47 of file solution_serializer.cc.
◆ WriteToSolutionFile()
void operations_research::RoutingSolution::WriteToSolutionFile |
( |
RoutingOutputFormat | format, |
|
|
const std::string & | file_name ) const |
Serializes the full solution to the given file, including metadata like instance name or total cost, depending on the format.
Definition at line 85 of file solution_serializer.cc.
The documentation for this class was generated from the following files: