Struct Vehicle

Struct Documentation

struct Vehicle

Public Functions

Vehicle(const int id = 0, const int load = 0, const int capacity = 0)

Constructor.

Constructor of vehicle struct

Return
no return value
Parameters
  • id: Vehicle id
  • load: Current vehicle load
  • capacity: Maximum vehicle capacity (initial load)

void CalculateCost(const std::vector<std::vector<double>> &distanceMatrix)

Calculates cost of the visiting the nodes in order.

Calculates cost of the route nd updates the cost variable

Return
void
Parameters
  • distanceMatrix: Holds the distances between each pair of nodes

Public Members

int id_
int load_
int capacity_
double cost_ = 0
std::vector<int> nodes_

Friends

std::ostream &operator<<(std::ostream &os, const Vehicle &v)

Overloads the << operator to print the data in the Vehicle struct.

Return
ostream
Parameters
  • os: ostream to which the printing is to be done
  • v: vehicle who’s status is to be printed