9#ifndef POPULATION_DYNAMICS_AGE_TO_LENGTH_CONVERSION_RUNTIME_HPP
10#define POPULATION_DYNAMICS_AGE_TO_LENGTH_CONVERSION_RUNTIME_HPP
42template <
typename Type>
43std::shared_ptr<AgeToLengthConversionBase<Type>>
47 if (
population ==
nullptr || fleet ==
nullptr) {
51 if (!fleet->requires_age_length_mapping || fleet->n_lengths == 0) {
58 std::shared_ptr<AgeToLengthConversionBase<Type>>
60 std::make_shared<AgeToLengthConversionDerived<Type>>(
67 "Growth-derived age-to-length conversion successfully set to fleet " +
68 fims::to_string(fleet->id) +
" for population " +
75 std::shared_ptr<AgeToLengthConversionBase<Type>>
77 std::make_shared<AgeToLengthConversionFixed<Type>>(fleet);
81 FIMS_INFO_LOG(
"Fixed age-to-length matrix successfully set to fleet " +
82 fims::to_string(fleet->id));
104template <
typename Type>
108 if (fleet ==
nullptr) {
109 throw std::runtime_error(
110 "Fleet pointer was null while resolving age-to-length conversion.");
114 throw std::runtime_error(
115 "Population pointer was null while resolving age-to-length "
119 if (!fleet->requires_age_length_mapping || fleet->n_lengths == 0) {
124 std::dynamic_pointer_cast<GrowthDerivedObservationBase<Type>>(
127 if (fleet->age_to_length_conversion_model !=
nullptr) {
129 std::shared_ptr<AgeToLengthConversionDerived<Type>>
131 std::dynamic_pointer_cast<AgeToLengthConversionDerived<Type>>(
132 fleet->age_to_length_conversion_model);
139 }
else if (fleet->age_to_length_conversion_model->IsActive() &&
140 fleet->age_to_length_conversion_model
141 ->PrepareForCurrentState()) {
146 fleet->age_to_length_conversion_model =
149 if (fleet->age_to_length_conversion_model !=
nullptr) {
153 std::stringstream
ss;
154 ss <<
"Fleet " << fleet->GetId()
155 <<
" has length composition bins but no usable age-to-length conversion "
159 ss <<
" This population uses a growth-derived-capable growth object, so "
160 <<
"the growth-derived age-to-length conversion path with population "
161 "size-provider support "
162 <<
"was required and could not be built or prepared.";
164 ss <<
" Provide a valid fixed age-to-length conversion matrix for this "
165 <<
"fleet or use a supported growth-derived-capable growth object.";
169 throw std::runtime_error(
ss.str());
183template <
typename Type>
187 throw std::runtime_error(
188 "Population pointer was null while resolving age-to-length "
Declares the AgeToLengthConversionBase class which is the base class for all age-length key functors.
Generic capability interface for growth models that can feed the growth-derived age-to-length convers...
Definition growth_model_adapter.hpp:26
#define FIMS_INFO_LOG(MESSAGE)
Record an info-log entry with metadata.
Definition def.hpp:636
#define FIMS_ERROR_LOG(MESSAGE)
Definition def.hpp:664
Declares the AgeToLengthConversionDerived class, which implements AgeToLengthConversionBase by mappin...
Declares the AgeToLengthConversionFixed class, which implements AgeToLengthConversionBase using a fle...
The population dynamics of FIMS.
Definition catch_at_age.hpp:45
void EnsurePopulationFleetAgeToLengthConversion(const std::shared_ptr< Population< Type > > &population)
Ensure all fleets linked to a population have a usable age-to-length conversion.
Definition runtime.hpp:184
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
void EnsureAgeToLengthConversionFleet(const std::shared_ptr< Population< Type > > &population, const std::shared_ptr< Fleet< Type > > &fleet)
Ensure a fleet has an active age-to-length conversion before length-based calculations.
Definition runtime.hpp:105
Defines the Population class and its fields and methods.
Base class for all fleets.
Definition fleet.hpp:26
Population class. Contains subpopulations that are divided into generic partitions (e....
Definition population.hpp:27