9#ifndef FIMS_POPULATION_DYNAMICS_SIZE_BIN_MAPPING_HPP
10#define FIMS_POPULATION_DYNAMICS_SIZE_BIN_MAPPING_HPP
16#include "../size_grid.hpp"
17#include "../../../common/fims_vector.hpp"
50 if (edges.
size() < 2) {
54 for (std::size_t
i = 0;
i + 1 < edges.
size(); ++
i) {
55 if (!(edges[
i + 1] > edges[
i])) {
83 throw std::runtime_error(
84 "SizeBinMapping requires strictly increasing source and "
89 throw std::runtime_error(
90 "SizeBinMapping requires destination edges to cover the full "
157 throw std::runtime_error(
158 "SizeBinMapping requires strictly increasing source and "
159 "destination edges");
211 template <
typename Type>
218 for (std::size_t
i = 0;
i < weights.size(); ++
i) {
222 throw std::runtime_error(
223 "SizeBinMapping weight rows must match source mass length");
Definition fims_vector.hpp:27
void resize(size_t s)
Changes the number of elements stored.
Definition fims_vector.hpp:401
size_type size() const
Returns the number of elements.
Definition fims_vector.hpp:299
The population dynamics of FIMS.
Definition catch_at_age.hpp:45
std::shared_ptr< AgeToLengthConversionBase< Type > > BuildAgeToLengthConversionFleet(const std::shared_ptr< Population< Type > > &population, const std::shared_ptr< Fleet< Type > > &fleet)
Build the active age-to-length conversion for a fleet from the current population and fleet state.
Definition runtime.hpp:44
Helper for mapping population biological size bins to observed fleet bins.
Definition size_bin_mapping.hpp:28
static bool HasStrictlyIncreasingEdges(const fims::Vector< double > &edges)
Check that a bin-edge vector is usable for geometric mapping.
Definition size_bin_mapping.hpp:49
static fims::Vector< fims::Vector< double > > BuildRebinWeights(const fims::Vector< double > &source_edges, const fims::Vector< double > &destination_edges)
Build overlap-based rebin weights from source bins to destination bins.
Definition size_bin_mapping.hpp:78
static double OverlapWidth(double left_a, double right_a, double left_b, double right_b)
Return the overlap width between two 1-D closed-open intervals.
Definition size_bin_mapping.hpp:37
static bool DestinationCoversSourceRange(const fims::Vector< double > &source_edges, const fims::Vector< double > &destination_edges)
Check that the destination edges fully cover the source-bin range.
Definition size_bin_mapping.hpp:125
static fims::Vector< Type > ApplyRebinWeights(const fims::Vector< fims::Vector< double > > &weights, const fims::Vector< Type > &source_mass)
Apply a source-to-destination bin mapping to a size-mass vector.
Definition size_bin_mapping.hpp:212
static fims::Vector< double > ExpandDestinationEdgesToCoverSourceRange(const fims::Vector< double > &source_edges, const fims::Vector< double > &destination_edges)
Return explicit mapping edges whose support covers the source range while preserving the canonical de...
Definition size_bin_mapping.hpp:152