133 if (params.current_gen == 0)
135 log <<
"generation" <<
sep
137 <<
"best_score" <<
sep
138 <<
"best_score_val" <<
sep
139 <<
"med_score" <<
sep
140 <<
"med_score_val" <<
sep
142 <<
"med_complexity" <<
sep
144 <<
"max_complexity" <<
"\n";
146 log << params.current_gen <<
sep
147 << timer.Elapsed().count() <<
sep
148 << stats.best_score.back() <<
sep
149 << stats.best_score_v.back() <<
sep
150 << stats.med_score.back() <<
sep
151 << stats.med_score_v.back() <<
sep
152 << stats.med_size.back() <<
sep
153 << stats.med_complexity.back() <<
sep
154 << stats.max_size.back() <<
sep
155 << stats.max_complexity.back() <<
"\n";
163 for (
unsigned int i = 0;
i<50; ++
i)
169 std::cout.precision(5);
170 std::cout << std::scientific;
172 if(params.max_time == -1)
173 std::cout <<
"Generation " << params.current_gen+1 <<
"/"
174 << params.max_gens <<
" [" +
bar +
space +
"]\n";
176 std::cout << std::fixed <<
"Time elapsed "<< timer
177 <<
"/" << params.max_time
178 <<
" seconds (Generation "<< params.current_gen+1
181 std::cout << std::fixed
182 <<
"Train Loss (Med): " << stats.best_score.back() <<
" (" << stats.med_score.back() <<
")\n"
183 <<
"Val Loss (Med): " << stats.best_score_v.back() <<
" (" << stats.med_score_v.back() <<
")\n"
184 <<
"Median Size (Max): " << stats.med_size.back() <<
" (" << stats.max_size.back() <<
")\n"
185 <<
"Median complexity (Max): " << stats.med_complexity.back() <<
" (" << stats.max_complexity.back() <<
")\n"
186 <<
"Time (s): " << timer
332 if (params.load_population !=
"")
333 this->pop.load(params.load_population);
335 this->pop.init(this->ss, this->params);
339 if (!params.logfile.empty())
340 log.open(params.logfile, std::ofstream::app);
342 evaluator.set_scorer(params.scorer_);
347 if (params.n_jobs == -1)
348 threads = std::thread::hardware_concurrency();
349 else if (params.n_jobs == 0)
356 assert( (
executor.num_workers() > 0) &&
"Invalid number of workers");
361 unsigned generation = 0;
368 return ( (generation == params.max_gens)
369 && ((params.max_stall == 0 ||
stall_count < params.max_stall)
370 && (params.max_time == -1 || params.max_time > timer.Elapsed().count()) )
384 for (
int i=0;
i< params.num_islands;
i++){
385 size_t idx_start = std::floor(
i*params.pop_size/params.num_islands);
386 size_t idx_end = std::floor((
i+1)*params.pop_size/params.num_islands);
405 params.set_current_gen(generation);
407 }).name(
"prepare generation");
410 evaluator.update_fitness(this->pop, island, data, params, true);
415 evaluator.update_fitness(this->pop, island, batch, params, false);
417 vector<size_t> parents = selector.select(this->pop, island, params);
419 for (int i=0; i< parents.size(); i++){
420 island_parents.at(island).at(i) = parents.at(i);
425 evaluator.update_fitness(this->pop,
island, data, params,
true);
428 evaluator.update_fitness(this->pop,
island,
batch, params,
false);
436 }).name(
"runs one generation at each island in parallel");
441 }).name(
"update, migrate and disentangle indexes between islands");
446 if ( (params.verbosity>1 || !params.logfile.empty() )
447 || params.use_arch ) {
452 archive.update(pop, params);
454 fraction = params.max_time == -1 ? ((generation+1)*1.0)/params.max_gens :
455 timer.Elapsed().count()/params.max_time;
457 if(params.verbosity>1)
459 else if(params.verbosity == 1)
462 if (!params.logfile.empty())
472 }).name(
"update best, log, archive, stall");
483 if (params.save_population !=
"")
484 this->pop.save(params.save_population);
486 this->set_is_fitted(
true);
494 if (!params.use_arch)
496 archive.individuals.resize(0);
502 archive.individuals.push_back( *pop.individuals.at(
indices.at(
i)) );
511 cond.name(
"termination");
512 body.name(
"main loop");