9#ifndef FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_GROWTH_HPP
10#define FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_GROWTH_HPP
12#include "../../../population_dynamics/growth/growth.hpp"
34 static std::map<uint32_t, std::shared_ptr<GrowthInterfaceBase>>
live_objects;
74std::map<uint32_t, std::shared_ptr<GrowthInterfaceBase>>
101 std::shared_ptr<std::map<int, std::map<double, double>>>
ewaa;
111 this->ewaa = std::make_shared<std::map<int, std::map<double, double>>>();
113 std::make_shared<EWAAGrowthInterface>(*
this);
115 std::make_shared<EWAAGrowthInterface>(*
this));
148 std::map<int, std::map<double, double>>
mymap;
154 Rcpp::stop(
"EWAA Error:: n_years must be at least 1");
159 Rcpp::stop(
"EWAA Error:: ages and weights must have at least one value");
167 Rcpp::stop(
"weights size does not match ages size or ages size times "
168 "(n_years + 1), where the plus one is for the beginning "
169 "of the year after the terminal year spawning-biomass "
202 EWAAGrowth.
ewaa =
make_map(this->ages, this->weights, this->n_years);
207 "this empirical weight at age object is already initialized");
220 std::stringstream
ss;
222 ss <<
" \"module_name\": \"Growth\",\n";
223 ss <<
" \"module_type\": \"EWAA\",\n";
224 ss <<
" \"module_id\":" << this->
id <<
",\n";
225 ss <<
" \"parameters\": [\n{\n";
226 ss <<
" \"name\": \"weight_at_age\",\n";
227 ss <<
" \"id\": null,\n";
228 ss <<
" \"type\": \"vector\",\n";
229 ss <<
" \"dimensionality\": {\n";
230 ss <<
" \"header\": [\"n_years+1\",\"n_ages\"],\n";
231 ss <<
" \"dimensions\": [" << this->n_years.
get() + 1 <<
"," << this->ages.
size() <<
"]\n},\n";
233 ss <<
" \"values\": [\n";
236 ss <<
"\"id\": null,\n";
238 ss <<
"\"estimated_value\": " <<
weights[
i] <<
",\n";
239 ss <<
"\"estimation_type\": \"constant\"\n";
243 ss <<
"\"id\": null,\n";
246 ss <<
"\"estimation_type\": \"constant\"\n";
255 std::shared_ptr<fims_info::Information<Type>>
info =
258 std::shared_ptr<fims_popdy::EWAAGrowth<Type>>
ewaa_growth =
259 std::make_shared<fims_popdy::EWAAGrowth<Type>>();
264 make_map(this->ages, this->weights, this->n_years);
Rcpp interface for EWAAGrowth to instantiate the object from R: ewaa <- methods::new(EWAAGrowth)....
Definition rcpp_growth.hpp:82
virtual ~EWAAGrowthInterface()
The destructor.
Definition rcpp_growth.hpp:131
SharedInt n_years
An integer specifying the number of years.
Definition rcpp_growth.hpp:96
std::shared_ptr< std::map< int, std::map< double, double > > > ewaa
A map of empirical weight-at-age values allowing multiple modules to access and modify the weights wi...
Definition rcpp_growth.hpp:101
virtual uint32_t get_id()
Gets the ID of the interface base object.
Definition rcpp_growth.hpp:137
RealVector ages
Ages (years) for each age class.
Definition rcpp_growth.hpp:91
virtual double evaluate(double age)
Evaluate the growth using empirical weight at age.
Definition rcpp_growth.hpp:196
EWAAGrowthInterface(const EWAAGrowthInterface &other)
Construct a new EWAAGrowthInterface object.
Definition rcpp_growth.hpp:123
std::map< int, std::map< double, double > > make_map(RealVector ages, RealVector weights, SharedInt n_years)
Create a map of input numeric vectors.
Definition rcpp_growth.hpp:146
bool initialized
Have weight and age vectors been set? The default is false.
Definition rcpp_growth.hpp:105
RealVector weights
Weights (mt) for each age class.
Definition rcpp_growth.hpp:87
EWAAGrowthInterface()
The constructor.
Definition rcpp_growth.hpp:110
virtual std::string to_json()
Converts the data to json representation for the output.
Definition rcpp_growth.hpp:219
Base class for all interface objects.
Definition rcpp_interface_base.hpp:574
static std::vector< std::shared_ptr< FIMSRcppInterfaceBase > > fims_interface_objects
FIMS interface object vectors.
Definition rcpp_interface_base.hpp:584
virtual bool add_to_fims_tmb()
A virtual method to inherit to add objects to the TMB model.
Definition rcpp_interface_base.hpp:589
Rcpp interface that serves as the parent class for Rcpp growth interfaces. This type should be inheri...
Definition rcpp_growth.hpp:19
static std::map< uint32_t, std::shared_ptr< GrowthInterfaceBase > > live_objects
The map associating the IDs of GrowthInterfaceBase to the objects. This is a live object,...
Definition rcpp_growth.hpp:34
virtual double evaluate(double age)=0
A method for each child growth interface object to inherit so each growth option can have an evaluate...
GrowthInterfaceBase(const GrowthInterfaceBase &other)
Construct a new Growth Interface Base object.
Definition rcpp_growth.hpp:52
static uint32_t id_g
The static id of the GrowthInterfaceBase object.
Definition rcpp_growth.hpp:24
virtual ~GrowthInterfaceBase()
The destructor.
Definition rcpp_growth.hpp:57
GrowthInterfaceBase()
The constructor.
Definition rcpp_growth.hpp:39
uint32_t id
The local id of the GrowthInterfaceBase object.
Definition rcpp_growth.hpp:28
virtual uint32_t get_id()=0
Get the ID for the child growth interface objects to inherit.
An Rcpp interface class that defines the RealVector class.
Definition rcpp_interface_base.hpp:374
size_t size()
Returns the size of a RealVector.
Definition rcpp_interface_base.hpp:535
A class that provides shared ownership of an integer value.
Definition rcpp_shared_primitive.hpp:24
int get() const
Retrieve the value of the integer.
Definition rcpp_shared_primitive.hpp:122
void clear_internal()
Clears the internal objects.
Definition rcpp_interface.hpp:239
The Rcpp interface to declare objects that are used ubiquitously throughout the Rcpp interface,...
EWAAGrowth class that returns the EWAA function value.
Definition ewaa.hpp:23
std::map< int, std::map< double, double > > ewaa
Definition ewaa.hpp:29
virtual const Type evaluate(int year, const double &a)
Returns the weight at age a (in kg) from the input vector.
Definition ewaa.hpp:44