Skip to content

Commit

Permalink
Merge pull request #419 from NOAA-FIMS/403-refactor-remove-init_naa-f…
Browse files Browse the repository at this point in the history
…rom-population

remove init_naa
  • Loading branch information
nathanvaughan-NOAA authored Jul 13, 2023
2 parents 64880ae + 500fe8a commit 1553745
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
7 changes: 2 additions & 5 deletions inst/include/population_dynamics/population/population.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ struct Population : public FIMSObject<Type> {
ParameterVector log_M; /*!< estimated parameter: log Natural Mortality*/

// Transformed values
std::vector<Type> init_naa; /*!< transformed parameter: numbers at age*/
std::vector<Type> M; /*!< transformed parameter: Natural Mortality*/
std::vector<Type> M; /*!< transformed parameter: Natural Mortality*/

std::vector<double> ages; /*!< vector of the ages for referencing*/
std::vector<double> years; /*!< vector of years for referencing*/
Expand Down Expand Up @@ -141,7 +140,6 @@ struct Population : public FIMSObject<Type> {
unfished_spawning_biomass.resize((nyears + 1));
spawning_biomass.resize((nyears + 1));
expected_recruitment.resize((nyears + 1));
init_naa.resize(nages);
M.resize(nyears * nages);
ages.resize(nages);
log_init_naa.resize(nages);
Expand Down Expand Up @@ -175,7 +173,6 @@ struct Population : public FIMSObject<Type> {

// Transformation Section
for (size_t age = 0; age < this->nages; age++) {
this->init_naa[age] = fims::exp(this->log_init_naa[age]);
for (size_t year = 0; year < this->nyears; year++) {
size_t index_ay = age * this->nyears + year;
this->M[index_ay] = fims::exp(this->log_M[index_ay]);
Expand All @@ -198,7 +195,7 @@ struct Population : public FIMSObject<Type> {
*/
inline void CalculateInitialNumbersAA(
size_t index_ya, size_t a) { // inline all function unless complicated
this->numbers_at_age[index_ya] = this->init_naa[a];
this->numbers_at_age[index_ya] = fims::exp(this->log_init_naa[a]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace
EXPECT_EQ(population.spawning_biomass.size(), nyears + 1);
EXPECT_EQ(population.log_init_naa.size(), nages);
EXPECT_EQ(population.log_M.size(), nyears * nages);
EXPECT_EQ(population.init_naa.size(), nages);
EXPECT_EQ(population.M.size(), nyears * nages);
}

Expand Down Expand Up @@ -81,9 +80,7 @@ namespace
for (int i = 0; i < nages; i++)
{
naa[i] = fims::exp(population.log_init_naa[i]);
EXPECT_EQ(population.init_naa[i], naa[i]);
}
EXPECT_EQ(population.init_naa.size(), nages);

// Test population.M
std::vector<double> M(nyears * nages, 0);
Expand Down

0 comments on commit 1553745

Please sign in to comment.