Class Solution

Inheritance Relationships

Derived Types

Class Documentation

class Solution

Subclassed by GASolution, GreedySolution, LocalSearchInterIntraSolution, LocalSearchIntraSolution, SimulatedAnnealingSolution, TabuSearchSolution

Public Functions

Solution(std::vector<Node> nodes, const std::vector<Vehicle> &vehicles, std::vector<std::vector<double>> distanceMatrix)

Constructor.

Constructor for solution struct

Return
no return type
Parameters
  • nodes: Vector of all nodes
  • vehicles: Vector of vehicles
  • distanceMatrix: Matrix containing distance between each pair of nodes

Solution(const Problem &p)

Constructor.

Constructor for solution struct

Return
no return type
Parameters
  • p: Instance of Problem struct defining the problem parameters

Solution(const Solution &s)

Copy constructor.

Return
no return value
Parameters
  • s: object to be copied

Solution &operator=(const Solution &s)

Copy assignment.

Return
solution object
Parameters
  • s: object to be copied

Solution(Solution &&s)

Move constructor.

Return
no return value
Parameters
  • s: object to be moved

Solution &operator=(Solution &&s)

Move assignment.

Return
solution object
Parameters
  • s: object to be moved

virtual ~Solution()

Destructor.

Return
no return value

void CreateInitialSolution()

Creates initial solution.

Creates initial solution, currently set to greedy.

Return
void

bool CheckSolutionValid() const

Check whether the solution is valid.

Check whether the solution is valid by checking whether all the nodes are reached and whether the total edmand of all the nodes on any of the routes exceed the capacity of the respective vehicles

Return
bool True is solution is valid

virtual void Solve() = 0

Virtual function overloaded by solution structes to solve the given problem.

Virtual function overloaded by solution struct to solve the given problem.

Return
void

std::tuple<bool, Node> find_closest(const Vehicle &v) const

find closest node

Finds the node nearest to the last node in the route of the vehicle under constideration that has not been routed already

Return
tuple containing bool as to whether a Node was found and the nearest node
Parameters
  • v: vehicle under consideration

void PrintSolution(const std::string &option = "") const

Prints the status of solution.

Prints the solution status including cost, the vehicle status, and solution validity

Return
void
Parameters
  • option: allows the option to print routes or vehicle statuses

std::vector<Node> GetNodes() const
std::vector<Vehicle> GetVehicles() const

Protected Attributes

std::vector<Node> nodes_
std::vector<Vehicle> vehicles_
std::vector<std::vector<double>> distanceMatrix_
Node depot_
int capacity_