Class GASolution

Inheritance Relationships

Base Type

Class Documentation

class GASolution : public Solution

Public Functions

GASolution(const std::vector<Node> &nodes, const std::vector<Vehicle> &vehicles, const std::vector<std::vector<double>> &distanceMatrix, const int n_chromosomes = 10, const int generations = 100)

Constructor.

Constructor for initial setup of problem, and solution using GA.

Return
No return parameter
Parameters
  • nodes: Vector of nodes
  • vehicles: Vector of vehicles
  • distanceMatrix: Matrix containing distance between each pair of nodes
  • n_chromosomes: Number of solutions
  • generations: Number of generations the algorithm should run for

GASolution(const Problem &p, const int n_chromosomes = 10, const int generations = 100)

Constructor.

Constructor

Return
No return parameter
Parameters
  • p: Instance of Problem class defining the problem parameters
  • n_chromosomes: Number of solutions
  • generations: Number of generations the algorithm should run for

GASolution(const Solution &s, const int n_chromosomes = 10, const int generations = 100)

Constructor.

Constructor

Return
No return parameter
Parameters
  • s: Instance of Solution class containing a valid solution and problem parameters
  • n_chromosomes: Number of solutions
  • generations: Number of generations the algorithm should run for

void Solve()

Function called to solve the given problem using Genetic Algorithm.

Generates random iniitial solutions. Applies selected algorithm. Prints cost of best solution, and its validity.

Return
void