9#ifndef __SIMULATORS_UTILS_H_INCLUDED__
10#define __SIMULATORS_UTILS_H_INCLUDED__
12#include "../coalescence/container/Forest.hpp"
13#include "../coalescence/merger_policy.hpp"
14#include "../demography/History.hpp"
21template <
typename Env,
typename F>
struct neighbor_migration
24 using coord_type =
typename Env::coord_type;
28 env_type
const &_landscape;
31 neighbor_migration(env_type
const &env, F f) : _landscape(env), _f(f)
35 template <
typename T> std::vector<coord_type> arrival_space(coord_type
const &x,
const T &)
const
37 auto v = _landscape.four_nearest_defined_cells(x);
42 template <
typename T>
double operator()(coord_type
const &x, coord_type
const &y, T
const &t)
const
44 auto v = arrival_space(x, t);
45 auto binop = [
this, t](
auto const &a,
auto const &b) {
return a + _f(b, t); };
46 double sum = std::accumulate(v.begin(), v.end(), 0.0, binop);
47 return _f(y, t) / sum;
51template <
typename Env,
typename F>
auto make_neighbor_migration(Env
const &env, F f)
53 return neighbor_migration<Env, F>(env, f);
Simulation of coalescence-based models of molecular evolution.
Definition coalescence.hpp:21