9#ifndef FIMS_COMMON_MODEL_HPP
10#define FIMS_COMMON_MODEL_HPP
22template <
typename Type>
25 static std::shared_ptr<Model<Type>>
27 std::shared_ptr<fims_info::Information<Type>>
32 bool do_tmb_reporting =
true;
33 ::objective_function<Type> *of;
59 Type jnll =
static_cast<Type
>(0.0);
64 "fims_information is not set. Please set fims_information before "
65 "calling Evaluate().");
76 std::shared_ptr<fims_popdy::FisheryModelBase<Type>> m = (*m_it).second;
89 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
94 if (d->input_type ==
"prior") {
95 nll_vec[nll_vec_idx] = -d->evaluate();
96 jnll += nll_vec[nll_vec_idx];
102 "Model: Finished evaluating prior distributions. The jnll after "
104 fims::to_string(n_priors) +
" priors is: " + fims::to_string(jnll));
108 size_t n_random_effects = 0;
111 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
116 if (d->input_type ==
"random_effects") {
117 nll_vec[nll_vec_idx] = -d->evaluate();
118 jnll += nll_vec[nll_vec_idx];
119 n_random_effects += 1;
124 "Model: Finished evaluating random effect distributions. The jnll "
125 "after evaluating priors and " +
126 fims::to_string(n_random_effects) +
127 " random_effects is: " + fims::to_string(jnll));
133 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
139 if (d->input_type ==
"data") {
140 nll_vec[nll_vec_idx] = -d->evaluate();
141 jnll += nll_vec[nll_vec_idx];
149 vector<Type> nll_components = nll_vec.
to_tmb();
158 std::shared_ptr<fims_popdy::FisheryModelBase<Type>> m = (*m_it).second;
167template <
typename Type>
Definition fims_vector.hpp:27
std::vector< Type > to_tmb() const
Convert fims::Vector to TMB vector type.
Definition fims_vector.hpp:468
Model class. FIMS objective function.
Definition model.hpp:23
static std::shared_ptr< Model< Type > > fims_model
Definition model.hpp:26
static std::shared_ptr< Model< Type > > GetInstance()
Definition model.hpp:45
const Type Evaluate()
Evaluate. Calculates the joint negative log-likelihood function.
Definition model.hpp:57
std::shared_ptr< fims_info::Information< Type > > fims_information
Definition model.hpp:28
#define FIMS_INFO_LOG(MESSAGE)
Definition def.hpp:590
#define FIMS_ERROR_LOG(MESSAGE)
Definition def.hpp:606
#define FIMS_REPORT_F(name, F)
TMB macro that reports variables.
Definition interface.hpp:74