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>>
96 std::shared_ptr<std::map<double, double>>
ewaa;
106 this->ewaa = std::make_shared<std::map<double, double>>();
108 std::make_shared<EWAAGrowthInterface>(*
this);
110 std::make_shared<EWAAGrowthInterface>(*
this));
144 std::map<double, double>
mymap;
161 if (this->ages.
size() !=
this->weights.size()) {
162 Rcpp::stop(
"ages and weights must be the same length");
167 Rcpp::stop(
"this empirical weight at age object is already initialized");
180 std::stringstream
ss;
182 ss <<
" \"module_name\": \"Growth\",\n";
183 ss <<
" \"module_type\": \"EWAA\",\n";
184 ss <<
" \"module_id\":" << this->
id <<
",\n";
185 ss <<
" \"parameters\": [\n{\n";
186 ss <<
" \"name\": null,\n";
187 ss <<
" \"id\": null,\n";
188 ss <<
" \"type\": \"vector\",\n";
189 ss <<
" \"dimensionality\": {\n";
190 ss <<
" \"header\": [\"n_ages\"],\n";
191 ss <<
" \"dimensions\": [" << this->ages.
size() <<
"]\n},\n";
193 ss <<
" \"values\": [\n";
196 ss <<
"\"id\": null,\n";
198 ss <<
"\"estimated_value\": " <<
weights[
i] <<
",\n";
199 ss <<
"\"uncertainty\": " << 0 <<
",\n";
200 ss <<
"\"min\": \"-Infinity\",\n";
201 ss <<
"\"max\": \"Infinity\",\n";
202 ss <<
"\"estimation_type\": \"constant\"\n";
206 ss <<
"\"id\": null,\n";
209 ss <<
"\"uncertainty\": " << 0 <<
",\n";
210 ss <<
"\"min\": \"-Infinity\",\n";
211 ss <<
"\"max\": \"Infinity\",\n";
212 ss <<
"\"estimation_type\": \"constant\"\n";
220 template <
typename Type>
222 std::shared_ptr<fims_info::Information<Type>>
info =
225 std::shared_ptr<fims_popdy::EWAAGrowth<Type>>
ewaa_growth =
226 std::make_shared<fims_popdy::EWAAGrowth<Type>>();
230 ewaa_growth->ewaa =
make_map(this->ages, this->weights);
243#ifdef TMBAD_FRAMEWORK
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:128
std::shared_ptr< 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:96
virtual uint32_t get_id()
Gets the ID of the interface base object.
Definition rcpp_growth.hpp:134
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:156
EWAAGrowthInterface(const EWAAGrowthInterface &other)
Construct a new EWAAGrowthInterface object.
Definition rcpp_growth.hpp:118
bool initialized
Have weight and age vectors been set? The default is false.
Definition rcpp_growth.hpp:100
RealVector weights
Weights (mt) for each age class.
Definition rcpp_growth.hpp:87
EWAAGrowthInterface()
The constructor.
Definition rcpp_growth.hpp:105
std::map< double, double > make_map(RealVector ages, RealVector weights)
Create a map of input numeric vectors.
Definition rcpp_growth.hpp:142
virtual std::string to_json()
Converts the data to json representation for the output.
Definition rcpp_growth.hpp:179
Base class for all interface objects.
Definition rcpp_interface_base.hpp:634
static std::vector< std::shared_ptr< FIMSRcppInterfaceBase > > fims_interface_objects
FIMS interface object vectors.
Definition rcpp_interface_base.hpp:644
virtual bool add_to_fims_tmb()
A virtual method to inherit to add objects to the TMB model.
Definition rcpp_interface_base.hpp:649
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:434
size_t size()
Returns the size of a RealVector.
Definition rcpp_interface_base.hpp:595
void clear_internal()
Clears the internal objects.
Definition rcpp_interface.hpp:279
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
virtual const Type evaluate(const double &a)
Returns the weight at age a (in kg) from the input vector.
Definition ewaa.hpp:43
std::map< double, double > ewaa
Definition ewaa.hpp:29