diff --git a/inst/include/common/model.hpp b/inst/include/common/model.hpp index da86f61b6..a339e90b6 100644 --- a/inst/include/common/model.hpp +++ b/inst/include/common/model.hpp @@ -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 > creates a nested vector structure where - //each vector can be a different dimension. Does not work with ADREPORT - //fleets - vector< vector > exp_index(n_fleets); - vector< vector > exp_catch(n_fleets); - vector< vector > cnaa(n_fleets); - vector< vector > cwaa(n_fleets); - vector< vector > F_mort(n_fleets); - //populations - vector< vector > naa(n_pops); - vector< vector > ssb(n_pops); - vector< vector > biomass(n_pops); - vector< vector > rec_dev(n_pops); - vector< vector > recruitment(n_pops); - vector< vector > M(n_pops); - #endif +// Create vector lists to store output for reporting +#ifdef TMB_MODEL + // vector< vector > creates a nested vector structure where + // each vector can be a different dimension. Does not work with ADREPORT + // fleets + vector > exp_index(n_fleets); + vector > exp_catch(n_fleets); + vector > cnaa(n_fleets); + vector > cwaa(n_fleets); + vector > F_mort(n_fleets); + // populations + vector > naa(n_pops); + vector > ssb(n_pops); + vector > biomass(n_pops); + vector > rec_dev(n_pops); + vector > recruitment(n_pops); + vector > M(n_pops); +#endif // Loop over populations, evaluate, and sum up the recruitment likelihood // component @@ -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::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; @@ -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((*it).second->numbers_at_age); - ssb(pop_idx) = vector((*it).second->spawning_biomass); - rec_dev(pop_idx) = vector((*it).second->recruitment->recruit_deviations); - recruitment(pop_idx) = vector((*it).second->expected_recruitment); - biomass(pop_idx) = vector((*it).second->biomass); - M(pop_idx) = vector((*it).second->M); - #endif +#ifdef TMB_MODEL + naa(pop_idx) = vector((*it).second->numbers_at_age); + ssb(pop_idx) = vector((*it).second->spawning_biomass); + rec_dev(pop_idx) = + vector((*it).second->recruitment->recruit_deviations); + recruitment(pop_idx) = vector((*it).second->expected_recruitment); + biomass(pop_idx) = vector((*it).second->biomass); + M(pop_idx) = vector((*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((*jt).second->expected_index); - exp_catch(fleet_idx) = vector((*jt).second->expected_catch); - F_mort(fleet_idx) = vector((*jt).second->Fmort); - cnaa(fleet_idx) = vector((*jt).second->catch_numbers_at_age); - cwaa(fleet_idx) = vector((*jt).second->catch_weight_at_age); - #endif +#ifdef TMB_MODEL + exp_index(fleet_idx) = vector((*jt).second->expected_index); + exp_catch(fleet_idx) = vector((*jt).second->expected_catch); + F_mort(fleet_idx) = vector((*jt).second->Fmort); + cnaa(fleet_idx) = vector((*jt).second->catch_numbers_at_age); + cwaa(fleet_idx) = vector((*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); @@ -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; } diff --git a/inst/include/interface/interface.hpp b/inst/include/interface/interface.hpp index 36f3fbe95..60572f067 100644 --- a/inst/include/interface/interface.hpp +++ b/inst/include/interface/interface.hpp @@ -32,17 +32,17 @@ #define ADREPORT_F(name, F) F->reportvector.push(name, #name); template -vector ADREPORTvector(vector< vector > x){ +vector ADREPORTvector(vector > x) { int outer_dim = x.size(); int dim = 0; - for(int i=0; i res(dim); int idx = 0; - for(int i=0; i