FIMS  v0.9.3
Loading...
Searching...
No Matches
rcpp_models.hpp
Go to the documentation of this file.
1
9#ifndef FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_MODELS_HPP
10#define FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_MODELS_HPP
11
12#include <set>
13#include "common/def.hpp"
15#include "../../../models/fisheries_models.hpp"
16#include "common/model.hpp"
17#include "../../../utilities/fims_json.hpp"
18#include "rcpp_population.hpp"
19#include "rcpp_fleet.hpp"
20#include "rcpp_growth.hpp"
21#include "rcpp_distribution.hpp"
22#include "rcpp_data.hpp"
23#include "rcpp_maturity.hpp"
24#include "rcpp_recruitment.hpp"
25#include "rcpp_selectivity.hpp"
26#include <valarray>
27#include <cmath>
28#include <mutex>
29
37 protected:
41 std::shared_ptr<std::set<uint32_t>> population_ids;
45 typedef typename std::set<uint32_t>::iterator population_id_iterator;
46
47 public:
51 static uint32_t id_g;
61 static std::map<uint32_t, std::shared_ptr<FisheryModelInterfaceBase>>
63
69 this->population_ids = std::make_shared<std::set<uint32_t>>();
70 /* Create instance of map: key is id and value is pointer to
71 FleetInterfaceBase */
72 // FisheryModelInterfaceBase::live_objects[this->id] = this;
73 }
74
82
87
101 virtual std::string to_json() {
102 return "std::string to_json() not yet implemented.";
103 }
104
108 virtual uint32_t get_id() = 0;
109
117 Rcpp::NumericVector get_fixed_parameters_vector() {
118 std::shared_ptr<fims_info::Information<double>> info0 =
120
121 Rcpp::NumericVector p;
122
123 for (size_t i = 0; i < info0->fixed_effects_parameters.size(); i++) {
124 p.push_back(*info0->fixed_effects_parameters[i]);
125 }
126
127 return p;
128 }
129
137 Rcpp::NumericVector get_random_parameters_vector() {
138 std::shared_ptr<fims_info::Information<double>> d0 =
140
141 Rcpp::NumericVector p;
142
143 for (size_t i = 0; i < d0->random_effects_parameters.size(); i++) {
144 p.push_back(*d0->random_effects_parameters[i]);
145 }
146
147 return p;
148 }
149
156 double sum(const std::valarray<double> &v) {
157 double sum = 0.0;
158 for (size_t i = 0; i < v.size(); i++) {
159 sum += v[i];
160 }
161 return sum;
162 }
163
170 double sum(const std::vector<double> &v) {
171 double sum = 0.0;
172 for (size_t i = 0; i < v.size(); i++) {
173 sum += v[i];
174 }
175 return sum;
176 }
177
185 double min(const std::valarray<double> &v) {
186 double min_value = v[0];
187 for (size_t i = 1; i < v.size(); i++) {
188 if (v[i] < min_value) {
189 min_value = v[i];
190 }
191 }
192 return min_value;
193 }
194
203 std::valarray<double> fabs(const std::valarray<double> &v) {
204 std::valarray<double> result(v.size());
205 for (size_t i = 0; i < v.size(); i++) {
206 result[i] = std::fabs(v[i]);
207 }
208 return result;
209 }
210};
211
217 public:
222 std::shared_ptr<CatchAtAgeInterface> caa =
223 std::make_shared<CatchAtAgeInterface>(*this);
226 }
227
235
240 this->population_ids->insert(id);
241
242 std::map<uint32_t, std::shared_ptr<PopulationInterfaceBase>>::iterator pit;
245 std::shared_ptr<PopulationInterfaceBase> &pop = (*pit).second;
246 pop->initialize_catch_at_age.set(true);
247 } else {
248 FIMS_ERROR_LOG("Population with id " + fims::to_string(id) +
249 " not found.");
250 }
251 }
252
260 void DoReporting(bool report) {
261#ifdef TMB_MODEL
262 std::shared_ptr<fims_info::Information<double>> info =
265 model_it = info->models_map.find(this->get_id());
266 if (model_it != info->models_map.end()) {
267 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
268 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
269 (*model_it).second);
270 model_ptr->do_reporting = report;
271 }
272#endif
273 }
274
282 bool IsReporting() {
283#ifdef TMB_MODEL
284 std::shared_ptr<fims_info::Information<double>> info =
287 model_it = info->models_map.find(this->get_id());
288 if (model_it != info->models_map.end()) {
289 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
290 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
291 (*model_it).second);
292 return model_ptr->do_reporting;
293 }
294 return false;
295#else
296 return false;
297#endif
298 }
299
303 virtual uint32_t get_id() { return this->id; }
304
308 virtual void finalize() {}
309
314 std::stringstream ss;
315
316 typename std::map<uint32_t,
317 std::shared_ptr<PopulationInterfaceBase>>::iterator
318 pi_it; // population interface iterator
320 population_interface->get_id());
322 FIMS_ERROR_LOG("Population with id " +
323 fims::to_string(population_interface->get_id()) +
324 " not found in live objects.");
325 return "{}"; // Return empty JSON
326 }
327
328 std::shared_ptr<PopulationInterface> population_interface_ptr =
329 std::dynamic_pointer_cast<PopulationInterface>((*pi_it).second);
330
331 std::shared_ptr<fims_info::Information<double>> info =
333
335 model_it = info->models_map.find(this->get_id());
336 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
337 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
338 (*model_it).second);
339
341
342 pit = info->populations.find(population_interface->get_id());
343
344 if (pit != info->populations.end()) {
345 std::shared_ptr<fims_popdy::Population<double>> &pop = (*pit).second;
346 ss << "{\n";
347
348 ss << " \"module_name\": \"Population\",\n";
349 ss << " \"population\": \"" << population_interface->name << "\",\n";
350 ss << " \"module_id\": " << population_interface->id << ",\n";
351 ss << " \"recruitment_id\": " << population_interface->recruitment_id
352 << ",\n";
353 ss << " \"growth_id\": " << population_interface->growth_id << ",\n";
354 ss << " \"maturity_id\": " << population_interface->maturity_id << ",\n";
355
356 ss << " \"parameters\": [\n";
357 for (size_t i = 0; i < pop->log_M.size(); i++) {
358 population_interface_ptr->log_M[i].final_value_m = pop->log_M[i];
359 }
360
361 ss << "{\n \"name\": \"log_M\",\n";
362 ss << " \"id\":" << population_interface->log_M.id_m << ",\n";
363 ss << " \"type\": \"vector\",\n";
364 ss << " \"dimensionality\": {\n";
365 ss << " \"header\": [" << "\"n_years\", \"n_ages\"" << "],\n";
366 ss << " \"dimensions\": [" << population_interface->n_years.get() << ", "
367 << population_interface->n_ages.get() << "]\n},\n";
368 ss << " \"values\": " << population_interface->log_M << "\n\n";
369 ss << "},\n";
370
371 for (size_t i = 0; i < pop->log_f_multiplier.size(); i++) {
372 population_interface_ptr->log_f_multiplier[i].final_value_m =
373 pop->log_f_multiplier[i];
374 }
375
376 ss << "{\n \"name\": \"log_f_multiplier\",\n";
377 ss << " \"id\":" << population_interface->log_f_multiplier.id_m << ",\n";
378 ss << " \"type\": \"vector\",\n";
379 ss << " \"dimensionality\": {\n";
380 ss << " \"header\": [" << "\"n_years\"" << "],\n";
381 ss << " \"dimensions\": [" << population_interface->n_years.get()
382 << "]\n},\n";
383 ss << " \"values\": " << population_interface->log_f_multiplier << "\n\n";
384 ss << "},\n";
385
386 for (size_t i = 0; i < pop->spawning_biomass_ratio.size(); i++) {
387 population_interface_ptr->spawning_biomass_ratio[i].final_value_m =
388 pop->spawning_biomass_ratio[i];
389 }
390
391 ss << "{\n \"name\": \"spawning_biomass_ratio\",\n";
392 ss << " \"id\":" << population_interface->spawning_biomass_ratio.id_m
393 << ",\n";
394 ss << " \"type\": \"vector\",\n";
395 ss << " \"dimensionality\": {\n";
396 ss << " \"header\": [" << "\"n_years\"" << "],\n";
397 ss << " \"dimensions\": [" << (population_interface->n_years.get() + 1)
398 << "]\n},\n";
399 ss << " \"values\": " << population_interface->spawning_biomass_ratio
400 << "\n\n";
401 ss << "},\n";
402
403 for (size_t i = 0; i < pop->log_init_naa.size(); i++) {
404 population_interface_ptr->log_init_naa[i].final_value_m =
405 pop->log_init_naa[i];
406 }
407 ss << " {\n\"name\": \"log_init_naa\",\n";
408 ss << " \"id\":" << population_interface->log_init_naa.id_m << ",\n";
409 ss << " \"type\": \"vector\",\n";
410 ss << " \"dimensionality\": {\n";
411 ss << " \"header\": [" << "\"n_ages\"" << "],\n";
412 ss << " \"dimensions\": [" << population_interface->n_ages.get()
413 << "]\n},\n";
414
415 ss << " \"values\":" << population_interface->log_init_naa << "\n";
416 ss << "},\n";
417
418 for (size_t i = 0; i < population_interface->proportion_female.size();
419 i++) {
420 population_interface_ptr->proportion_female[i].final_value_m =
421 pop->proportion_female.get_force_scalar(i);
422 }
423 ss << " {\n\"name\": \"proportion_female\",\n";
424 ss << " \"id\":" << population_interface->proportion_female.id_m
425 << ",\n";
426 ss << " \"type\": \"vector\",\n";
427 ss << " \"dimensionality\": {\n";
428 ss << " \"header\": [" << "\"n_ages\"" << "],\n";
429 ss << " \"dimensions\": ["
430 << population_interface->proportion_female.size() << "]\n},\n";
431
432 ss << " \"values\":" << population_interface->proportion_female << "\n";
433 ss << "}],\n";
434
435 ss << " \"derived_quantities\": [\n";
436
437 std::map<std::string, fims::Vector<double>> dqs =
438 model_ptr->GetPopulationDerivedQuantities(
439 population_interface->get_id());
440
441 std::map<std::string, fims_popdy::DimensionInfo> dim_info =
442 model_ptr->GetPopulationDimensionInfo(population_interface->get_id());
444 << " ]}\n";
445 } else {
446 ss << "{\n";
447 ss << " \"name\": \"Population\",\n";
448
449 ss << " \"type\": \"population\",\n";
450 ss << " \"tag\": \"" << population_interface->get_id()
451 << " not found in Information.\",\n";
452 ss << " \"id\": " << population_interface->get_id() << ",\n";
453 ss << " \"recruitment_id\": " << population_interface->recruitment_id
454 << ",\n";
455 ss << " \"growth_id\": " << population_interface->growth_id << ",\n";
456 ss << " \"maturity_id\": " << population_interface->maturity_id << ",\n";
457 ss << " \"derived_quantities\": []}\n";
458 }
459
460 return ss.str();
461 }
462
469 std::map<std::string, fims::Vector<double>>::iterator it,
471 std::stringstream ss;
472 fims::Vector<double> &dq = (*it).second;
473 std::stringstream dim_entry;
474 // gather dimension information
475 switch (dim_info.ndims) {
476 case 1:
477 dim_entry << "\"dimensionality\": {\n";
478 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\"],\n";
479 dim_entry << " \"dimensions\": [";
480 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
481 if (i > 0) dim_entry << ", ";
482 dim_entry << dim_info.dims[i];
483 }
484 dim_entry << "]\n";
485 dim_entry << "}";
486 break;
487 case 2:
488 dim_entry << "\"dimensionality\": {\n";
489 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\", \""
490 << dim_info.dim_names[1] << "\"],\n";
491 dim_entry << " \"dimensions\": [";
492 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
493 if (i > 0) dim_entry << ", ";
494 dim_entry << dim_info.dims[i];
495 }
496 dim_entry << "]\n";
497 dim_entry << "}";
498 break;
499 case 3:
500 dim_entry << "\"dimensionality\": {\n";
501 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\", \""
502 << dim_info.dim_names[1] << "\", \"" << dim_info.dim_names[2]
503 << "\"],\n";
504 dim_entry << " \"dimensions\": [";
505 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
506 if (i > 0) dim_entry << ", ";
507 dim_entry << dim_info.dims[i];
508 }
509 dim_entry << "]\n";
510 dim_entry << "}";
511 break;
512 default:
513 dim_entry << "\"dimensionality\": {\n";
514 dim_entry << " \"header\": [],\n";
515 dim_entry << " \"dimensions\": []\n";
516 dim_entry << "}";
517 break;
518 }
519
520 // build JSON string
521 ss << "{\n";
522 ss << "\"name\":\"" << (*it).first << "\",\n";
523 ss << dim_entry.str() << ",\n";
524 ss << "\"value\":[";
525 ss << std::fixed << std::setprecision(10);
526 if (dq.size() > 0) {
527 for (size_t i = 0; i < dq.size() - 1; i++) {
528 if (dq[i] != dq[i]) // check for NaN
529 {
530 ss << "-999" << ", ";
531 } else {
532 ss << dq[i] << ", ";
533 }
534 }
535 if (dq[dq.size() - 1] != dq[dq.size() - 1]) // check for NaN
536 {
537 ss << "-999]" << "\n";
538 } else {
539 ss << dq[dq.size() - 1] << "]\n";
540 }
541 } else {
542 ss << "]\n";
543 }
544 ss << "}";
545
546 return ss.str();
547 }
548
554 std::map<std::string, fims::Vector<double>> &dqs,
555 std::map<std::string, fims_popdy::DimensionInfo> &dim_info) {
556 std::stringstream ss;
557 std::map<std::string, fims_popdy::DimensionInfo>::iterator dim_info_it;
558 std::map<std::string, fims::Vector<double>>::iterator it;
559 std::map<std::string, fims::Vector<double>>::iterator end_it;
560 end_it = dqs.end();
561 typename std::map<std::string, fims::Vector<double>>::iterator
563 second_to_last = dqs.end();
564 if (it != end_it) {
566 }
567
568 it = dqs.begin();
569 for (; it != second_to_last; ++it) {
570 dim_info_it = dim_info.find(it->first);
571 ss << this->derived_quantity_to_json(it, dim_info_it->second) << ",\n";
572 }
573
574 dim_info_it = dim_info.find(second_to_last->first);
575 if (dim_info_it != dim_info.end()) {
576 ss << this->derived_quantity_to_json(second_to_last, dim_info_it->second)
577 << "\n";
578 } else {
579 ss << "{}";
580 // Handle case where dimension info is not found
581 }
582 return ss.str();
583 }
584
589 std::stringstream ss;
590
591 if (!fleet_interface) {
593 "Fleet pointer is null; cannot get id. Not found in live objects.");
594 return "{}"; // Return empty JSON
595 }
596
597 std::shared_ptr<fims_info::Information<double>> info =
599
601 model_it = info->models_map.find(this->get_id());
602 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
603 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
604 (*model_it).second);
605
607
608 fit = info->fleets.find(fleet_interface->get_id());
609
610 if (fit != info->fleets.end()) {
611 std::shared_ptr<fims_popdy::Fleet<double>> &fleet = (*fit).second;
612
613 ss << "{\n";
614 ss << " \"module_name\": \"Fleet\",\n";
615 ss << " \"fleet\": \"" << fleet_interface->name << "\",\n";
616 ss << " \"module_id\": " << fleet_interface->id << ",\n";
617 ss << " \"n_ages\": " << fleet_interface->n_ages.get() << ",\n";
618 ss << " \"n_years\": " << fleet_interface->n_years.get() << ",\n";
619 ss << " \"n_lengths\": " << fleet_interface->n_lengths.get() << ",\n";
620 ss << "\"data_ids\" : [\n";
621 ss << "{\"agecomp\": " << fleet_interface->GetObservedAgeCompDataID()
622 << "},\n";
623 ss << "{\"lengthcomp\": "
624 << fleet_interface->GetObservedLengthCompDataID() << "},\n";
625 ss << "{\"index\": " << fleet_interface->GetObservedIndexDataID()
626 << "},\n";
627 ss << "{\"landings\": " << fleet_interface->GetObservedLandingsDataID()
628 << "}\n";
629 ss << "],\n";
630 ss << "\"parameters\": [\n";
631 ss << "{\n";
632 for (size_t i = 0; i < fleet_interface->log_Fmort.size(); i++) {
633 fleet_interface->log_Fmort[i].final_value_m = fleet->log_Fmort[i];
634 }
635
636 ss << " \"name\": \"log_Fmort\",\n";
637 ss << " \"id\":" << fleet_interface->log_Fmort.id_m << ",\n";
638 ss << " \"type\": \"vector\",\n";
639 ss << " \"dimensionality\": {\n";
640 ss << " \"header\": [\"" << "n_years" << "\"],\n";
641 ss << " \"dimensions\": [" << fleet_interface->n_years.get()
642 << "]\n},\n";
643 ss << " \"values\": " << fleet_interface->log_Fmort << "},\n";
644
645 ss << " {\n";
646 for (size_t i = 0; i < fleet->log_q.size(); i++) {
647 fleet_interface->log_q[i].final_value_m = fleet->log_q[i];
648 }
649 ss << " \"name\": \"log_q\",\n";
650 ss << " \"id\":" << fleet_interface->log_q.id_m << ",\n";
651 ss << " \"type\": \"vector\",\n";
652 ss << " \"dimensionality\": {\n";
653 ss << " \"header\": [\"" << "na" << "\"],\n";
654 ss << " \"dimensions\": [" << fleet->log_q.size() << "]\n},\n";
655
656 ss << " \"values\": " << fleet_interface->log_q << "}\n";
657
658 ss << "], \"derived_quantities\": [";
659
660 std::map<std::string, fims::Vector<double>> dqs =
661 model_ptr->GetFleetDerivedQuantities(fleet_interface->get_id());
662 std::map<std::string, fims_popdy::DimensionInfo> dim_info =
663 model_ptr->GetFleetDimensionInfo(fleet_interface->get_id());
664 ss << this->derived_quantities_component_to_json(dqs, dim_info) << "]}\n";
665 } else {
666 ss << "{\n";
667 ss << " \"name\": \"Fleet\",\n";
668 ss << " \"type\": \"fleet\",\n";
669 ss << " \"tag\": \"" << fleet_interface->get_id()
670 << " not found in Information.\",\n";
671 ss << " \"derived_quantities\": []}\n";
672 }
673 return ss.str();
674 }
675
679 virtual std::string to_json() {
680 std::set<uint32_t> recruitment_ids;
681 std::set<uint32_t> growth_ids;
682 std::set<uint32_t> maturity_ids;
683 std::set<uint32_t> selectivity_ids;
684 std::set<uint32_t> fleet_ids;
685 // gather sub-module info from population and fleets
686 typename std::set<uint32_t>::iterator module_id_it; // generic
687 typename std::set<uint32_t>::iterator pit;
688 typename std::set<uint32_t>::iterator fids;
689 for (pit = this->population_ids->begin();
690 pit != this->population_ids->end(); pit++) {
691 std::shared_ptr<PopulationInterface> population_interface =
692 std::dynamic_pointer_cast<PopulationInterface>(
695 recruitment_ids.insert(population_interface->recruitment_id.get());
696 growth_ids.insert(population_interface->growth_id.get());
697 maturity_ids.insert(population_interface->maturity_id.get());
698
699 for (fids = population_interface->fleet_ids->begin();
700 fids != population_interface->fleet_ids->end(); fids++) {
701 fleet_ids.insert(*fids);
702 }
703 }
704 }
705
706 for (fids = fleet_ids.begin(); fids != fleet_ids.end(); fids++) {
707 std::shared_ptr<FleetInterface> fleet_interface =
708 std::dynamic_pointer_cast<FleetInterface>(
710 if (fleet_interface) {
711 selectivity_ids.insert(fleet_interface->GetSelectivityID());
712 }
713 }
714
715 std::shared_ptr<fims_info::Information<double>> info =
717
718 std::shared_ptr<fims_popdy::CatchAtAge<double>> model =
719 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
720 info->models_map[this->get_id()]);
721
722 std::shared_ptr<fims_model::Model<double>> model_internal =
724
725#ifdef TMB_MODEL
726 model->do_reporting = false;
727#endif
728
729 double value = model_internal->Evaluate();
730
731 std::stringstream ss;
732
733 ss.str("");
734
735 ss << "{\n";
736 ss << " \"name\": \"CatchAtAge\",\n";
737 ss << " \"type\": \"model\",\n";
738 ss << " \"estimation_framework\": ";
739#ifdef TMB_MODEL
740 ss << "\"Template_Model_Builder (TMB)\",";
741#else
742 ss << "\"FIMS\",";
743#endif
744 ss << " \"id\": " << this->get_id() << ",\n";
745 ss << " \"objective_function_value\": " << sanitize_val(value) << ",\n";
746 ss << "\"growth\":[\n";
747 for (module_id_it = growth_ids.begin(); module_id_it != growth_ids.end();
748 module_id_it++) {
749 std::shared_ptr<GrowthInterfaceBase> growth_interface =
751
752 if (growth_interface != NULL) {
753 growth_interface->finalize();
754 ss << growth_interface->to_json();
755 if (std::next(module_id_it) != growth_ids.end()) {
756 ss << ", ";
757 }
758 }
759 }
760
761 ss << "],\n";
762
763 ss << "\"recruitment\": [\n";
764 for (module_id_it = recruitment_ids.begin();
766 std::shared_ptr<RecruitmentInterfaceBase> recruitment_interface =
769 recruitment_interface->finalize();
770 ss << recruitment_interface->to_json();
771 if (std::next(module_id_it) != recruitment_ids.end()) {
772 ss << ", ";
773 }
774 }
775 }
776 ss << "],\n";
777
778 ss << "\"maturity\": [\n";
779 for (module_id_it = maturity_ids.begin();
781 std::shared_ptr<MaturityInterfaceBase> maturity_interface =
783 if (maturity_interface) {
784 maturity_interface->finalize();
785 ss << maturity_interface->to_json();
786 if (std::next(module_id_it) != maturity_ids.end()) {
787 ss << ", ";
788 }
789 }
790 }
791 ss << "],\n";
792
793 ss << "\"selectivity\": [\n";
794 for (module_id_it = selectivity_ids.begin();
796 std::shared_ptr<SelectivityInterfaceBase> selectivity_interface =
799 selectivity_interface->finalize();
800 ss << selectivity_interface->to_json();
801 if (std::next(module_id_it) != selectivity_ids.end()) {
802 ss << ", ";
803 }
804 }
805 }
806 ss << "],\n";
807
808 ss << " \"population_ids\": [";
809 for (pit = this->population_ids->begin();
810 pit != this->population_ids->end(); pit++) {
811 ss << *pit;
812 if (std::next(pit) != this->population_ids->end()) {
813 ss << ", ";
814 }
815 }
816 ss << "],\n";
817 ss << " \"fleet_ids\": [";
818
819 for (fids = fleet_ids.begin(); fids != fleet_ids.end(); fids++) {
820 ss << *fids;
821 if (std::next(fids) != fleet_ids.end()) {
822 ss << ", ";
823 }
824 }
825 ss << "],\n";
826 ss << "\"populations\": [\n";
827 typename std::set<uint32_t>::iterator pop_it;
828 typename std::set<uint32_t>::iterator pop_end_it;
829 pop_end_it = this->population_ids->end();
830 typename std::set<uint32_t>::iterator pop_second_to_last_it;
831 if (pop_end_it != this->population_ids->begin()) {
832 pop_second_to_last_it = std::prev(pop_end_it);
833 } else {
835 }
836 for (pop_it = this->population_ids->begin();
837 pop_it != pop_second_to_last_it; pop_it++) {
838 std::shared_ptr<PopulationInterface> population_interface =
839 std::dynamic_pointer_cast<PopulationInterface>(
842 std::set<uint32_t>::iterator fids;
843 for (fids = population_interface->fleet_ids->begin();
844 fids != population_interface->fleet_ids->end(); fids++) {
845 fleet_ids.insert(*fids);
846 }
847 population_interface->finalize();
848 ss << this->population_to_json(population_interface.get()) << ",";
849 } else {
850 FIMS_ERROR_LOG("Population with id " + fims::to_string(*pop_it) +
851 " not found in live objects.");
852 ss << "{}"; // Return empty JSON for this population
853 }
854 }
855
856 std::shared_ptr<PopulationInterface> population_interface =
857 std::dynamic_pointer_cast<PopulationInterface>(
860 std::set<uint32_t>::iterator fids;
861 for (fids = population_interface->fleet_ids->begin();
862 fids != population_interface->fleet_ids->end(); fids++) {
863 fleet_ids.insert(*fids);
864 }
865 ss << this->population_to_json(population_interface.get());
866 } else {
867 FIMS_ERROR_LOG("Population with id " + fims::to_string(*pop_it) +
868 " not found in live objects.");
869 ss << "{}"; // Return empty JSON for this population
870 }
871
872 ss << "]";
873 ss << ",\n";
874 ss << "\"fleets\": [\n";
875
876 typename std::set<uint32_t>::iterator fleet_it;
877 typename std::set<uint32_t>::iterator fleet_end_it;
878 fleet_end_it = fleet_ids.end();
879 typename std::set<uint32_t>::iterator fleet_second_to_last_it;
880
881 if (fleet_end_it != fleet_ids.begin()) {
883 }
884 for (fleet_it = fleet_ids.begin(); fleet_it != fleet_second_to_last_it;
885 fleet_it++) {
886 std::shared_ptr<FleetInterface> fleet_interface =
887 std::dynamic_pointer_cast<FleetInterface>(
889 if (fleet_interface) {
890 fleet_interface->finalize();
891 ss << this->fleet_to_json(fleet_interface.get()) << ",";
892 } else {
893 FIMS_ERROR_LOG("Fleet with id " + fims::to_string(*fleet_it) +
894 " not found in live objects.");
895 ss << "{}"; // Return empty JSON for this fleet
896 }
897 }
898 std::shared_ptr<FleetInterface> fleet_interface =
899 std::dynamic_pointer_cast<FleetInterface>(
901 if (fleet_interface) {
902 ss << this->fleet_to_json(fleet_interface.get());
903 } else {
904 FIMS_ERROR_LOG("Fleet with id " + fims::to_string(*fleet_it) +
905 " not found in live objects.");
906 ss << "{}"; // Return empty JSON for this fleet
907 }
908
909 ss << "],\n";
910
911 ss << "\"density_components\": [\n";
912
913 typename std::map<
914 uint32_t, std::shared_ptr<DistributionsInterfaceBase>>::iterator dit;
917 std::shared_ptr<DistributionsInterfaceBase> dist_interface =
918 (*dit).second;
919 if (dist_interface) {
920 dist_interface->finalize();
921 ss << dist_interface->to_json();
922 if (std::next(dit) != DistributionsInterfaceBase::live_objects.end()) {
923 ss << ",\n";
924 }
925 }
926 }
927 ss << "\n],\n";
928 ss << "\"data\": [\n";
929 typename std::map<uint32_t, std::shared_ptr<DataInterfaceBase>>::iterator
930 d_it;
933 std::shared_ptr<DataInterfaceBase> data_interface = (*d_it).second;
934 if (data_interface) {
935 data_interface->finalize();
936 ss << data_interface->to_json();
937 if (std::next(d_it) != DataInterfaceBase::live_objects.end()) {
938 ss << ",\n";
939 }
940 }
941 }
942 ss << "\n]\n";
943 ss << "}\n";
944#ifdef TMB_MODEL
945 model->do_reporting = true;
946#endif
948 }
949
950#ifdef TMB_MODEL
951
952 template <typename Type>
954 std::shared_ptr<fims_info::Information<Type>> info =
956
957 std::shared_ptr<fims_popdy::CatchAtAge<Type>> model =
958 std::make_shared<fims_popdy::CatchAtAge<Type>>();
959
961
962 for (it = this->population_ids->begin(); it != this->population_ids->end();
963 ++it) {
964 model->AddPopulation((*it));
965 }
966
967 std::set<uint32_t> fleet_ids; // all fleets in the model
968 typedef typename std::set<uint32_t>::iterator fleet_ids_iterator;
969
970 // add to Information
971 info->models_map[this->get_id()] = model;
972
973 for (it = this->population_ids->begin(); it != this->population_ids->end();
974 ++it) {
977 throw std::runtime_error("Population ID " + std::to_string(*it) +
978 " not found in live_objects");
979 }
980 auto population =
981 std::dynamic_pointer_cast<PopulationInterface>(it2->second);
982 model->InitializePopulationDerivedQuantities(population->id);
983 std::map<std::string, fims::Vector<Type>> &derived_quantities =
984 model->GetPopulationDerivedQuantities(population->id);
985
986 std::map<std::string, fims_popdy::DimensionInfo>
988 model->GetPopulationDimensionInfo(population->id);
989
990 std::stringstream ss;
991
992 derived_quantities["total_landings_weight"] =
993 fims::Vector<Type>(population->n_years.get());
994
995 derived_quantities_dim_info["total_landings_weight"] =
997 "total_landings_weight",
998 fims::Vector<int>{(int)population->n_years.get()},
999 fims::Vector<std::string>{"n_years"});
1000
1001 derived_quantities["total_landings_numbers"] =
1002 fims::Vector<Type>(population->n_years.get());
1003
1004 derived_quantities_dim_info["total_landings_numbers"] =
1006 "total_landings_numbers",
1007 fims::Vector<int>{population->n_years.get()},
1008 fims::Vector<std::string>{"n_years"});
1009
1010 derived_quantities["mortality_F"] = fims::Vector<Type>(
1011 population->n_years.get() * population->n_ages.get());
1013 "mortality_F",
1014 fims::Vector<int>{population->n_years.get(),
1015 population->n_ages.get()},
1016 fims::Vector<std::string>{"n_years", "n_ages"});
1017
1018 derived_quantities["mortality_M"] = fims::Vector<Type>(
1019 population->n_years.get() * population->n_ages.get());
1021 "mortality_M",
1022 fims::Vector<int>{population->n_years.get(),
1023 population->n_ages.get()},
1024 fims::Vector<std::string>{"n_years", "n_ages"});
1025
1026 derived_quantities["mortality_Z"] = fims::Vector<Type>(
1027 population->n_years.get() * population->n_ages.get());
1029 "mortality_Z",
1030 fims::Vector<int>{population->n_years.get(),
1031 population->n_ages.get()},
1032 fims::Vector<std::string>{"n_years", "n_ages"});
1033
1034 derived_quantities["numbers_at_age"] = fims::Vector<Type>(
1035 (population->n_years.get() + 1) * population->n_ages.get());
1037 "numbers_at_age",
1038 fims::Vector<int>{(population->n_years.get() + 1),
1039 population->n_ages.get()},
1040 fims::Vector<std::string>{"n_years+1", "n_ages"});
1041
1042 derived_quantities["unfished_numbers_at_age"] = fims::Vector<Type>(
1043 (population->n_years.get() + 1) * population->n_ages.get());
1044 derived_quantities_dim_info["unfished_numbers_at_age"] =
1046 "unfished_numbers_at_age",
1047 fims::Vector<int>{(population->n_years.get() + 1),
1048 population->n_ages.get()},
1049 fims::Vector<std::string>{"n_years+1", "n_ages"});
1050
1051 derived_quantities["biomass"] =
1052 fims::Vector<Type>((population->n_years.get() + 1));
1054 "biomass", fims::Vector<int>{(population->n_years.get() + 1)},
1055 fims::Vector<std::string>{"n_years+1"});
1056
1057 derived_quantities["spawning_biomass"] =
1058 fims::Vector<Type>((population->n_years.get() + 1));
1059 derived_quantities_dim_info["spawning_biomass"] =
1061 "spawning_biomass",
1062 fims::Vector<int>{(population->n_years.get() + 1)},
1063 fims::Vector<std::string>{"n_years+1"});
1064
1065 derived_quantities["unfished_biomass"] =
1066 fims::Vector<Type>((population->n_years.get() + 1));
1067 derived_quantities_dim_info["unfished_biomass"] =
1069 "unfished_biomass",
1070 fims::Vector<int>{(population->n_years.get() + 1)},
1071 fims::Vector<std::string>{"n_years+1"});
1072
1073 derived_quantities["unfished_spawning_biomass"] =
1074 fims::Vector<Type>((population->n_years.get() + 1));
1075 derived_quantities_dim_info["unfished_spawning_biomass"] =
1077 "unfished_spawning_biomass",
1078 fims::Vector<int>{(population->n_years.get() + 1)},
1079 fims::Vector<std::string>{"n_years+1"});
1080
1081 derived_quantities["proportion_mature_at_age"] = fims::Vector<Type>(
1082 (population->n_years.get() + 1) * population->n_ages.get());
1083 derived_quantities_dim_info["proportion_mature_at_age"] =
1085 "proportion_mature_at_age",
1086 fims::Vector<int>{(population->n_years.get() + 1),
1087 population->n_ages.get()},
1088 fims::Vector<std::string>{"n_years+1", "n_ages"});
1089
1090 derived_quantities["expected_recruitment"] =
1091 fims::Vector<Type>((population->n_years.get() + 1));
1092 derived_quantities_dim_info["expected_recruitment"] =
1094 "expected_recruitment",
1095 fims::Vector<int>{(population->n_years.get() + 1)},
1096 fims::Vector<std::string>{"n_years+1"});
1097
1098 derived_quantities["sum_selectivity"] = fims::Vector<Type>(
1099 population->n_years.get() * population->n_ages.get());
1100 derived_quantities_dim_info["sum_selectivity"] =
1102 "sum_selectivity",
1103 fims::Vector<int>{population->n_years.get(),
1104 population->n_ages.get()},
1105 fims::Vector<std::string>{"n_years", "n_ages"});
1106
1107 // replace elements in the variable map
1108
1109 for (fleet_ids_iterator fit = population->fleet_ids->begin();
1110 fit != population->fleet_ids->end(); ++fit) {
1111 fleet_ids.insert(*fit);
1112 }
1113 }
1114
1115 for (fleet_ids_iterator it = fleet_ids.begin(); it != fleet_ids.end();
1116 ++it) {
1117 std::shared_ptr<FleetInterface> fleet_interface =
1118 std::dynamic_pointer_cast<FleetInterface>(
1120 model->InitializeFleetDerivedQuantities(fleet_interface->id);
1121 std::map<std::string, fims::Vector<Type>> &derived_quantities =
1122 model->GetFleetDerivedQuantities(fleet_interface->id);
1123
1124 std::map<std::string, fims_popdy::DimensionInfo>
1126 model->GetFleetDimensionInfo(fleet_interface->id);
1127
1128 // initialize derive quantities
1129 // landings
1130 derived_quantities["landings_numbers_at_age"] = fims::Vector<Type>(
1131 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1132 derived_quantities_dim_info["landings_numbers_at_age"] =
1134 "landings_numbers_at_age",
1135 fims::Vector<int>{(fleet_interface->n_years.get()),
1136 fleet_interface->n_ages.get()},
1137 fims::Vector<std::string>{"n_years", "n_ages"});
1138
1139 derived_quantities["landings_weight_at_age"] = fims::Vector<Type>(
1140 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1141 derived_quantities_dim_info["landings_weight_at_age"] =
1143 "landings_weight_at_age",
1144 fims::Vector<int>{(fleet_interface->n_years.get()),
1145 fleet_interface->n_ages.get()},
1146 fims::Vector<std::string>{"n_years", "n_ages"});
1147
1148 derived_quantities["landings_numbers_at_length"] = fims::Vector<Type>(
1149 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1150 derived_quantities_dim_info["landings_numbers_at_length"] =
1152 "landings_numbers_at_length",
1153 fims::Vector<int>{(fleet_interface->n_years.get()),
1154 fleet_interface->n_lengths.get()},
1155 fims::Vector<std::string>{"n_years", "n_lengths"});
1156
1157 derived_quantities["landings_weight"] =
1158 fims::Vector<Type>(fleet_interface->n_years.get());
1159 derived_quantities_dim_info["landings_weight"] =
1161 "landings_weight",
1162 fims::Vector<int>{(fleet_interface->n_years.get())},
1163 fims::Vector<std::string>{"n_years"});
1164
1165 derived_quantities["landings_numbers"] =
1166 fims::Vector<Type>(fleet_interface->n_years.get());
1167 derived_quantities_dim_info["landings_numbers"] =
1169 "landings_numbers",
1170 fims::Vector<int>{(fleet_interface->n_years.get())},
1171 fims::Vector<std::string>{"n_years"});
1172
1173 derived_quantities["landings_expected"] =
1174 fims::Vector<Type>(fleet_interface->n_years.get());
1175 derived_quantities_dim_info["landings_expected"] =
1177 "landings_expected",
1178 fims::Vector<int>{(fleet_interface->n_years.get())},
1179 fims::Vector<std::string>{"n_years"});
1180
1181 derived_quantities["log_landings_expected"] =
1182 fims::Vector<Type>(fleet_interface->n_years.get());
1183 derived_quantities_dim_info["log_landings_expected"] =
1185 "log_landings_expected",
1186 fims::Vector<int>{(fleet_interface->n_years.get())},
1187 fims::Vector<std::string>{"n_years"});
1188
1189 derived_quantities["agecomp_proportion"] = fims::Vector<Type>(
1190 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1191 derived_quantities_dim_info["agecomp_proportion"] =
1193 "agecomp_proportion",
1194 fims::Vector<int>{(fleet_interface->n_years.get()),
1195 fleet_interface->n_ages.get()},
1196 fims::Vector<std::string>{"n_years", "n_ages"});
1197
1198 derived_quantities["lengthcomp_proportion"] = fims::Vector<Type>(
1199 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1200 derived_quantities_dim_info["lengthcomp_proportion"] =
1202 "lengthcomp_proportion",
1203 fims::Vector<int>{(fleet_interface->n_years.get()),
1204 fleet_interface->n_lengths.get()},
1205 fims::Vector<std::string>{"n_years", "n_lengths"});
1206
1207 // index
1208 derived_quantities["index_numbers_at_age"] = fims::Vector<Type>(
1209 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1210 derived_quantities_dim_info["index_numbers_at_age"] =
1212 "index_numbers_at_age",
1213 fims::Vector<int>{(fleet_interface->n_years.get()),
1214 fleet_interface->n_ages.get()},
1215 fims::Vector<std::string>{"n_years", "n_ages"});
1216
1217 derived_quantities["index_weight_at_age"] = fims::Vector<Type>(
1218 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1219 derived_quantities_dim_info["index_weight_at_age"] =
1221 "index_weight_at_age",
1222 fims::Vector<int>{(fleet_interface->n_years.get()),
1223 fleet_interface->n_ages.get()},
1224 fims::Vector<std::string>{"n_years", "n_ages"});
1225
1226 derived_quantities["index_weight_at_age"] = fims::Vector<Type>(
1227 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1228 derived_quantities_dim_info["index_weight_at_age"] =
1230 "index_weight_at_age",
1231 fims::Vector<int>{(fleet_interface->n_years.get()),
1232 fleet_interface->n_ages.get()},
1233 fims::Vector<std::string>{"n_years", "n_ages"});
1234
1235 derived_quantities["index_numbers_at_length"] = fims::Vector<Type>(
1236 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1237 derived_quantities_dim_info["index_numbers_at_length"] =
1239 "index_numbers_at_length",
1240 fims::Vector<int>{(fleet_interface->n_years.get()),
1241 fleet_interface->n_lengths.get()},
1242 fims::Vector<std::string>{"n_years", "n_lengths"});
1243 derived_quantities["index_weight"] =
1244 fims::Vector<Type>(fleet_interface->n_years.get());
1246 "index_weight", fims::Vector<int>{(fleet_interface->n_years.get())},
1247 fims::Vector<std::string>{"n_years"});
1248
1249 derived_quantities["index_numbers"] =
1250 fims::Vector<Type>(fleet_interface->n_years.get());
1252 "index_numbers", fims::Vector<int>{(fleet_interface->n_years.get())},
1253 fims::Vector<std::string>{"n_years"});
1254
1255 derived_quantities["index_expected"] =
1256 fims::Vector<Type>(fleet_interface->n_years.get());
1258 "index_expected", fims::Vector<int>{(fleet_interface->n_years.get())},
1259 fims::Vector<std::string>{"n_years"});
1260
1261 derived_quantities["log_index_expected"] =
1262 fims::Vector<Type>(fleet_interface->n_years.get());
1263 derived_quantities_dim_info["log_index_expected"] =
1265 "log_index_expected",
1266 fims::Vector<int>{(fleet_interface->n_years.get())},
1267 fims::Vector<std::string>{"n_years"});
1268
1269 derived_quantities["catch_index"] =
1270 fims::Vector<Type>(fleet_interface->n_years.get());
1272 "catch_index", fims::Vector<int>{(fleet_interface->n_years.get())},
1273 fims::Vector<std::string>{"n_years"});
1274
1275 derived_quantities["agecomp_expected"] = fims::Vector<Type>(
1276 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1277 derived_quantities_dim_info["agecomp_expected"] =
1279 "agecomp_expected",
1280 fims::Vector<int>{(fleet_interface->n_years.get()),
1281 (fleet_interface->n_ages.get())},
1282 fims::Vector<std::string>{"n_years", "n_ages"});
1283
1284 derived_quantities["lengthcomp_expected"] = fims::Vector<Type>(
1285 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1286 derived_quantities_dim_info["lengthcomp_expected"] =
1288 "lengthcomp_expected",
1289 fims::Vector<int>{(fleet_interface->n_years.get()),
1290 (fleet_interface->n_lengths.get())},
1291 fims::Vector<std::string>{"n_years", "n_lengths"});
1292
1293 // replace elements in the variable map
1294 info->variable_map[fleet_interface->log_landings_expected.id_m] =
1295 &(derived_quantities["log_landings_expected"]);
1296 info->variable_map[fleet_interface->log_index_expected.id_m] =
1297 &(derived_quantities["log_index_expected"]);
1298 info->variable_map[fleet_interface->agecomp_expected.id_m] =
1299 &(derived_quantities["agecomp_expected"]);
1300 info->variable_map[fleet_interface->agecomp_proportion.id_m] =
1301 &(derived_quantities["agecomp_proportion"]);
1302 info->variable_map[fleet_interface->lengthcomp_expected.id_m] =
1303 &(derived_quantities["lengthcomp_expected"]);
1304 info->variable_map[fleet_interface->lengthcomp_proportion.id_m] =
1305 &(derived_quantities["lengthcomp_proportion"]);
1306 }
1307
1308 return true;
1309 }
1310
1311 virtual bool add_to_fims_tmb() {
1314 return true;
1315 }
1316
1317#endif
1318};
1319
1320#endif
The CatchAtAgeInterface class is used to interface with the CatchAtAge model. It inherits from the Fi...
Definition rcpp_models.hpp:216
virtual std::string to_json()
Serialize the fishery model to a JSON string.
Definition rcpp_models.hpp:679
void AddPopulation(uint32_t id)
Definition rcpp_models.hpp:239
std::string derived_quantity_to_json(std::map< std::string, fims::Vector< double > >::iterator it, const fims_popdy::DimensionInfo &dim_info)
Definition rcpp_models.hpp:468
virtual void finalize()
Extracts derived quantities back to the Rcpp interface object from the Information object.
Definition rcpp_models.hpp:308
CatchAtAgeInterface()
The constructor.
Definition rcpp_models.hpp:221
void DoReporting(bool report)
Enable or disable reporting for the CatchAtAge model.
Definition rcpp_models.hpp:260
virtual uint32_t get_id()
Method to get this id.
Definition rcpp_models.hpp:303
std::string fleet_to_json(FleetInterface *fleet_interface)
Method to convert a fleet to a JSON string.
Definition rcpp_models.hpp:588
std::string derived_quantities_component_to_json(std::map< std::string, fims::Vector< double > > &dqs, std::map< std::string, fims_popdy::DimensionInfo > &dim_info)
Send the fleet-based derived quantities to the json file.
Definition rcpp_models.hpp:553
std::string population_to_json(PopulationInterface *population_interface)
Method to convert a population to a JSON string.
Definition rcpp_models.hpp:313
CatchAtAgeInterface(const CatchAtAgeInterface &other)
Construct a new Catch At Age Interface object.
Definition rcpp_models.hpp:233
bool IsReporting()
Check if reporting is enabled for the CatchAtAge model.
Definition rcpp_models.hpp:282
static std::map< uint32_t, std::shared_ptr< DataInterfaceBase > > live_objects
The map associating the IDs of DataInterfaceBase to the objects. This is a live object,...
Definition rcpp_data.hpp:43
static std::map< uint32_t, std::shared_ptr< DistributionsInterfaceBase > > live_objects
The map associating the ID of the DistributionsInterfaceBase to the DistributionsInterfaceBase object...
Definition rcpp_distribution.hpp:67
Base class for all interface objects.
Definition rcpp_interface_base.hpp:628
static std::vector< std::shared_ptr< FIMSRcppInterfaceBase > > fims_interface_objects
FIMS interface object vectors.
Definition rcpp_interface_base.hpp:638
virtual bool add_to_fims_tmb()
A virtual method to inherit to add objects to the TMB model.
Definition rcpp_interface_base.hpp:643
The FisheryModelInterfaceBase class is the base class for all fishery models in the FIMS Rcpp interfa...
Definition rcpp_models.hpp:36
double min(const std::valarray< double > &v)
Minimum method to calculate the minimum of an array or vector of doubles.
Definition rcpp_models.hpp:185
FisheryModelInterfaceBase(const FisheryModelInterfaceBase &other)
Construct a new Data Interface Base object.
Definition rcpp_models.hpp:80
static uint32_t id_g
The static id of the FleetInterfaceBase object.
Definition rcpp_models.hpp:51
virtual uint32_t get_id()=0
Get the ID for the child fleet interface objects to inherit.
FisheryModelInterfaceBase()
The constructor.
Definition rcpp_models.hpp:67
std::set< uint32_t >::iterator population_id_iterator
Iterator for population ids.
Definition rcpp_models.hpp:45
uint32_t id
The local id of the FleetInterfaceBase object.
Definition rcpp_models.hpp:55
std::valarray< double > fabs(const std::valarray< double > &v)
A function to compute the absolute value of a value array of floating-point values....
Definition rcpp_models.hpp:203
virtual std::string to_json()
Serialize the fishery model to a JSON string.
Definition rcpp_models.hpp:101
static std::map< uint32_t, std::shared_ptr< FisheryModelInterfaceBase > > live_objects
The map associating the IDs of FleetInterfaceBase to the objects. This is a live object,...
Definition rcpp_models.hpp:62
double sum(const std::valarray< double > &v)
Sum method to calculate the sum of an array or vector of doubles.
Definition rcpp_models.hpp:156
Rcpp::NumericVector get_random_parameters_vector()
Get the vector of random effect parameters for the model.
Definition rcpp_models.hpp:137
Rcpp::NumericVector get_fixed_parameters_vector()
Get the vector of fixed effect parameters for the model.
Definition rcpp_models.hpp:117
std::shared_ptr< std::set< uint32_t > > population_ids
The set of population ids that this fishery model operates on.
Definition rcpp_models.hpp:41
virtual ~FisheryModelInterfaceBase()
The destructor.
Definition rcpp_models.hpp:86
double sum(const std::vector< double > &v)
Sum method for a vector of doubles.
Definition rcpp_models.hpp:170
static std::map< uint32_t, std::shared_ptr< FleetInterfaceBase > > live_objects
The map associating the IDs of FleetInterfaceBase to the objects. This is a live object,...
Definition rcpp_fleet.hpp:34
The Rcpp interface for Fleet to instantiate from R: fleet <- methods::new(Fleet)
Definition rcpp_fleet.hpp:68
static std::map< uint32_t, std::shared_ptr< GrowthInterfaceBase > > live_objects
The map associating the IDs of GrowthInterfaceBase to the objects. This is a live object,...
Definition rcpp_growth.hpp:34
static std::map< uint32_t, std::shared_ptr< MaturityInterfaceBase > > live_objects
The map associating the IDs of MaturityInterfaceBase to the objects. This is a live object,...
Definition rcpp_maturity.hpp:35
static std::map< uint32_t, std::shared_ptr< PopulationInterfaceBase > > live_objects
The map associating the IDs of PopulationInterfaceBase to the objects. This is a live object,...
Definition rcpp_population.hpp:35
Rcpp interface for a new Population to instantiate from R: population <- methods::new(population)
Definition rcpp_population.hpp:80
static std::map< uint32_t, std::shared_ptr< RecruitmentInterfaceBase > > live_objects
The map associating the IDs of RecruitmentInterfaceBase to the objects. This is a live object,...
Definition rcpp_recruitment.hpp:40
static std::map< uint32_t, std::shared_ptr< SelectivityInterfaceBase > > live_objects
The map associating the IDs of SelectivityInterfaceBase to the objects. This is a live object,...
Definition rcpp_selectivity.hpp:35
static std::string PrettyFormatJSON(const std::string &json)
Formats a JSON string.
Definition fims_json.hpp:128
Definition fims_vector.hpp:27
std::unordered_map< uint32_t, std::shared_ptr< fims_popdy::FisheryModelBase< Type > > > models_map
Definition information.hpp:135
std::map< uint32_t, std::shared_ptr< fims_popdy::Fleet< Type > > >::iterator fleet_iterator
Definition information.hpp:109
std::map< uint32_t, std::shared_ptr< fims_popdy::Population< Type > > >::iterator population_iterator
Definition information.hpp:119
std::unordered_map< uint32_t, std::shared_ptr< fims_popdy::FisheryModelBase< Type > > >::iterator model_map_iterator
Definition information.hpp:139
static std::shared_ptr< Information< Type > > GetInstance()
Returns a singleton Information object for type T.
Definition information.hpp:237
static std::shared_ptr< Model< Type > > GetInstance()
Evaluate. Calculates the joint negative log-likelihood function.
Definition model.hpp:54
Platform macros and the core FIMS logging system.
#define FIMS_ERROR_LOG(MESSAGE)
Definition def.hpp:664
: Loops over model components and returns the negative log-likelihood function.
The Rcpp interface to declare different types of data, e.g., age-composition and index data....
The Rcpp interface to declare different distributions, e.g., normal and log normal....
The Rcpp interface to declare fleets. Allows for the use of methods::new() in R.
The Rcpp interface to declare different types of growth, e.g., empirical weight-at-age data....
void clear_internal()
Clears the internal objects.
Definition rcpp_interface.hpp:235
The Rcpp interface to declare objects that are used ubiquitously throughout the Rcpp interface,...
double sanitize_val(double x)
Sanitize a double value by replacing NaN or Inf with -999.0.
Definition rcpp_interface_base.hpp:113
The Rcpp interface to declare different maturity options, e.g., logistic. Allows for the use of metho...
The Rcpp interface to declare different types of populations. Allows for the use of methods::new() in...
The Rcpp interface to declare different types of recruitment, e.g., Beverton–Holt stock–recruitment r...
The Rcpp interface to declare different types of selectivity, e.g., logistic and double logistic....
Structure to hold dimension information for derived quantities.
Definition fishery_model_base.hpp:25