Ejemplo n.º 1
0
void Simulation::printResume(const Population &population) const {
    _display.basicLine("generation " + std::to_string(_currentGeneration) + "/" + std::to_string(config.simulationNumber));
    _display.basicLine("Best: ");
    _problem->print(population.best());
    _display.basicLine("Mid: ");
    _problem->print(population.at(config.populationSize / 2));
    _display.basicLine("Worst: ");
    _problem->print(population.worst());
    _display.newLine();
}
Ejemplo n.º 2
0
void Reporter::capture( Population& p,
		const int& i){
	//assure we can read
	if( ! datafile.good()){
		fail = true;
		return;}
	//setup
	char* buffer = new char[50];
	//write the first part
	sprintf( buffer, "%d, %f, %f, %f",
		i, p.best(), p.average(), p.worst());
	datafile << buffer << std::endl;
	//done, clean up
	datafile.flush();
	delete[] buffer;}