FIMS  v0.11.0
Loading...
Searching...
No Matches
growth_model_adapter.hpp
Go to the documentation of this file.
1
6#ifndef POPULATION_DYNAMICS_GROWTH_MODEL_ADAPTER_HPP
7#define POPULATION_DYNAMICS_GROWTH_MODEL_ADAPTER_HPP
8
9#include <cmath>
10#include <memory>
11#include <stdexcept>
12
15#include "growth_model.hpp"
18
19namespace fims_popdy {
20
25template <typename Type>
26class GrowthDerivedObservationBase : public GrowthBase<Type> {
27 public:
28 GrowthDerivedObservationBase() : GrowthBase<Type>() {}
29 virtual ~GrowthDerivedObservationBase() = default;
30
35 virtual void SetAgeOffset(double min_age) = 0;
36
43 virtual void Initialize(std::size_t n_years, std::size_t n_ages,
44 std::size_t n_sexes = 1) = 0;
45
52 virtual bool SupportsAgeToLengthConversionDerived() const = 0;
53
57 virtual void PrepareGrowthProducts() = 0;
58
64
70 virtual Type EvaluateWeightAtLength(const Type& length) const = 0;
71};
72
77template <typename Type>
78class VonBertalanffySchnuteGrowthModelAdapter
79 : public GrowthDerivedObservationBase<Type> {
80 public:
81 VonBertalanffySchnuteGrowthModelAdapter()
82 : GrowthDerivedObservationBase<Type>() {}
83
88 kEstimatedReferenceLengths = 0,
89 kConstantLengthYoungEstimatedLengthOld,
90 kEstimatedLengthYoungBelowConstantLengthOld,
91 kBothConstant
92 };
93
98 length_reference_parameterization_ =
99 LengthReferenceParameterization::kEstimatedReferenceLengths;
100 growth_products_prepared_ = false;
101 }
102
110 Type constant_mean_length_young) {
111 length_reference_parameterization_ =
112 LengthReferenceParameterization::kConstantLengthYoungEstimatedLengthOld;
113 constant_mean_length_young_ = constant_mean_length_young;
114 growth_products_prepared_ = false;
115 }
116
124 Type constant_mean_length_old) {
125 length_reference_parameterization_ = LengthReferenceParameterization::
126 kEstimatedLengthYoungBelowConstantLengthOld;
127 constant_mean_length_old_ = constant_mean_length_old;
128 growth_products_prepared_ = false;
129 }
130
139 void UseConstantReferenceMeanLengths(Type constant_mean_length_young,
140 Type constant_mean_length_old) {
141 length_reference_parameterization_ =
142 LengthReferenceParameterization::kBothConstant;
143 constant_mean_length_young_ = constant_mean_length_young;
144 constant_mean_length_old_ = constant_mean_length_old;
145 growth_products_prepared_ = false;
146 }
147
154 use_param_vectors_ = true;
155 vb_params_set_ = true;
156 growth_products_prepared_ = false;
157 return mean_length_young_vector_;
158 }
159
165 use_param_vectors_ = true;
166 vb_params_set_ = true;
167 growth_products_prepared_ = false;
168 return mean_length_old_vector_;
169 }
170
177 use_param_vectors_ = true;
178 vb_params_set_ = true;
179 growth_products_prepared_ = false;
180 return growth_coefficient_vector_;
181 }
182
188 use_param_vectors_ = true;
189 vb_params_set_ = true;
190 growth_products_prepared_ = false;
191 return reference_age_for_length_young_vector_;
192 }
193
199 use_param_vectors_ = true;
200 vb_params_set_ = true;
201 growth_products_prepared_ = false;
202 return reference_age_for_length_old_vector_;
203 }
204
210 use_param_vectors_ = true;
211 lw_params_set_ = true;
212 growth_products_prepared_ = false;
213 return length_weight_a_vector_;
214 }
215
221 use_param_vectors_ = true;
222 lw_params_set_ = true;
223 growth_products_prepared_ = false;
224 return length_weight_b_vector_;
225 }
226
232 use_param_vectors_ = true;
233 growth_products_prepared_ = false;
234 return length_at_age_sd_young_vector_;
235 }
236
242 use_param_vectors_ = true;
243 growth_products_prepared_ = false;
244 return length_at_age_sd_old_vector_;
245 }
246
252 use_param_vectors_ = true;
253 growth_products_prepared_ = false;
254 return log_sd_mean_length_young_vector_;
255 }
256
262 use_param_vectors_ = true;
263 growth_products_prepared_ = false;
264 return log_sd_mean_length_old_vector_;
265 }
266
272 use_param_vectors_ = true;
273 growth_products_prepared_ = false;
274 return log_sd_growth_coefficient_vector_;
275 }
276
283 use_param_vectors_ = true;
284 growth_products_prepared_ = false;
285 return mean_length_young_mean_length_old_logit_corr_vector_;
286 }
287
294 use_param_vectors_ = true;
295 growth_products_prepared_ = false;
296 return mean_length_young_growth_coefficient_logit_corr_vector_;
297 }
298
305 use_param_vectors_ = true;
306 growth_products_prepared_ = false;
307 return mean_length_old_growth_coefficient_logit_corr_vector_;
308 }
309
314 void SetAgeOffset(double min_age) override {
315 age_offset_ = min_age;
316 age_offset_set_ = true;
317 growth_products_prepared_ = false;
318 if (model_) {
319 model_->SetAgeOffset(static_cast<Type>(age_offset_));
320 }
321 }
322
329 void Initialize(std::size_t n_years, std::size_t n_ages,
330 std::size_t n_sexes = 1) override {
331 EnsureParamsSet();
332 if (n_sexes != 1) {
333 throw std::runtime_error(
334 "VonBertalanffySchnuteGrowthModelAdapter currently supports n_sexes "
335 "== 1");
336 }
337 n_years_ = n_years;
338 n_ages_ = n_ages;
339 n_sexes_ = n_sexes;
340 growth_products_prepared_ = false;
341 model_ = std::make_shared<GrowthModel<Type>>(n_years, n_ages, n_sexes);
342 SyncParamsToModel();
343 if (age_offset_set_) {
344 model_->SetAgeOffset(static_cast<Type>(age_offset_));
345 }
346 }
347
353 bool SupportsAgeToLengthConversionDerived() const override { return true; }
354
355 virtual const Type evaluate(int year, const double& a) override {
356 if (a < 0.0) {
357 throw std::runtime_error("Negative age not supported");
358 }
359 const double a_round = std::round(a);
360 const double tol = 1e-8;
361 if (std::fabs(a - a_round) > tol) {
362 throw std::runtime_error("Non-integer age not supported yet");
363 }
364 EnsureParamsSet();
365 const Type ref_age_young = CurrentReferenceAgeForLengthYoung();
366 const Type ref_age_old = CurrentReferenceAgeForLengthOld();
367 if (ref_age_old <= ref_age_young) {
368 throw std::runtime_error(
369 "VonBertalanffySchnuteGrowth reference_age_for_length_old must be > "
370 "reference_age_for_length_young");
371 }
372
373 if (!model_) {
374 return EvaluateWithFunctor(year, a);
375 }
376
377 SyncParamsToModel();
378 model_->Prepare();
379 const auto& p = model_->GetProducts();
380 const double offset = age_offset_set_ ? age_offset_ : 0.0;
381 const double age_index_raw = a_round - offset;
382 const double age_index_round = std::round(age_index_raw);
383 if (std::fabs(age_index_raw - age_index_round) <= tol &&
384 age_index_round >= 0.0) {
385 const std::size_t age_index = static_cast<std::size_t>(age_index_round);
386 if (age_index < p.n_ages) {
387 const std::size_t year_index =
388 (year >= 0 && static_cast<std::size_t>(year) < p.n_years)
389 ? static_cast<std::size_t>(year)
390 : static_cast<std::size_t>(0);
391 return p.MeanWAA(year_index, age_index, 0);
392 }
393 }
394
395 // Outside cached model age bins: fall back to direct functor evaluation.
396 return EvaluateWithFunctor(year, a);
397 }
398
402 void PrepareGrowthProducts() override {
403 growth_products_prepared_ = false;
404 if (!model_) {
405 if (n_ages_ == 0) {
406 throw std::runtime_error("Growth model not initialized; n_ages is 0");
407 }
408 Initialize(n_years_ == 0 ? 1 : n_years_, n_ages_,
409 n_sexes_ == 0 ? 1 : n_sexes_);
410 }
411 SyncParamsToModel();
412 model_->Prepare();
413 growth_products_prepared_ = true;
414 }
415
421 if (!model_ || !growth_products_prepared_) {
422 return nullptr;
423 }
424 return &(model_->GetProducts());
425 }
426
437 Type EvaluateWeightAtLength(const Type& length) const override {
438 EnsureParamsSet();
439 const Type length_safe = fims_math::ad_max(length, static_cast<Type>(1e-8));
440 return CurrentLengthWeightA() *
441 fims_math::pow(length_safe, CurrentLengthWeightB());
442 }
443
444 private:
445 // Stored parameter vectors on their working scales. Positive parameters
446 // use log scale, reference ages stay on the natural scale, and
447 // correlation terms use transformed working-scale values.
448 fims::Vector<Type> mean_length_young_vector_;
449 fims::Vector<Type> mean_length_old_vector_;
450 fims::Vector<Type> growth_coefficient_vector_;
451 fims::Vector<Type> reference_age_for_length_young_vector_;
452 fims::Vector<Type> reference_age_for_length_old_vector_;
453 fims::Vector<Type> length_weight_a_vector_;
454 fims::Vector<Type> length_weight_b_vector_;
455 fims::Vector<Type> length_at_age_sd_young_vector_;
456 fims::Vector<Type> length_at_age_sd_old_vector_;
457 fims::Vector<Type> log_sd_mean_length_young_vector_;
458 fims::Vector<Type> log_sd_mean_length_old_vector_;
459 fims::Vector<Type> log_sd_growth_coefficient_vector_;
460 fims::Vector<Type> mean_length_young_mean_length_old_logit_corr_vector_;
461 fims::Vector<Type> mean_length_young_growth_coefficient_logit_corr_vector_;
462 fims::Vector<Type> mean_length_old_growth_coefficient_logit_corr_vector_;
463 bool use_param_vectors_ = false;
464 LengthReferenceParameterization length_reference_parameterization_ =
465 LengthReferenceParameterization::kEstimatedReferenceLengths;
466 Type constant_mean_length_young_ = Type(0.0);
467 Type constant_mean_length_old_ = Type(0.0);
468 std::size_t n_years_ = 0;
469 std::size_t n_ages_ = 0;
470 std::size_t n_sexes_ = 1;
471 double age_offset_ = 0.0;
472 bool age_offset_set_ = false;
473 bool vb_params_set_ = false;
474 bool lw_params_set_ = false;
475 bool growth_products_prepared_ = false;
476
477 mutable std::shared_ptr<GrowthModel<Type>> model_;
478
479 Type EvaluateWithFunctor(int year, const double& a) const {
480 EnsureParamsSet();
482 vb.mean_length_young = CurrentMeanLengthYoung();
483 vb.mean_length_old = CurrentMeanLengthOld();
484 vb.growth_coefficient = CurrentGrowthCoefficient();
485 vb.reference_age_for_length_young = CurrentReferenceAgeForLengthYoung();
486 vb.reference_age_for_length_old = CurrentReferenceAgeForLengthOld();
487 vb.length_weight_a = CurrentLengthWeightA();
488 vb.length_weight_b = CurrentLengthWeightB();
489 return vb.evaluate(year, a);
490 }
491
492 void SyncParamsToModel() const {
493 if (!model_) return;
494 EnsureParamsSet();
495
496 model_->SetVonBertalanffySchnuteParameters(
497 CurrentMeanLengthYoung(), CurrentMeanLengthOld(),
498 CurrentGrowthCoefficient(), CurrentReferenceAgeForLengthYoung(),
499 CurrentReferenceAgeForLengthOld());
500 model_->SetLengthWeightParameters(CurrentLengthWeightA(),
501 CurrentLengthWeightB());
502
503 if (HasInterpolationSdInputs()) {
504 model_->SetLengthSdParams(CurrentLengthAtAgeSdAtReferenceAge1(),
505 CurrentLengthAtAgeSdAtReferenceAge2());
506 }
507
508 if (HasStructuredDeltaMethodInputs()) {
509 model_->SetGrowthParameterCovariance(
510 CurrentMeanLengthYoungVariance(),
511 CurrentMeanLengthYoungLengthAtRefAgeOldCovariance(),
512 CurrentMeanLengthYoungKCovariance(), CurrentMeanLengthOldVariance(),
513 CurrentMeanLengthOldKCovariance(),
514 CurrentGrowthCoefficientVariance());
515 } else {
516 model_->ClearGrowthParameterCovariance();
517 }
518 }
519
520 Type CurrentMeanLengthYoungStorage() const {
521 return fims_math::exp(mean_length_young_vector_[0]);
522 }
523
524 Type CurrentMeanLengthOldStorage() const {
525 return fims_math::exp(mean_length_old_vector_[0]);
526 }
527
528 Type CurrentMeanLengthYoung() const {
529 switch (length_reference_parameterization_) {
530 case LengthReferenceParameterization::kEstimatedReferenceLengths:
531 return CurrentMeanLengthYoungStorage();
532
533 case LengthReferenceParameterization::
534 kConstantLengthYoungEstimatedLengthOld:
535 return constant_mean_length_young_;
536
537 case LengthReferenceParameterization::
538 kEstimatedLengthYoungBelowConstantLengthOld:
539 return fims_math::inv_logit(static_cast<Type>(0.0),
540 constant_mean_length_old_,
541 mean_length_young_vector_[0]);
542
543 case LengthReferenceParameterization::kBothConstant:
544 return constant_mean_length_young_;
545 }
546
547 return CurrentMeanLengthYoungStorage();
548 }
549
550 Type CurrentMeanLengthOld() const {
551 switch (length_reference_parameterization_) {
552 case LengthReferenceParameterization::kEstimatedReferenceLengths:
553 case LengthReferenceParameterization::
554 kConstantLengthYoungEstimatedLengthOld:
555 return CurrentMeanLengthOldStorage();
556
557 case LengthReferenceParameterization::
558 kEstimatedLengthYoungBelowConstantLengthOld:
559 return constant_mean_length_old_;
560
561 case LengthReferenceParameterization::kBothConstant:
562 return constant_mean_length_old_;
563 }
564
565 return CurrentMeanLengthOldStorage();
566 }
567
568 Type CurrentGrowthCoefficient() const {
569 return fims_math::exp(growth_coefficient_vector_[0]);
570 }
571 Type CurrentReferenceAgeForLengthYoung() const {
572 return reference_age_for_length_young_vector_[0];
573 }
574 Type CurrentReferenceAgeForLengthOld() const {
575 return reference_age_for_length_old_vector_[0];
576 }
577 Type CurrentLengthWeightA() const {
578 return fims_math::exp(length_weight_a_vector_[0]);
579 }
580 Type CurrentLengthWeightB() const {
581 return fims_math::exp(length_weight_b_vector_[0]);
582 }
583 Type CurrentLengthAtAgeSdAtReferenceAge1() const {
584 return fims_math::exp(length_at_age_sd_young_vector_[0]);
585 }
586 Type CurrentLengthAtAgeSdAtReferenceAge2() const {
587 return fims_math::exp(length_at_age_sd_old_vector_[0]);
588 }
589 Type CurrentSdLengthAtRefAgeYoung() const {
590 return fims_math::exp(log_sd_mean_length_young_vector_[0]);
591 }
592
593 Type CurrentSdLengthAtRefAgeOld() const {
594 return fims_math::exp(log_sd_mean_length_old_vector_[0]);
595 }
596
597 Type CurrentSdGrowthCoefficient() const {
598 return fims_math::exp(log_sd_growth_coefficient_vector_[0]);
599 }
600
601 Type CurrentCorrLengthAtRefAgeYoungLengthAtRefAgeOld() const {
603 static_cast<Type>(-1.0), static_cast<Type>(1.0),
604 mean_length_young_mean_length_old_logit_corr_vector_[0]);
605 }
606
607 Type CurrentCorrLengthAtRefAgeYoungK() const {
609 static_cast<Type>(-1.0), static_cast<Type>(1.0),
610 mean_length_young_growth_coefficient_logit_corr_vector_[0]);
611 }
612
613 Type CurrentCorrLengthAtRefAgeOldK() const {
615 static_cast<Type>(-1.0), static_cast<Type>(1.0),
616 mean_length_old_growth_coefficient_logit_corr_vector_[0]);
617 }
618
619 Type CurrentMeanLengthYoungVariance() const {
620 const Type sd = CurrentSdLengthAtRefAgeYoung();
621 return sd * sd;
622 }
623
624 Type CurrentMeanLengthOldVariance() const {
625 const Type sd = CurrentSdLengthAtRefAgeOld();
626 return sd * sd;
627 }
628
629 Type CurrentGrowthCoefficientVariance() const {
630 const Type sd = CurrentSdGrowthCoefficient();
631 return sd * sd;
632 }
633
634 Type CurrentMeanLengthYoungLengthAtRefAgeOldCovariance() const {
635 return CurrentCorrLengthAtRefAgeYoungLengthAtRefAgeOld() *
636 CurrentSdLengthAtRefAgeYoung() * CurrentSdLengthAtRefAgeOld();
637 }
638
639 Type CurrentMeanLengthYoungKCovariance() const {
640 return CurrentCorrLengthAtRefAgeYoungK() * CurrentSdLengthAtRefAgeYoung() *
641 CurrentSdGrowthCoefficient();
642 }
643
644 Type CurrentMeanLengthOldKCovariance() const {
645 return CurrentCorrLengthAtRefAgeOldK() * CurrentSdLengthAtRefAgeOld() *
646 CurrentSdGrowthCoefficient();
647 }
648
649 bool HasInterpolationSdInputs() const {
650 return length_at_age_sd_young_vector_.size() > 0 ||
651 length_at_age_sd_old_vector_.size() > 0;
652 }
653
654 bool HasAnyStructuredDeltaMethodInput() const {
655 return log_sd_mean_length_young_vector_.size() > 0 ||
656 log_sd_mean_length_old_vector_.size() > 0 ||
657 log_sd_growth_coefficient_vector_.size() > 0 ||
658 mean_length_young_mean_length_old_logit_corr_vector_.size() > 0 ||
659 mean_length_young_growth_coefficient_logit_corr_vector_.size() > 0 ||
660 mean_length_old_growth_coefficient_logit_corr_vector_.size() > 0;
661 }
662
663 bool HasStructuredDeltaMethodInputs() const {
664 return log_sd_mean_length_young_vector_.size() > 0 &&
665 log_sd_mean_length_old_vector_.size() > 0 &&
666 log_sd_growth_coefficient_vector_.size() > 0 &&
667 mean_length_young_mean_length_old_logit_corr_vector_.size() > 0 &&
668 mean_length_young_growth_coefficient_logit_corr_vector_.size() > 0 &&
669 mean_length_old_growth_coefficient_logit_corr_vector_.size() > 0;
670 }
671
672 void EnsureParamsSet() const {
673 if (!use_param_vectors_ || mean_length_young_vector_.size() < 1 ||
674 mean_length_old_vector_.size() < 1 ||
675 growth_coefficient_vector_.size() < 1 ||
676 reference_age_for_length_young_vector_.size() < 1 ||
677 reference_age_for_length_old_vector_.size() < 1 ||
678 length_weight_a_vector_.size() < 1 ||
679 length_weight_b_vector_.size() < 1) {
680 throw std::runtime_error(
681 "VonBertalanffySchnuteGrowth parameters not set");
682 }
683
684 if (mean_length_young_vector_.size() != 1 ||
685 mean_length_old_vector_.size() != 1 ||
686 growth_coefficient_vector_.size() != 1 ||
687 reference_age_for_length_young_vector_.size() != 1 ||
688 reference_age_for_length_old_vector_.size() != 1 ||
689 length_weight_a_vector_.size() != 1 ||
690 length_weight_b_vector_.size() != 1) {
691 throw std::runtime_error(
692 "VonBertalanffySchnuteGrowthModelAdapter currently supports a single "
693 "growth pattern; expected size 1 for von Bertalanffy--Schnute and "
694 "length-weight parameter vectors");
695 }
696
697 const bool has_sd = HasInterpolationSdInputs();
698 const bool has_any_structured_delta = HasAnyStructuredDeltaMethodInput();
699 const bool has_structured_delta = HasStructuredDeltaMethodInputs();
700
701 if (!has_sd && !has_any_structured_delta) {
702 throw std::runtime_error(
703 "VonBertalanffySchnuteGrowthModelAdapter requires either "
704 "both length_at_age_sd_young and length_at_age_sd_old, "
705 "or the structured delta-method growth variability inputs");
706 }
707
708 if (has_any_structured_delta && !has_structured_delta) {
709 throw std::runtime_error(
710 "VonBertalanffySchnuteGrowthModelAdapter requires all six structured "
711 "delta-method variability inputs when using that path");
712 }
713
714 if (has_sd && has_structured_delta) {
715 throw std::runtime_error(
716 "von Bertalanffy--Schnute growth adapter requires variability inputs "
717 "for exactly one supported path. Supply either the interpolation "
718 "inputs length_at_age_sd_young and length_at_age_sd_old or the full "
719 "delta-method variability inputs, but not both");
720 }
721
722 if (has_sd && (length_at_age_sd_young_vector_.size() != 1 ||
723 length_at_age_sd_old_vector_.size() != 1)) {
724 throw std::runtime_error(
725 "VonBertalanffySchnuteGrowthModelAdapter requires exactly one "
726 "length_at_age_sd_young value and one length_at_age_sd_old value");
727 }
728
729 if (has_structured_delta &&
730 (log_sd_mean_length_young_vector_.size() != 1 ||
731 log_sd_mean_length_old_vector_.size() != 1 ||
732 log_sd_growth_coefficient_vector_.size() != 1 ||
733 mean_length_young_mean_length_old_logit_corr_vector_.size() != 1 ||
734 mean_length_young_growth_coefficient_logit_corr_vector_.size() != 1 ||
735 mean_length_old_growth_coefficient_logit_corr_vector_.size() != 1)) {
736 throw std::runtime_error(
737 "VonBertalanffySchnuteGrowthModelAdapter currently supports a single "
738 "structured delta-method variability parameter set; expected "
739 "size 1 for each structured uncertainty input");
740 }
741 }
742};
743
744} // namespace fims_popdy
745
746#endif // POPULATION_DYNAMICS_GROWTH_MODEL_ADAPTER_HPP
Definition fims_vector.hpp:27
virtual bool SupportsAgeToLengthConversionDerived() const =0
Report whether this growth object can support the dynamic age-to-length conversion path.
virtual void Initialize(std::size_t n_years, std::size_t n_ages, std::size_t n_sexes=1)=0
Initialize any cached growth products.
virtual void SetAgeOffset(double min_age)=0
Set the minimum modeled age used to translate cached age indices.
virtual void PrepareGrowthProducts()=0
Prepare growth products for the current model state.
virtual Type EvaluateWeightAtLength(const Type &length) const =0
Evaluate weight at a supplied length.
virtual const GrowthProducts< Type > * TryGetPreparedGrowthProducts() const =0
Return prepared growth products without triggering preparation.
LengthReferenceParameterization
Options for how the two reference lengths are supplied.
Definition growth_model_adapter.hpp:87
void UseConstantReferenceMeanLengths(Type constant_mean_length_young, Type constant_mean_length_old)
Fix both young and old reference mean lengths.
Definition growth_model_adapter.hpp:139
fims::Vector< Type > & LogSdGrowthCoefficientVector()
Access the log-SD vector for growth_coefficient.
Definition growth_model_adapter.hpp:271
virtual const Type evaluate(int year, const double &a) override
Calculates the growth at the independent variable value.
Definition growth_model_adapter.hpp:355
fims::Vector< Type > & LogitCorrLengthAtRefAgeYoungKVector()
Access the transformed correlation vector for mean_length_young and growth_coefficient.
Definition growth_model_adapter.hpp:293
fims::Vector< Type > & LogSdLengthAtRefAgeOldVector()
Access the log-SD vector for mean_length_old.
Definition growth_model_adapter.hpp:261
fims::Vector< Type > & ReferenceAgeForLengthYoungVector()
Access the first reference-age vector.
Definition growth_model_adapter.hpp:187
void SetAgeOffset(double min_age) override
Set the minimum modeled age used by cached growth products.
Definition growth_model_adapter.hpp:314
bool SupportsAgeToLengthConversionDerived() const override
Report that the adapter supports growth-derived age-to-length conversion calculations.
Definition growth_model_adapter.hpp:353
fims::Vector< Type > & LengthWeightAVector()
Access the log-scale length-weight-a vector.
Definition growth_model_adapter.hpp:209
void Initialize(std::size_t n_years, std::size_t n_ages, std::size_t n_sexes=1) override
Initialize the backing growth model and cache dimensions.
Definition growth_model_adapter.hpp:329
fims::Vector< Type > & LogitCorrLengthAtRefAgeOldKVector()
Access the transformed correlation vector for mean_length_old and growth_coefficient.
Definition growth_model_adapter.hpp:304
fims::Vector< Type > & ReferenceAgeForLengthOldVector()
Access the second reference-age vector.
Definition growth_model_adapter.hpp:198
void UseEstimatedMeanLengthYoungBelowConstantMeanLengthOld(Type constant_mean_length_old)
Estimate young reference length below a fixed old reference length.
Definition growth_model_adapter.hpp:123
Type EvaluateWeightAtLength(const Type &length) const override
Evaluate the length-weight relationship at a supplied length.
Definition growth_model_adapter.hpp:437
fims::Vector< Type > & MeanLengthOldVector()
Access the log-scale length-at-reference-age-2 parameter vector.
Definition growth_model_adapter.hpp:164
fims::Vector< Type > & LengthWeightBVector()
Access the log-scale length-weight-b vector.
Definition growth_model_adapter.hpp:220
fims::Vector< Type > & LogitCorrLengthAtRefAgeYoungLengthAtRefAgeOldVector()
Access the transformed correlation vector for mean_length_young and mean_length_old.
Definition growth_model_adapter.hpp:282
void UseEstimatedReferenceMeanLengths()
Estimate both reference mean lengths.
Definition growth_model_adapter.hpp:97
void PrepareGrowthProducts() override
Prepare growth products for the current model state.
Definition growth_model_adapter.hpp:402
fims::Vector< Type > & MeanLengthYoungVector()
Access the working-scale storage for the first reference-length parameter.
Definition growth_model_adapter.hpp:153
const GrowthProducts< Type > * TryGetPreparedGrowthProducts() const override
Return prepared growth products without triggering preparation.
Definition growth_model_adapter.hpp:420
fims::Vector< Type > & LogSdLengthAtRefAgeYoungVector()
Access the log-SD vector for mean_length_young.
Definition growth_model_adapter.hpp:251
fims::Vector< Type > & GrowthCoefficientVector()
Access the log-scale VonBertalanffySchnute growth coefficient vector.
Definition growth_model_adapter.hpp:176
fims::Vector< Type > & LengthAtAgeSdYoungVector()
Access the log-scale length-at-age SD at the younger reference age.
Definition growth_model_adapter.hpp:231
fims::Vector< Type > & LengthAtAgeSdOldVector()
Access the log-scale length-at-age SD at the older reference age.
Definition growth_model_adapter.hpp:241
void UseConstantMeanLengthYoungWithEstimatedMeanLengthOld(Type constant_mean_length_young)
Fix young reference length and estimate older reference mean length.
Definition growth_model_adapter.hpp:109
A collection of mathematical functions used in FIMS.
const Type ad_max(const Type &a, const Type &b, Type C=1e-5)
Definition fims_math.hpp:380
const Type inv_logit(const Type &a, const Type &b, const Type &logit_x)
An inverse logit function for bounding of parameters.
Definition fims_math.hpp:276
Establishes the FIMS Vector class.
Declares the GrowthBase class which is the base class for all growth functors.
Concrete growth model implementation (Phase 1).
The population dynamics of FIMS.
Definition catch_at_age.hpp:45
GrowthBase()
Constructor.
Definition growth_base.hpp:34
Growth "products" in a consistent (year, age, sex) space.
Definition growth_products.hpp:26
VonBertalanffySchnute growth functor for length-at-age and weight-at-age.
Definition vonb_schnute.hpp:32
Type mean_length_young
Expected length at the first reference age.
Definition vonb_schnute.hpp:34
Type reference_age_for_length_old
Second reference age for the length parameterization.
Definition vonb_schnute.hpp:42
Type growth_coefficient
Growth coefficient.
Definition vonb_schnute.hpp:38
Type length_weight_b
Exponent in the length-weight relationship, W = a * L^b.
Definition vonb_schnute.hpp:47
Type reference_age_for_length_young
First reference age for the length parameterization.
Definition vonb_schnute.hpp:40
Type length_weight_a
Coefficient in the length-weight relationship, W = a * L^b.
Definition vonb_schnute.hpp:45
virtual const Type evaluate(int year, const double &a) override
Calculates the growth at the independent variable value.
Definition vonb_schnute.hpp:194
Type mean_length_old
Expected length at the second reference age.
Definition vonb_schnute.hpp:36
Defines the VonBertalanffySchnuteGrowth class, which inherits from the GrowthBase class.