SolverEvolver::Genome SolverEvolver::random_genome() { Genome ret; for (int i = 0; i < ret.size(); ++i) { ret[i] = random_double(0.0f); } return std::move(ret); }
//Fitness: Minimize the distance along the path double fitness(const Genome& ind) { double total = 0; for(auto i= 0U; i < ind.size()-1; ++i) { if (ind[i] < ind[i+1]) { total += distances.at({ind[i], ind[i+1]}); } else { total += distances.at({ind[i+1], ind[i]}); } } return total; }