13#if !defined(ULTRA_ALPS_H)
56 : layers_{std::ref(l), std::ref(l)}, has_secondary_(
false) {}
65 : layers_{std::ref(p), std::ref(s)}, has_secondary_(
true) {}
68 [[nodiscard]]
constexpr std::size_t
size() const noexcept
70 return 1 +
static_cast<std::size_t
>(has_secondary_);
76 return has_secondary_;
80 [[nodiscard]]
constexpr auto begin() const noexcept
82 return layers_.begin();
86 [[nodiscard]]
constexpr auto end() const noexcept
88 return layers_.begin() +
static_cast<std::ptrdiff_t
>(
size());
92 [[nodiscard]]
constexpr Layer &
primary() const noexcept
94 return layers_[0].get();
100 [[nodiscard]]
constexpr Layer &
secondary() const noexcept
103 return layers_[1].get();
117 [[nodiscard]] Layer &
random(
double p_pri)
const
119 Expects(in_0_1(p_pri));
124 std::array<std::reference_wrapper<Layer>, 2> layers_;
125 bool has_secondary_ {
false};
152 [[nodiscard]]
unsigned max_age(std::size_t)
const;
153 [[nodiscard]]
unsigned max_age(std::size_t, std::size_t)
const;
181template<LayeredPopulation P>
184 const auto layers(pop.layers());
188 const auto ¶ms(pop.problem().params);
190 for (std::size_t l(0); l < layers; ++l)
191 pop.layer(l).max_age(params.alps.max_age(l, layers));
218template<LayeredPopulation P>
219alps_layer_pair<typename P::layer_t>
222 Expects(pop.layers());
223 Expects(iterator_of(l, pop.range_of_layers()));
225 if (l == std::prev(pop.range_of_layers().end()))
228 return {*l, pop.back()};
255template<LayeredPopulation P>
259 Expects(pop.layers());
260 Expects(iterator_of(l, pop.range_of_layers()));
262 if (l == pop.range_of_layers().begin())
265 return {*l, *std::prev(l)};
alps_layer_pair< typename P::layer_t > replacement_layers(P &pop, typename P::layer_iter l)
Definition alps.h:220
alps_layer_pair< const typename P::layer_t > selection_layers(const P &pop, typename P::layer_const_iter l)
Definition alps.h:257
constexpr auto begin() const noexcept
Definition alps.h:80
alps_layer_pair(Layer &p, Layer &s) noexcept
Definition alps.h:64
constexpr Layer & secondary() const noexcept
Definition alps.h:100
constexpr std::size_t size() const noexcept
Definition alps.h:68
constexpr Layer & primary() const noexcept
Definition alps.h:92
alps_layer_pair(Layer &l) noexcept
Definition alps.h:55
constexpr bool has_secondary() const noexcept
Definition alps.h:74
Layer & random(double p_pri) const
Definition alps.h:117
constexpr auto end() const noexcept
Definition alps.h:86
bool boolean(double p)
Definition random.h:154
unsigned max_age(std::size_t) const
Definition alps.cc:30
double p_main_layer
Definition alps.h:178
std::size_t max_layers
Maximum number of layers an ALPS layered population can grow to.
Definition alps.h:172
unsigned age_gap
Definition alps.h:169