Skip to content

Commit

Permalink
style: run clang format (#483)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrea-Havron-NOAA <Andrea-Havron-NOAA@users.noreply.github.com>
  • Loading branch information
ChristineStawitz-NOAA and Andrea-Havron-NOAA committed Oct 19, 2023
1 parent 9851bec commit 4f4eee1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
85 changes: 41 additions & 44 deletions inst/include/common/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,24 @@ class Model { // may need singleton
int n_fleets = fims_information->fleets.size();
int n_pops = fims_information->populations.size();

//Create vector lists to store output for reporting
#ifdef TMB_MODEL
//vector< vector<Type> > creates a nested vector structure where
//each vector can be a different dimension. Does not work with ADREPORT
//fleets
vector< vector<Type> > exp_index(n_fleets);
vector< vector<Type> > exp_catch(n_fleets);
vector< vector<Type> > cnaa(n_fleets);
vector< vector<Type> > cwaa(n_fleets);
vector< vector<Type> > F_mort(n_fleets);
//populations
vector< vector<Type> > naa(n_pops);
vector< vector<Type> > ssb(n_pops);
vector< vector<Type> > biomass(n_pops);
vector< vector<Type> > rec_dev(n_pops);
vector< vector<Type> > recruitment(n_pops);
vector< vector<Type> > M(n_pops);
#endif
// Create vector lists to store output for reporting
#ifdef TMB_MODEL
// vector< vector<Type> > creates a nested vector structure where
// each vector can be a different dimension. Does not work with ADREPORT
// fleets
vector<vector<Type> > exp_index(n_fleets);
vector<vector<Type> > exp_catch(n_fleets);
vector<vector<Type> > cnaa(n_fleets);
vector<vector<Type> > cwaa(n_fleets);
vector<vector<Type> > F_mort(n_fleets);
// populations
vector<vector<Type> > naa(n_pops);
vector<vector<Type> > ssb(n_pops);
vector<vector<Type> > biomass(n_pops);
vector<vector<Type> > rec_dev(n_pops);
vector<vector<Type> > recruitment(n_pops);
vector<vector<Type> > M(n_pops);
#endif

// Loop over populations, evaluate, and sum up the recruitment likelihood
// component
Expand All @@ -109,11 +109,10 @@ class Model { // may need singleton
FIMS_LOG << "rec nll: " << rec_nll << std::endl;
}

//Loop over fleets/surveys, and sum up age comp and index nlls
// Loop over fleets/surveys, and sum up age comp and index nlls
typename fims::Information<Type>::fleet_iterator jt;
for (jt = this->fims_information->fleets.begin();
jt != this->fims_information->fleets.end(); ++jt) {

//(*jt).second points to each individual Fleet module
#ifdef TMB_MODEL
(*jt).second->of = this->of;
Expand All @@ -122,43 +121,42 @@ class Model { // may need singleton
index_nll += (*jt).second->evaluate_index_nll();
}

//Loop over populations and fleets/surveys and fill in reporting
// Loop over populations and fleets/surveys and fill in reporting

//initiate population index for structuring report out objects
// initiate population index for structuring report out objects
int pop_idx = 0;
for (it = this->fims_information->populations.begin();
it != this->fims_information->populations.end(); ++it) {
#ifdef TMB_MODEL
naa(pop_idx) = vector<Type>((*it).second->numbers_at_age);
ssb(pop_idx) = vector<Type>((*it).second->spawning_biomass);
rec_dev(pop_idx) = vector<Type>((*it).second->recruitment->recruit_deviations);
recruitment(pop_idx) = vector<Type>((*it).second->expected_recruitment);
biomass(pop_idx) = vector<Type>((*it).second->biomass);
M(pop_idx) = vector<Type>((*it).second->M);
#endif
#ifdef TMB_MODEL
naa(pop_idx) = vector<Type>((*it).second->numbers_at_age);
ssb(pop_idx) = vector<Type>((*it).second->spawning_biomass);
rec_dev(pop_idx) =
vector<Type>((*it).second->recruitment->recruit_deviations);
recruitment(pop_idx) = vector<Type>((*it).second->expected_recruitment);
biomass(pop_idx) = vector<Type>((*it).second->biomass);
M(pop_idx) = vector<Type>((*it).second->M);
#endif
pop_idx += 1;

}

//initiate fleet index for structuring report out objects
// initiate fleet index for structuring report out objects
int fleet_idx = 0;
for (jt = this->fims_information->fleets.begin();
jt != this->fims_information->fleets.end(); ++jt) {
#ifdef TMB_MODEL
exp_index(fleet_idx) = vector<Type>((*jt).second->expected_index);
exp_catch(fleet_idx) = vector<Type>((*jt).second->expected_catch);
F_mort(fleet_idx) = vector<Type>((*jt).second->Fmort);
cnaa(fleet_idx) = vector<Type>((*jt).second->catch_numbers_at_age);
cwaa(fleet_idx) = vector<Type>((*jt).second->catch_weight_at_age);
#endif
#ifdef TMB_MODEL
exp_index(fleet_idx) = vector<Type>((*jt).second->expected_index);
exp_catch(fleet_idx) = vector<Type>((*jt).second->expected_catch);
F_mort(fleet_idx) = vector<Type>((*jt).second->Fmort);
cnaa(fleet_idx) = vector<Type>((*jt).second->catch_numbers_at_age);
cwaa(fleet_idx) = vector<Type>((*jt).second->catch_weight_at_age);
#endif
fleet_idx += 1;
}

jnll = rec_nll + age_comp_nll + index_nll;


//Reporting
#ifdef TMB_MODEL
// Reporting
#ifdef TMB_MODEL
REPORT_F(rec_nll, of);
REPORT_F(age_comp_nll, of);
REPORT_F(index_nll, of);
Expand Down Expand Up @@ -194,8 +192,7 @@ class Model { // may need singleton
ADREPORT_F(FMort, of);
ADREPORT_F(ExpectedIndex, of);
ADREPORT_F(CNAA, of);
#endif

#endif

return jnll;
}
Expand Down
8 changes: 4 additions & 4 deletions inst/include/interface/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
#define ADREPORT_F(name, F) F->reportvector.push(name, #name);

template <typename Type>
vector<Type> ADREPORTvector(vector< vector<Type> > x){
vector<Type> ADREPORTvector(vector<vector<Type> > x) {
int outer_dim = x.size();
int dim = 0;
for(int i=0; i<outer_dim; i++){
for (int i = 0; i < outer_dim; i++) {
dim += x(i).size();
}
vector<Type> res(dim);
int idx = 0;
for(int i=0; i<outer_dim; i++){
for (int i = 0; i < outer_dim; i++) {
int inner_dim = x(i).size();
for(int j=0; j<inner_dim; j++){
for (int j = 0; j < inner_dim; j++) {
res(idx) = x(i)(j);
idx += 1;
}
Expand Down

0 comments on commit 4f4eee1

Please sign in to comment.