1669 int n_fleets = this->
fleets.size();
1672 if (this->do_reporting ==
true) {
1684 vector<vector<Type>> biomass_p(n_pops);
1685 vector<vector<Type>> expected_recruitment_p(n_pops);
1686 vector<vector<Type>> mortality_F_p(n_pops);
1687 vector<vector<Type>> mortality_M_p(n_pops);
1688 vector<vector<Type>> mortality_Z_p(n_pops);
1689 vector<vector<Type>> numbers_at_age_p(n_pops);
1690 vector<vector<Type>> proportion_mature_at_age_p(n_pops);
1691 vector<vector<Type>> spawning_biomass_p(n_pops);
1692 vector<vector<Type>> sum_selectivity_p(n_pops);
1693 vector<vector<Type>> total_catch_numbers_p(n_pops);
1694 vector<vector<Type>> total_catch_weight_p(n_pops);
1695 vector<vector<Type>> unfished_biomass_p(n_pops);
1696 vector<vector<Type>> unfished_numbers_at_age_p(n_pops);
1697 vector<vector<Type>> unfished_spawning_biomass_p(n_pops);
1698 vector<vector<Type>> spawning_biomass_ratio_p(n_pops);
1699 vector<vector<Type>> growth_mean_LAA_p(n_pops);
1700 vector<vector<Type>> growth_sd_LAA_p(n_pops);
1701 vector<vector<Type>> growth_mean_WAA_p(n_pops);
1704 vector<vector<Type>> agecomp_expected_f(n_fleets);
1705 vector<vector<Type>> agecomp_proportion_f(n_fleets);
1706 vector<vector<Type>> age_to_length_conversion_f(n_fleets);
1707 vector<vector<Type>> age_to_length_conversion_derived_f(n_fleets);
1708 vector<vector<Type>> age_to_length_conversion_derived_used_f(n_fleets);
1709 vector<vector<Type>> growth_derived_mean_WAA_f(n_fleets);
1710 vector<vector<Type>> index_expected_f(n_fleets);
1711 vector<vector<Type>> index_numbers_f(n_fleets);
1712 vector<vector<Type>> index_numbers_at_age_f(n_fleets);
1713 vector<vector<Type>> index_numbers_at_length_f(n_fleets);
1714 vector<vector<Type>> index_weight_f(n_fleets);
1715 vector<vector<Type>> index_weight_at_age_f(n_fleets);
1716 vector<vector<Type>> catch_expected_f(n_fleets);
1717 vector<vector<Type>> catch_numbers_f(n_fleets);
1718 vector<vector<Type>> catch_numbers_at_age_f(n_fleets);
1719 vector<vector<Type>> catch_numbers_at_length_f(n_fleets);
1720 vector<vector<Type>> catch_weight_f(n_fleets);
1721 vector<vector<Type>> catch_weight_at_age_f(n_fleets);
1722 vector<vector<Type>> lengthcomp_expected_f(n_fleets);
1723 vector<vector<Type>> lengthcomp_proportion_f(n_fleets);
1724 vector<vector<Type>> log_index_expected_f(n_fleets);
1725 vector<vector<Type>> log_catch_expected_f(n_fleets);
1729 for (
size_t p = 0; p < this->
populations.size(); p++) {
1730 std::map<std::string, fims::Vector<Type>> &derived_quantities =
1732 biomass_p(pop_idx) = derived_quantities[
"biomass"].to_tmb();
1733 expected_recruitment_p(pop_idx) =
1734 derived_quantities[
"expected_recruitment"].to_tmb();
1735 mortality_F_p(pop_idx) = derived_quantities[
"mortality_F"].to_tmb();
1736 mortality_M_p(pop_idx) = derived_quantities[
"mortality_M"].to_tmb();
1737 mortality_Z_p(pop_idx) = derived_quantities[
"mortality_Z"].to_tmb();
1738 numbers_at_age_p(pop_idx) =
1739 derived_quantities[
"numbers_at_age"].to_tmb();
1740 proportion_mature_at_age_p(pop_idx) =
1741 derived_quantities[
"proportion_mature_at_age"].to_tmb();
1742 spawning_biomass_p(pop_idx) =
1743 derived_quantities[
"spawning_biomass"].to_tmb();
1744 sum_selectivity_p(pop_idx) =
1745 derived_quantities[
"sum_selectivity"].to_tmb();
1746 total_catch_numbers_p(pop_idx) =
1747 derived_quantities[
"total_catch_numbers"].to_tmb();
1748 total_catch_weight_p(pop_idx) =
1749 derived_quantities[
"total_catch_weight"].to_tmb();
1750 unfished_biomass_p(pop_idx) =
1751 derived_quantities[
"unfished_biomass"].to_tmb();
1752 unfished_numbers_at_age_p(pop_idx) =
1753 derived_quantities[
"unfished_numbers_at_age"].to_tmb();
1754 unfished_spawning_biomass_p(pop_idx) =
1755 derived_quantities[
"unfished_spawning_biomass"].to_tmb();
1756 spawning_biomass_ratio_p(pop_idx) =
1757 this->
populations[pop_idx]->spawning_biomass_ratio.to_tmb();
1760 growth_observation = std::dynamic_pointer_cast<
1763 const auto *gp = growth_observation->TryGetPreparedGrowthProducts();
1764 if (gp ==
nullptr) {
1765 throw std::runtime_error(
1766 "Growth products were not prepared before report generation.");
1769 const std::size_t n = gp->Size();
1770 vector<Type> mean_laa(n);
1771 vector<Type> sd_laa(n);
1772 vector<Type> mean_waa(n);
1773 for (std::size_t i = 0; i < n; ++i) {
1774 mean_laa(i) = gp->mean_LAA[i];
1775 sd_laa(i) = gp->sd_LAA[i];
1776 const std::size_t year = i / this->
populations[p]->n_ages;
1777 const std::size_t age = i % this->
populations[p]->n_ages;
1781 growth_mean_LAA_p(pop_idx) = mean_laa;
1782 growth_sd_LAA_p(pop_idx) = sd_laa;
1783 growth_mean_WAA_p(pop_idx) = mean_waa;
1792 for (fit = this->
fleets.begin(); fit != this->fleets.end(); ++fit) {
1793 std::shared_ptr<fims_popdy::Fleet<Type>> &fleet = (*fit).second;
1794 std::map<std::string, fims::Vector<Type>> &derived_quantities =
1797 agecomp_expected_f(fleet_idx) =
1798 derived_quantities[
"agecomp_expected"].to_tmb();
1799 agecomp_proportion_f(fleet_idx) =
1800 derived_quantities[
"agecomp_proportion"].to_tmb();
1804 bool using_age_to_length_conversion_derived =
false;
1805 if (isDouble<Type>::value) {
1806 age_to_length_conversion_derived_used.
resize(1);
1807 age_to_length_conversion_derived_used[0] =
static_cast<Type
>(0.0);
1809 std::shared_ptr<fims_popdy::AgeToLengthConversionDerived<Type>>
1810 age_to_length_conversion_derived_model =
1811 std::dynamic_pointer_cast<
1813 fleet->age_to_length_conversion_model);
1815 if (age_to_length_conversion_derived_model !=
nullptr &&
1816 age_to_length_conversion_derived_model->IsActive()) {
1817 using_age_to_length_conversion_derived =
true;
1818 age_to_length_conversion_derived_used[0] =
static_cast<Type
>(1.0);
1819 growth_derived_mean_WAA.
resize(fleet->n_years * fleet->n_ages);
1821 for (
size_t y = 0; y < fleet->n_years; ++y) {
1822 for (
size_t a = 0; a < fleet->n_ages; ++a) {
1823 const size_t i_age_year = y * fleet->n_ages + a;
1825 if (this->report_age_to_length_conversion_derived_tensor) {
1826 if (age_to_length_conversion_derived.
size() == 0) {
1827 age_to_length_conversion_derived.
resize(
1828 fleet->n_years * fleet->n_ages * fleet->n_lengths);
1833 age_to_length_conversion_derived_model, fleet, y, a,
1834 age_to_length_conversion_row);
1836 growth_derived_mean_WAA[i_age_year] =
1838 age_to_length_conversion_derived_model
1839 ->growth_observation_,
1840 fleet, age_to_length_conversion_row);
1842 for (
size_t l = 0; l < fleet->n_lengths; ++l) {
1843 const size_t i_length_age_year =
1844 y * (fleet->n_ages * fleet->n_lengths) +
1845 a * fleet->n_lengths + l;
1846 age_to_length_conversion_derived[i_length_age_year] =
1847 age_to_length_conversion_row[l];
1850 growth_derived_mean_WAA[i_age_year] =
1858 age_to_length_conversion_derived_f(fleet_idx) =
1859 age_to_length_conversion_derived.
to_tmb();
1860 age_to_length_conversion_derived_used_f(fleet_idx) =
1861 age_to_length_conversion_derived_used.
to_tmb();
1862 growth_derived_mean_WAA_f(fleet_idx) = growth_derived_mean_WAA.
to_tmb();
1863 if (!using_age_to_length_conversion_derived) {
1864 age_to_length_conversion_f(fleet_idx) =
1865 fleet->age_to_length_conversion.to_tmb();
1867 index_expected_f(fleet_idx) =
1868 derived_quantities[
"index_expected"].to_tmb();
1869 index_numbers_f(fleet_idx) =
1870 derived_quantities[
"index_numbers"].to_tmb();
1871 index_numbers_at_age_f(fleet_idx) =
1872 derived_quantities[
"index_numbers_at_age"].to_tmb();
1873 index_numbers_at_length_f(fleet_idx) =
1874 derived_quantities[
"index_numbers_at_length"].to_tmb();
1875 index_weight_f(fleet_idx) = derived_quantities[
"index_weight"].to_tmb();
1876 index_weight_at_age_f(fleet_idx) =
1877 derived_quantities[
"index_weight_at_age"].to_tmb();
1878 catch_expected_f(fleet_idx) =
1879 derived_quantities[
"catch_expected"].to_tmb();
1880 catch_numbers_f(fleet_idx) =
1881 derived_quantities[
"catch_numbers"].to_tmb();
1882 catch_numbers_at_age_f(fleet_idx) =
1883 derived_quantities[
"catch_numbers_at_age"].to_tmb();
1884 catch_numbers_at_length_f(fleet_idx) =
1885 derived_quantities[
"catch_numbers_at_length"].to_tmb();
1886 catch_weight_f(fleet_idx) = derived_quantities[
"catch_weight"].to_tmb();
1887 catch_weight_at_age_f(fleet_idx) =
1888 derived_quantities[
"catch_weight_at_age"].to_tmb();
1893 lengthcomp_expected_f(fleet_idx) =
1894 derived_quantities[
"lengthcomp_expected"].to_tmb();
1895 lengthcomp_proportion_f(fleet_idx) =
1896 derived_quantities[
"lengthcomp_proportion"].to_tmb();
1897 log_index_expected_f(fleet_idx) =
1898 derived_quantities[
"log_index_expected"].to_tmb();
1899 log_catch_expected_f(fleet_idx) =
1900 derived_quantities[
"log_catch_expected"].to_tmb();
1904 vector<Type> biomass = ADREPORTvector(biomass_p);
1905 vector<Type> expected_recruitment =
1906 ADREPORTvector(expected_recruitment_p);
1907 vector<Type> mortality_F = ADREPORTvector(mortality_F_p);
1908 vector<Type> mortality_M = ADREPORTvector(mortality_M_p);
1909 vector<Type> mortality_Z = ADREPORTvector(mortality_Z_p);
1910 vector<Type> numbers_at_age = ADREPORTvector(numbers_at_age_p);
1911 vector<Type> proportion_mature_at_age =
1912 ADREPORTvector(proportion_mature_at_age_p);
1913 vector<Type> spawning_biomass = ADREPORTvector(spawning_biomass_p);
1914 vector<Type> sum_selectivity = ADREPORTvector(sum_selectivity_p);
1915 vector<Type> total_catch_numbers = ADREPORTvector(total_catch_numbers_p);
1916 vector<Type> total_catch_weight = ADREPORTvector(total_catch_weight_p);
1917 vector<Type> unfished_biomass = ADREPORTvector(unfished_biomass_p);
1918 vector<Type> unfished_numbers_at_age =
1919 ADREPORTvector(unfished_numbers_at_age_p);
1920 vector<Type> unfished_spawning_biomass =
1921 ADREPORTvector(unfished_spawning_biomass_p);
1922 vector<Type> spawning_biomass_ratio =
1923 ADREPORTvector(spawning_biomass_ratio_p);
1925 vector<Type> agecomp_expected = ADREPORTvector(agecomp_expected_f);
1926 vector<Type> agecomp_proportion = ADREPORTvector(agecomp_proportion_f);
1927 vector<Type> index_expected = ADREPORTvector(index_expected_f);
1928 vector<Type> index_numbers = ADREPORTvector(index_numbers_f);
1929 vector<Type> index_numbers_at_age =
1930 ADREPORTvector(index_numbers_at_age_f);
1931 vector<Type> index_numbers_at_length =
1932 ADREPORTvector(index_numbers_at_length_f);
1933 vector<Type> index_weight = ADREPORTvector(index_weight_f);
1934 vector<Type> index_weight_at_age = ADREPORTvector(index_weight_at_age_f);
1935 vector<Type> catch_expected = ADREPORTvector(catch_expected_f);
1936 vector<Type> catch_numbers = ADREPORTvector(catch_numbers_f);
1937 vector<Type> catch_numbers_at_age =
1938 ADREPORTvector(catch_numbers_at_age_f);
1939 vector<Type> catch_numbers_at_length =
1940 ADREPORTvector(catch_numbers_at_length_f);
1941 vector<Type> catch_weight = ADREPORTvector(catch_weight_f);
1942 vector<Type> catch_weight_at_age = ADREPORTvector(catch_weight_at_age_f);
1946 vector<Type> lengthcomp_expected = ADREPORTvector(lengthcomp_expected_f);
1947 vector<Type> lengthcomp_proportion =
1948 ADREPORTvector(lengthcomp_proportion_f);
1949 vector<Type> log_index_expected = ADREPORTvector(log_index_expected_f);
1950 vector<Type> log_catch_expected = ADREPORTvector(log_catch_expected_f);
1953 FIMS_REPORT_F_(
"biomass", biomass_p, this->of);
1954 FIMS_REPORT_F_(
"expected_recruitment", expected_recruitment_p, this->of);
1955 FIMS_REPORT_F_(
"mortality_F", mortality_F_p, this->of);
1956 FIMS_REPORT_F_(
"mortality_M", mortality_M_p, this->of);
1957 FIMS_REPORT_F_(
"mortality_Z", mortality_Z_p, this->of);
1958 FIMS_REPORT_F_(
"numbers_at_age", numbers_at_age_p, this->of);
1959 FIMS_REPORT_F_(
"proportion_mature_at_age", proportion_mature_at_age_p,
1961 FIMS_REPORT_F_(
"spawning_biomass", spawning_biomass_p, this->of);
1962 FIMS_REPORT_F_(
"sum_selectivity", sum_selectivity_p, this->of);
1963 FIMS_REPORT_F_(
"total_catch_numbers", total_catch_numbers_p, this->of);
1964 FIMS_REPORT_F_(
"total_catch_weight", total_catch_weight_p, this->of);
1965 FIMS_REPORT_F_(
"unfished_biomass", unfished_biomass_p, this->of);
1966 FIMS_REPORT_F_(
"unfished_numbers_at_age", unfished_numbers_at_age_p,
1968 FIMS_REPORT_F_(
"unfished_spawning_biomass", unfished_spawning_biomass_p,
1970 FIMS_REPORT_F_(
"spawning_biomass_ratio", spawning_biomass_ratio_p,
1972 FIMS_REPORT_F_(
"growth_mean_LAA", growth_mean_LAA_p, this->of);
1973 FIMS_REPORT_F_(
"growth_sd_LAA", growth_sd_LAA_p, this->of);
1974 FIMS_REPORT_F_(
"growth_mean_WAA", growth_mean_WAA_p, this->of);
1983 ADREPORT_F(proportion_mature_at_age, this->of);
1989 ADREPORT_F(unfished_numbers_at_age, this->of);
1990 ADREPORT_F(unfished_spawning_biomass, this->of);
1991 ADREPORT_F(spawning_biomass_ratio, this->of);
1995 FIMS_REPORT_F_(
"agecomp_expected", agecomp_expected_f, this->of);
1996 FIMS_REPORT_F_(
"agecomp_proportion", agecomp_proportion_f, this->of);
1997 FIMS_REPORT_F_(
"age_to_length_conversion", age_to_length_conversion_f,
1999 FIMS_REPORT_F_(
"age_to_length_conversion_derived",
2000 age_to_length_conversion_derived_f, this->of);
2001 FIMS_REPORT_F_(
"age_to_length_conversion_derived_used",
2002 age_to_length_conversion_derived_used_f, this->of);
2003 FIMS_REPORT_F_(
"growth_derived_mean_WAA", growth_derived_mean_WAA_f,
2005 FIMS_REPORT_F_(
"index_expected", index_expected_f, this->of);
2006 FIMS_REPORT_F_(
"index_numbers", index_numbers_f, this->of);
2007 FIMS_REPORT_F_(
"index_numbers_at_age", index_numbers_at_age_f, this->of);
2008 FIMS_REPORT_F_(
"index_numbers_at_length", index_numbers_at_length_f,
2010 FIMS_REPORT_F_(
"index_weight", index_weight_f, this->of);
2011 FIMS_REPORT_F_(
"index_weight_at_age", index_weight_at_age_f, this->of);
2012 FIMS_REPORT_F_(
"catch_expected", catch_expected_f, this->of);
2013 FIMS_REPORT_F_(
"catch_numbers", catch_numbers_f, this->of);
2014 FIMS_REPORT_F_(
"catch_numbers_at_age", catch_numbers_at_age_f, this->of);
2015 FIMS_REPORT_F_(
"catch_numbers_at_length", catch_numbers_at_length_f,
2017 FIMS_REPORT_F_(
"catch_weight", catch_weight_f, this->of);
2018 FIMS_REPORT_F_(
"catch_weight_at_age", catch_weight_at_age_f, this->of);
2019 FIMS_REPORT_F_(
"lengthcomp_expected", lengthcomp_expected_f, this->of);
2020 FIMS_REPORT_F_(
"lengthcomp_proportion", lengthcomp_proportion_f,
2022 FIMS_REPORT_F_(
"log_index_expected", log_index_expected_f, this->of);
2023 FIMS_REPORT_F_(
"log_catch_expected", log_catch_expected_f, this->of);
2030 ADREPORT_F(index_numbers_at_length, this->of);
2036 ADREPORT_F(catch_numbers_at_length, this->of);
2043 std::stringstream var_name;
2044 typename std::map<std::string, fims::Vector<fims::Vector<Type>>>::iterator
2048 auto &x = rvit->second;
2050 int outer_dim = x.size();
2052 for (
int i = 0; i < outer_dim; i++) {
2055 vector<Type> res(dim);
2057 for (
int i = 0; i < outer_dim; i++) {
2058 int inner_dim = x[i].size();
2059 for (
int j = 0; j < inner_dim; j++) {
2064 this->of->reportvector.push(res, rvit->first.c_str());