Closed richelbilderbeek closed 7 years ago
I'll put this in the jkr
namespace.
Plan:
I suggest from
template <class parameters, class simulation, class results>
void do_experiment(const parameters& p)
{
simulation s = create_simulation(p);
run(s);
save_ltt_plot(get_results(s), get_ltt_plot_filename(p));
}
to
template <class parameters, class simulation, class results>
void do_experiment(const parameters& p)
{
simulation s = create_simulation(p);
const int n_generations = get_n_generations(p);
for (int t=0; t!=n_generations; ++t)
{
const auto next_population = create_next_population(s);
set_population(s, next_population);
}
save_ltt_plot(get_results(s), get_ltt_plot_filename(p));
}
Sure, the get/set can be done in one line, but, thanks to auto
, the rigidity of the function would not change from that.
Agree on this?
Suggestion for next iteration:
create_next_population
only reads from simulation
template <class parameters, class simulation, class results>
void do_experiment(const parameters& p)
{
simulation s = create_simulation(p);
const int n_generations = get_n_generations(p);
std::mt19937 rng_engine(get_rng_seed(p));
for (int t=0; t!=n_generations; ++t)
{
const auto next_population
= create_next_population(
const_cast<const simulation&>(s), //Enforce only reading the simulation
rng_engine
);
set_population(s, next_population);
}
save_ltt_plot(get_results(s), get_ltt_plot_filename(p));
}
Agree on this?
This goes just fine, closing this Issue for now.
To ensure that we all do our experiment in the same way, a template function should be written, ensuring we do things in the same way.
This must be done by the team as a whole. I suggest I write a first draft, then let the team modify.