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>>
47 ::objective_function<Type> *of =
nullptr;
69 Type jnll =
static_cast<Type
>(0.0);
74 "Model: fims_information is not set. Please set fims_information "
76 "calling Evaluate().");
87 std::shared_ptr<fims_popdy::FisheryModelBase<Type>> m = (*m_it).second;
98 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
103 if (d->input_type ==
"prior") {
104 nll_vec[nll_vec_idx] = -d->evaluate();
105 jnll += nll_vec[nll_vec_idx];
112 "Model: Finished evaluating prior distributions. The jnll after "
114 fims::to_string(n_priors) +
" priors is: " + fims::to_string(jnll));
118 size_t n_random_effects = 0;
121 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
126 if (d->input_type ==
"random_effects") {
127 nll_vec[nll_vec_idx] = -d->evaluate();
128 jnll += nll_vec[nll_vec_idx];
129 n_random_effects += 1;
135 "Model: Finished evaluating random effect distributions. The jnll "
136 "after evaluating priors and " +
137 fims::to_string(n_random_effects) +
138 " random_effects is: " + fims::to_string(jnll));
144 std::shared_ptr<fims_distributions::DensityComponentBase<Type>> d =
150 if (d->input_type ==
"data") {
151 nll_vec[nll_vec_idx] = -d->evaluate();
152 jnll += nll_vec[nll_vec_idx];
159 "Model: Finished evaluating data likelihoods. The jnll after "
160 "evaluating priors, random effects, and " +
161 fims::to_string(n_data) +
162 " data likelihoods is: " + fims::to_string(jnll));
168 vector<Type> nll_components = nll_vec.
to_tmb();
178 std::shared_ptr<fims_popdy::FisheryModelBase<Type>> m = (*m_it).second;
188template <
typename Type>
Definition fims_vector.hpp:27
std::vector< Type > to_tmb() const
Convert fims::Vector to TMB vector type.
Definition fims_vector.hpp:494
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:55
const Type Evaluate()
Evaluate. Calculates the joint negative log-likelihood function.
Definition model.hpp:67
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:636
#define FIMS_ERROR_LOG(MESSAGE)
Definition def.hpp:664
#define FIMS_REPORT_F(name, F)
TMB macro that reports variables.
Definition interface.hpp:79