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>>
46 ::objective_function<Type> *of;
68 Type jnll =
static_cast<Type
>(0.0);
73 "Model: fims_information is not set. Please set fims_information "
75 "calling Evaluate().");
86 std::shared_ptr<fims_popdy::FisheryModelBase<Type>> m = (*m_it).second;
97 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
102 if (d->input_type ==
"prior") {
103 nll_vec[nll_vec_idx] = -d->evaluate();
104 jnll += nll_vec[nll_vec_idx];
111 "Model: Finished evaluating prior distributions. The jnll after "
113 fims::to_string(n_priors) +
" priors is: " + fims::to_string(jnll));
117 size_t n_random_effects = 0;
120 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
125 if (d->input_type ==
"random_effects") {
126 nll_vec[nll_vec_idx] = -d->evaluate();
127 jnll += nll_vec[nll_vec_idx];
128 n_random_effects += 1;
134 "Model: Finished evaluating random effect distributions. The jnll "
135 "after evaluating priors and " +
136 fims::to_string(n_random_effects) +
137 " random_effects is: " + fims::to_string(jnll));
143 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
149 if (d->input_type ==
"data") {
150 nll_vec[nll_vec_idx] = -d->evaluate();
151 jnll += nll_vec[nll_vec_idx];
158 "Model: Finished evaluating data likelihoods. The jnll after "
159 "evaluating priors, random effects, and " +
160 fims::to_string(n_data) +
161 " data likelihoods is: " + fims::to_string(jnll));
167 vector<Type> nll_components = nll_vec.
to_tmb();
177 std::shared_ptr<fims_popdy::FisheryModelBase<Type>> m = (*m_it).second;
187template <
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
Model()
Construct a new Model object.
Definition model.hpp:35
~Model()
Destroy the Model object.
Definition model.hpp:41
static std::shared_ptr< Model< Type > > fims_model
Definition model.hpp:26
static std::shared_ptr< Model< Type > > GetInstance()
Evaluate. Calculates the joint negative log-likelihood function.
Definition model.hpp:54
const Type Evaluate()
Evaluate. Calculates the joint negative log-likelihood function.
Definition model.hpp:66
std::shared_ptr< fims_info::Information< Type > > fims_information
Definition model.hpp:28
#define FIMS_INFO_LOG(MESSAGE)
Record an info-log entry with metadata.
Definition def.hpp:627
#define FIMS_ERROR_LOG(MESSAGE)
Definition def.hpp:655
#define FIMS_REPORT_F(name, F)
TMB macro that reports variables.
Definition interface.hpp:75