FIMS  v0.9.2
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 "../../../utilities/fims_json.hpp"
17#include "rcpp_population.hpp"
18#include "rcpp_fleet.hpp"
19#include "rcpp_maturity.hpp"
20#include "rcpp_recruitment.hpp"
21#include "rcpp_selectivity.hpp"
22#include <valarray>
23#include <cmath>
24#include <mutex>
25
33 protected:
37 std::shared_ptr<std::set<uint32_t>> population_ids;
41 typedef typename std::set<uint32_t>::iterator population_id_iterator;
42
43 public:
47 static uint32_t id_g;
57 static std::map<uint32_t, std::shared_ptr<FisheryModelInterfaceBase>>
59
65 this->population_ids = std::make_shared<std::set<uint32_t>>();
66 /* Create instance of map: key is id and value is pointer to
67 FleetInterfaceBase */
68 // FisheryModelInterfaceBase::live_objects[this->id] = this;
69 }
70
78
83
97 virtual std::string to_json() {
98 return "std::string to_json() not yet implemented.";
99 }
100
104 virtual uint32_t get_id() = 0;
105
113 Rcpp::NumericVector get_fixed_parameters_vector() {
114 std::shared_ptr<fims_info::Information<double>> info0 =
116
117 Rcpp::NumericVector p;
118
119 for (size_t i = 0; i < info0->fixed_effects_parameters.size(); i++) {
120 p.push_back(*info0->fixed_effects_parameters[i]);
121 }
122
123 return p;
124 }
125
133 Rcpp::NumericVector get_random_parameters_vector() {
134 std::shared_ptr<fims_info::Information<double>> d0 =
136
137 Rcpp::NumericVector p;
138
139 for (size_t i = 0; i < d0->random_effects_parameters.size(); i++) {
140 p.push_back(*d0->random_effects_parameters[i]);
141 }
142
143 return p;
144 }
145
152 double sum(const std::valarray<double> &v) {
153 double sum = 0.0;
154 for (size_t i = 0; i < v.size(); i++) {
155 sum += v[i];
156 }
157 return sum;
158 }
159
166 double sum(const std::vector<double> &v) {
167 double sum = 0.0;
168 for (size_t i = 0; i < v.size(); i++) {
169 sum += v[i];
170 }
171 return sum;
172 }
173
181 double min(const std::valarray<double> &v) {
182 double min_value = v[0];
183 for (size_t i = 1; i < v.size(); i++) {
184 if (v[i] < min_value) {
185 min_value = v[i];
186 }
187 }
188 return min_value;
189 }
190
199 std::valarray<double> fabs(const std::valarray<double> &v) {
200 std::valarray<double> result(v.size());
201 for (size_t i = 0; i < v.size(); i++) {
202 result[i] = std::fabs(v[i]);
203 }
204 return result;
205 }
206};
207// static id of the FleetInterfaceBase object
209
210// FleetInterfaceBase to the FleetInterfaceBase objects
211std::map<uint32_t, std::shared_ptr<FisheryModelInterfaceBase>>
213
219 public:
224 std::shared_ptr<CatchAtAgeInterface> caa =
225 std::make_shared<CatchAtAgeInterface>(*this);
228 }
229
237
242 this->population_ids->insert(id);
243
244 std::map<uint32_t, std::shared_ptr<PopulationInterfaceBase>>::iterator pit;
247 std::shared_ptr<PopulationInterfaceBase> &pop = (*pit).second;
248 pop->initialize_catch_at_age.set(true);
249 } else {
250 FIMS_ERROR_LOG("Population with id " + fims::to_string(id) +
251 " not found.");
252 }
253 }
254
262 void DoReporting(bool report) {
263#ifdef TMB_MODEL
264 std::shared_ptr<fims_info::Information<double>> info =
267 model_it = info->models_map.find(this->get_id());
268 if (model_it != info->models_map.end()) {
269 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
270 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
271 (*model_it).second);
272 model_ptr->do_reporting = report;
273 }
274#endif
275 }
276
284 bool IsReporting() {
285#ifdef TMB_MODEL
286 std::shared_ptr<fims_info::Information<double>> info =
289 model_it = info->models_map.find(this->get_id());
290 if (model_it != info->models_map.end()) {
291 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
292 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
293 (*model_it).second);
294 return model_ptr->do_reporting;
295 }
296 return false;
297#else
298 return false;
299#endif
300 }
301
305 virtual uint32_t get_id() { return this->id; }
306
310 virtual void finalize() {}
311
316 std::stringstream ss;
317
318 typename std::map<uint32_t,
319 std::shared_ptr<PopulationInterfaceBase>>::iterator
320 pi_it; // population interface iterator
322 population_interface->get_id());
324 FIMS_ERROR_LOG("Population with id " +
325 fims::to_string(population_interface->get_id()) +
326 " not found in live objects.");
327 return "{}"; // Return empty JSON
328 }
329
330 std::shared_ptr<PopulationInterface> population_interface_ptr =
331 std::dynamic_pointer_cast<PopulationInterface>((*pi_it).second);
332
333 std::shared_ptr<fims_info::Information<double>> info =
335
337 model_it = info->models_map.find(this->get_id());
338 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
339 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
340 (*model_it).second);
341
343
344 pit = info->populations.find(population_interface->get_id());
345
346 if (pit != info->populations.end()) {
347 std::shared_ptr<fims_popdy::Population<double>> &pop = (*pit).second;
348 ss << "{\n";
349
350 ss << " \"module_name\": \"Population\",\n";
351 ss << " \"population\": \"" << population_interface->name << "\",\n";
352 ss << " \"module_id\": " << population_interface->id << ",\n";
353 ss << " \"recruitment_id\": " << population_interface->recruitment_id
354 << ",\n";
355 ss << " \"growth_id\": " << population_interface->growth_id << ",\n";
356 ss << " \"maturity_id\": " << population_interface->maturity_id << ",\n";
357
358 ss << " \"parameters\": [\n";
359 for (size_t i = 0; i < pop->log_M.size(); i++) {
360 population_interface_ptr->log_M[i].final_value_m = pop->log_M[i];
361 }
362
363 ss << "{\n \"name\": \"log_M\",\n";
364 ss << " \"id\":" << population_interface->log_M.id_m << ",\n";
365 ss << " \"type\": \"vector\",\n";
366 ss << " \"dimensionality\": {\n";
367 ss << " \"header\": [" << "\"n_years\", \"n_ages\"" << "],\n";
368 ss << " \"dimensions\": [" << population_interface->n_years.get() << ", "
369 << population_interface->n_ages.get() << "]\n},\n";
370 ss << " \"values\": " << population_interface->log_M << "\n\n";
371 ss << "},\n";
372
373 for (size_t i = 0; i < pop->log_f_multiplier.size(); i++) {
374 population_interface_ptr->log_f_multiplier[i].final_value_m =
375 pop->log_f_multiplier[i];
376 }
377
378 ss << "{\n \"name\": \"log_f_multiplier\",\n";
379 ss << " \"id\":" << population_interface->log_f_multiplier.id_m << ",\n";
380 ss << " \"type\": \"vector\",\n";
381 ss << " \"dimensionality\": {\n";
382 ss << " \"header\": [" << "\"n_years\"" << "],\n";
383 ss << " \"dimensions\": [" << population_interface->n_years.get()
384 << "]\n},\n";
385 ss << " \"values\": " << population_interface->log_f_multiplier << "\n\n";
386 ss << "},\n";
387
388 for (size_t i = 0; i < pop->spawning_biomass_ratio.size(); i++) {
389 population_interface_ptr->spawning_biomass_ratio[i].final_value_m =
390 pop->spawning_biomass_ratio[i];
391 }
392
393 ss << "{\n \"name\": \"spawning_biomass_ratio\",\n";
394 ss << " \"id\":" << population_interface->spawning_biomass_ratio.id_m
395 << ",\n";
396 ss << " \"type\": \"vector\",\n";
397 ss << " \"dimensionality\": {\n";
398 ss << " \"header\": [" << "\"n_years\"" << "],\n";
399 ss << " \"dimensions\": [" << (population_interface->n_years.get() + 1)
400 << "]\n},\n";
401 ss << " \"values\": " << population_interface->spawning_biomass_ratio
402 << "\n\n";
403 ss << "},\n";
404
405 for (size_t i = 0; i < pop->log_init_naa.size(); i++) {
406 population_interface_ptr->log_init_naa[i].final_value_m =
407 pop->log_init_naa[i];
408 }
409 ss << " {\n\"name\": \"log_init_naa\",\n";
410 ss << " \"id\":" << population_interface->log_init_naa.id_m << ",\n";
411 ss << " \"type\": \"vector\",\n";
412 ss << " \"dimensionality\": {\n";
413 ss << " \"header\": [" << "\"n_ages\"" << "],\n";
414 ss << " \"dimensions\": [" << population_interface->n_ages.get()
415 << "]\n},\n";
416
417 ss << " \"values\":" << population_interface->log_init_naa << "\n";
418 ss << "}],\n";
419
420 ss << " \"derived_quantities\": [\n";
421
422 std::map<std::string, fims::Vector<double>> dqs =
423 model_ptr->GetPopulationDerivedQuantities(
424 population_interface->get_id());
425
426 std::map<std::string, fims_popdy::DimensionInfo> dim_info =
427 model_ptr->GetPopulationDimensionInfo(population_interface->get_id());
429 << " ]}\n";
430 } else {
431 ss << "{\n";
432 ss << " \"name\": \"Population\",\n";
433
434 ss << " \"type\": \"population\",\n";
435 ss << " \"tag\": \"" << population_interface->get_id()
436 << " not found in Information.\",\n";
437 ss << " \"id\": " << population_interface->get_id() << ",\n";
438 ss << " \"recruitment_id\": " << population_interface->recruitment_id
439 << ",\n";
440 ss << " \"growth_id\": " << population_interface->growth_id << ",\n";
441 ss << " \"maturity_id\": " << population_interface->maturity_id << ",\n";
442 ss << " \"derived_quantities\": []}\n";
443 }
444
445 return ss.str();
446 }
447
454 std::map<std::string, fims::Vector<double>>::iterator it,
456 std::stringstream ss;
457 fims::Vector<double> &dq = (*it).second;
458 std::stringstream dim_entry;
459 // gather dimension information
460 switch (dim_info.ndims) {
461 case 1:
462 dim_entry << "\"dimensionality\": {\n";
463 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\"],\n";
464 dim_entry << " \"dimensions\": [";
465 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
466 if (i > 0) dim_entry << ", ";
467 dim_entry << dim_info.dims[i];
468 }
469 dim_entry << "]\n";
470 dim_entry << "}";
471 break;
472 case 2:
473 dim_entry << "\"dimensionality\": {\n";
474 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\", \""
475 << dim_info.dim_names[1] << "\"],\n";
476 dim_entry << " \"dimensions\": [";
477 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
478 if (i > 0) dim_entry << ", ";
479 dim_entry << dim_info.dims[i];
480 }
481 dim_entry << "]\n";
482 dim_entry << "}";
483 break;
484 case 3:
485 dim_entry << "\"dimensionality\": {\n";
486 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\", \""
487 << dim_info.dim_names[1] << "\", \"" << dim_info.dim_names[2]
488 << "\"],\n";
489 dim_entry << " \"dimensions\": [";
490 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
491 if (i > 0) dim_entry << ", ";
492 dim_entry << dim_info.dims[i];
493 }
494 dim_entry << "]\n";
495 dim_entry << "}";
496 break;
497 default:
498 dim_entry << "\"dimensionality\": {\n";
499 dim_entry << " \"header\": [],\n";
500 dim_entry << " \"dimensions\": []\n";
501 dim_entry << "}";
502 break;
503 }
504
505 // build JSON string
506 ss << "{\n";
507 ss << "\"name\":\"" << (*it).first << "\",\n";
508 ss << dim_entry.str() << ",\n";
509 ss << "\"value\":[";
510 ss << std::fixed << std::setprecision(10);
511 if (dq.size() > 0) {
512 for (size_t i = 0; i < dq.size() - 1; i++) {
513 if (dq[i] != dq[i]) // check for NaN
514 {
515 ss << "-999" << ", ";
516 } else {
517 ss << dq[i] << ", ";
518 }
519 }
520 if (dq[dq.size() - 1] != dq[dq.size() - 1]) // check for NaN
521 {
522 ss << "-999]" << "\n";
523 } else {
524 ss << dq[dq.size() - 1] << "]\n";
525 }
526 } else {
527 ss << "]\n";
528 }
529 ss << "}";
530
531 return ss.str();
532 }
533
539 std::map<std::string, fims::Vector<double>> &dqs,
540 std::map<std::string, fims_popdy::DimensionInfo> &dim_info) {
541 std::stringstream ss;
542 std::map<std::string, fims_popdy::DimensionInfo>::iterator dim_info_it;
543 std::map<std::string, fims::Vector<double>>::iterator it;
544 std::map<std::string, fims::Vector<double>>::iterator end_it;
545 end_it = dqs.end();
546 typename std::map<std::string, fims::Vector<double>>::iterator
548 second_to_last = dqs.end();
549 if (it != end_it) {
551 }
552
553 it = dqs.begin();
554 for (; it != second_to_last; ++it) {
555 dim_info_it = dim_info.find(it->first);
556 ss << this->derived_quantity_to_json(it, dim_info_it->second) << ",\n";
557 }
558
559 dim_info_it = dim_info.find(second_to_last->first);
560 if (dim_info_it != dim_info.end()) {
561 ss << this->derived_quantity_to_json(second_to_last, dim_info_it->second)
562 << "\n";
563 } else {
564 ss << "{}";
565 // Handle case where dimension info is not found
566 }
567 return ss.str();
568 }
569
574 std::stringstream ss;
575
576 if (!fleet_interface) {
578 "Fleet pointer is null; cannot get id. Not found in live objects.");
579 return "{}"; // Return empty JSON
580 }
581
582 std::shared_ptr<fims_info::Information<double>> info =
584
586 model_it = info->models_map.find(this->get_id());
587 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
588 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
589 (*model_it).second);
590
592
593 fit = info->fleets.find(fleet_interface->get_id());
594
595 if (fit != info->fleets.end()) {
596 std::shared_ptr<fims_popdy::Fleet<double>> &fleet = (*fit).second;
597
598 ss << "{\n";
599 ss << " \"module_name\": \"Fleet\",\n";
600 ss << " \"fleet\": \"" << fleet_interface->name << "\",\n";
601 ss << " \"module_id\": " << fleet_interface->id << ",\n";
602 ss << " \"n_ages\": " << fleet_interface->n_ages.get() << ",\n";
603 ss << " \"n_years\": " << fleet_interface->n_years.get() << ",\n";
604 ss << " \"n_lengths\": " << fleet_interface->n_lengths.get() << ",\n";
605 ss << "\"data_ids\" : [\n";
606 ss << "{\"agecomp\": " << fleet_interface->GetObservedAgeCompDataID()
607 << "},\n";
608 ss << "{\"lengthcomp\": "
609 << fleet_interface->GetObservedLengthCompDataID() << "},\n";
610 ss << "{\"index\": " << fleet_interface->GetObservedIndexDataID()
611 << "},\n";
612 ss << "{\"landings\": " << fleet_interface->GetObservedLandingsDataID()
613 << "}\n";
614 ss << "],\n";
615 ss << "\"parameters\": [\n";
616 ss << "{\n";
617 for (size_t i = 0; i < fleet_interface->log_Fmort.size(); i++) {
618 fleet_interface->log_Fmort[i].final_value_m = fleet->log_Fmort[i];
619 }
620
621 ss << " \"name\": \"log_Fmort\",\n";
622 ss << " \"id\":" << fleet_interface->log_Fmort.id_m << ",\n";
623 ss << " \"type\": \"vector\",\n";
624 ss << " \"dimensionality\": {\n";
625 ss << " \"header\": [\"" << "n_years" << "\"],\n";
626 ss << " \"dimensions\": [" << fleet_interface->n_years.get()
627 << "]\n},\n";
628 ss << " \"values\": " << fleet_interface->log_Fmort << "},\n";
629
630 ss << " {\n";
631 for (size_t i = 0; i < fleet->log_q.size(); i++) {
632 fleet_interface->log_q[i].final_value_m = fleet->log_q[i];
633 }
634 ss << " \"name\": \"log_q\",\n";
635 ss << " \"id\":" << fleet_interface->log_q.id_m << ",\n";
636 ss << " \"type\": \"vector\",\n";
637 ss << " \"dimensionality\": {\n";
638 ss << " \"header\": [\"" << "na" << "\"],\n";
639 ss << " \"dimensions\": [" << fleet->log_q.size() << "]\n},\n";
640
641 ss << " \"values\": " << fleet_interface->log_q << "}\n";
642
643 ss << "], \"derived_quantities\": [";
644
645 std::map<std::string, fims::Vector<double>> dqs =
646 model_ptr->GetFleetDerivedQuantities(fleet_interface->get_id());
647 std::map<std::string, fims_popdy::DimensionInfo> dim_info =
648 model_ptr->GetFleetDimensionInfo(fleet_interface->get_id());
649 ss << this->derived_quantities_component_to_json(dqs, dim_info) << "]}\n";
650 } else {
651 ss << "{\n";
652 ss << " \"name\": \"Fleet\",\n";
653 ss << " \"type\": \"fleet\",\n";
654 ss << " \"tag\": \"" << fleet_interface->get_id()
655 << " not found in Information.\",\n";
656 ss << " \"derived_quantities\": []}\n";
657 }
658 return ss.str();
659 }
660
664 virtual std::string to_json() {
665 std::set<uint32_t> recruitment_ids;
666 std::set<uint32_t> growth_ids;
667 std::set<uint32_t> maturity_ids;
668 std::set<uint32_t> selectivity_ids;
669 std::set<uint32_t> fleet_ids;
670 // gather sub-module info from population and fleets
671 typename std::set<uint32_t>::iterator module_id_it; // generic
672 typename std::set<uint32_t>::iterator pit;
673 typename std::set<uint32_t>::iterator fids;
674 for (pit = this->population_ids->begin();
675 pit != this->population_ids->end(); pit++) {
676 std::shared_ptr<PopulationInterface> population_interface =
677 std::dynamic_pointer_cast<PopulationInterface>(
680 recruitment_ids.insert(population_interface->recruitment_id.get());
681 growth_ids.insert(population_interface->growth_id.get());
682 maturity_ids.insert(population_interface->maturity_id.get());
683
684 for (fids = population_interface->fleet_ids->begin();
685 fids != population_interface->fleet_ids->end(); fids++) {
686 fleet_ids.insert(*fids);
687 }
688 }
689 }
690
691 for (fids = fleet_ids.begin(); fids != fleet_ids.end(); fids++) {
692 std::shared_ptr<FleetInterface> fleet_interface =
693 std::dynamic_pointer_cast<FleetInterface>(
695 if (fleet_interface) {
696 selectivity_ids.insert(fleet_interface->GetSelectivityID());
697 }
698 }
699
700 std::shared_ptr<fims_info::Information<double>> info =
702
703 std::shared_ptr<fims_popdy::CatchAtAge<double>> model =
704 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
705 info->models_map[this->get_id()]);
706
707 std::shared_ptr<fims_model::Model<double>> model_internal =
709
710#ifdef TMB_MODEL
711 model->do_reporting = false;
712#endif
713
714 double value = model_internal->Evaluate();
715
716 std::stringstream ss;
717
718 ss.str("");
719
720 ss << "{\n";
721 ss << " \"name\": \"CatchAtAge\",\n";
722 ss << " \"type\": \"model\",\n";
723 ss << " \"estimation_framework\": ";
724#ifdef TMB_MODEL
725 ss << "\"Template_Model_Builder (TMB)\",";
726#else
727 ss << "\"FIMS\",";
728#endif
729 ss << " \"id\": " << this->get_id() << ",\n";
730 ss << " \"objective_function_value\": " << value << ",\n";
731 ss << "\"growth\":[\n";
732 for (module_id_it = growth_ids.begin(); module_id_it != growth_ids.end();
733 module_id_it++) {
734 std::shared_ptr<GrowthInterfaceBase> growth_interface =
736
737 if (growth_interface != NULL) {
738 growth_interface->finalize();
739 ss << growth_interface->to_json();
740 if (std::next(module_id_it) != growth_ids.end()) {
741 ss << ", ";
742 }
743 }
744 }
745
746 ss << "],\n";
747
748 ss << "\"recruitment\": [\n";
749 for (module_id_it = recruitment_ids.begin();
751 std::shared_ptr<RecruitmentInterfaceBase> recruitment_interface =
754 recruitment_interface->finalize();
755 ss << recruitment_interface->to_json();
756 if (std::next(module_id_it) != recruitment_ids.end()) {
757 ss << ", ";
758 }
759 }
760 }
761 ss << "],\n";
762
763 ss << "\"maturity\": [\n";
764 for (module_id_it = maturity_ids.begin();
766 std::shared_ptr<MaturityInterfaceBase> maturity_interface =
768 if (maturity_interface) {
769 maturity_interface->finalize();
770 ss << maturity_interface->to_json();
771 if (std::next(module_id_it) != maturity_ids.end()) {
772 ss << ", ";
773 }
774 }
775 }
776 ss << "],\n";
777
778 ss << "\"selectivity\": [\n";
779 for (module_id_it = selectivity_ids.begin();
781 std::shared_ptr<SelectivityInterfaceBase> selectivity_interface =
784 selectivity_interface->finalize();
785 ss << selectivity_interface->to_json();
786 if (std::next(module_id_it) != selectivity_ids.end()) {
787 ss << ", ";
788 }
789 }
790 }
791 ss << "],\n";
792
793 ss << " \"population_ids\": [";
794 for (pit = this->population_ids->begin();
795 pit != this->population_ids->end(); pit++) {
796 ss << *pit;
797 if (std::next(pit) != this->population_ids->end()) {
798 ss << ", ";
799 }
800 }
801 ss << "],\n";
802 ss << " \"fleet_ids\": [";
803
804 for (fids = fleet_ids.begin(); fids != fleet_ids.end(); fids++) {
805 ss << *fids;
806 if (std::next(fids) != fleet_ids.end()) {
807 ss << ", ";
808 }
809 }
810 ss << "],\n";
811 ss << "\"populations\": [\n";
812 typename std::set<uint32_t>::iterator pop_it;
813 typename std::set<uint32_t>::iterator pop_end_it;
814 pop_end_it = this->population_ids->end();
815 typename std::set<uint32_t>::iterator pop_second_to_last_it;
816 if (pop_end_it != this->population_ids->begin()) {
817 pop_second_to_last_it = std::prev(pop_end_it);
818 } else {
820 }
821 for (pop_it = this->population_ids->begin();
822 pop_it != pop_second_to_last_it; pop_it++) {
823 std::shared_ptr<PopulationInterface> population_interface =
824 std::dynamic_pointer_cast<PopulationInterface>(
827 std::set<uint32_t>::iterator fids;
828 for (fids = population_interface->fleet_ids->begin();
829 fids != population_interface->fleet_ids->end(); fids++) {
830 fleet_ids.insert(*fids);
831 }
832 population_interface->finalize();
833 ss << this->population_to_json(population_interface.get()) << ",";
834 } else {
835 FIMS_ERROR_LOG("Population with id " + fims::to_string(*pop_it) +
836 " not found in live objects.");
837 ss << "{}"; // Return empty JSON for this population
838 }
839 }
840
841 std::shared_ptr<PopulationInterface> population_interface =
842 std::dynamic_pointer_cast<PopulationInterface>(
845 std::set<uint32_t>::iterator fids;
846 for (fids = population_interface->fleet_ids->begin();
847 fids != population_interface->fleet_ids->end(); fids++) {
848 fleet_ids.insert(*fids);
849 }
850 ss << this->population_to_json(population_interface.get());
851 } else {
852 FIMS_ERROR_LOG("Population with id " + fims::to_string(*pop_it) +
853 " not found in live objects.");
854 ss << "{}"; // Return empty JSON for this population
855 }
856
857 ss << "]";
858 ss << ",\n";
859 ss << "\"fleets\": [\n";
860
861 typename std::set<uint32_t>::iterator fleet_it;
862 typename std::set<uint32_t>::iterator fleet_end_it;
863 fleet_end_it = fleet_ids.end();
864 typename std::set<uint32_t>::iterator fleet_second_to_last_it;
865
866 if (fleet_end_it != fleet_ids.begin()) {
868 }
869 for (fleet_it = fleet_ids.begin(); fleet_it != fleet_second_to_last_it;
870 fleet_it++) {
871 std::shared_ptr<FleetInterface> fleet_interface =
872 std::dynamic_pointer_cast<FleetInterface>(
874 if (fleet_interface) {
875 fleet_interface->finalize();
876 ss << this->fleet_to_json(fleet_interface.get()) << ",";
877 } else {
878 FIMS_ERROR_LOG("Fleet with id " + fims::to_string(*fleet_it) +
879 " not found in live objects.");
880 ss << "{}"; // Return empty JSON for this fleet
881 }
882 }
883 std::shared_ptr<FleetInterface> fleet_interface =
884 std::dynamic_pointer_cast<FleetInterface>(
886 if (fleet_interface) {
887 ss << this->fleet_to_json(fleet_interface.get());
888 } else {
889 FIMS_ERROR_LOG("Fleet with id " + fims::to_string(*fleet_it) +
890 " not found in live objects.");
891 ss << "{}"; // Return empty JSON for this fleet
892 }
893
894 ss << "],\n";
895
896 ss << "\"density_components\": [\n";
897
898 typename std::map<
899 uint32_t, std::shared_ptr<DistributionsInterfaceBase>>::iterator dit;
902 std::shared_ptr<DistributionsInterfaceBase> dist_interface =
903 (*dit).second;
904 if (dist_interface) {
905 dist_interface->finalize();
906 ss << dist_interface->to_json();
907 if (std::next(dit) != DistributionsInterfaceBase::live_objects.end()) {
908 ss << ",\n";
909 }
910 }
911 }
912 ss << "\n],\n";
913 ss << "\"data\": [\n";
914 typename std::map<uint32_t, std::shared_ptr<DataInterfaceBase>>::iterator
915 d_it;
918 std::shared_ptr<DataInterfaceBase> data_interface = (*d_it).second;
919 if (data_interface) {
920 data_interface->finalize();
921 ss << data_interface->to_json();
922 if (std::next(d_it) != DataInterfaceBase::live_objects.end()) {
923 ss << ",\n";
924 }
925 }
926 }
927 ss << "\n]\n";
928 ss << "}\n";
929#ifdef TMB_MODEL
930 model->do_reporting = true;
931#endif
933 }
934
935#ifdef TMB_MODEL
936
937 template <typename Type>
939 std::shared_ptr<fims_info::Information<Type>> info =
941
942 std::shared_ptr<fims_popdy::CatchAtAge<Type>> model =
943 std::make_shared<fims_popdy::CatchAtAge<Type>>();
944
946
947 for (it = this->population_ids->begin(); it != this->population_ids->end();
948 ++it) {
949 model->AddPopulation((*it));
950 }
951
952 std::set<uint32_t> fleet_ids; // all fleets in the model
953 typedef typename std::set<uint32_t>::iterator fleet_ids_iterator;
954
955 // add to Information
956 info->models_map[this->get_id()] = model;
957
958 for (it = this->population_ids->begin(); it != this->population_ids->end();
959 ++it) {
962 throw std::runtime_error("Population ID " + std::to_string(*it) +
963 " not found in live_objects");
964 }
965 auto population =
966 std::dynamic_pointer_cast<PopulationInterface>(it2->second);
967 model->InitializePopulationDerivedQuantities(population->id);
968 std::map<std::string, fims::Vector<Type>> &derived_quantities =
969 model->GetPopulationDerivedQuantities(population->id);
970
971 std::map<std::string, fims_popdy::DimensionInfo>
973 model->GetPopulationDimensionInfo(population->id);
974
975 std::stringstream ss;
976
977 derived_quantities["total_landings_weight"] =
978 fims::Vector<Type>(population->n_years.get());
979
980 derived_quantities_dim_info["total_landings_weight"] =
982 "total_landings_weight",
983 fims::Vector<int>{(int)population->n_years.get()},
984 fims::Vector<std::string>{"n_years"});
985
986 derived_quantities["total_landings_numbers"] =
987 fims::Vector<Type>(population->n_years.get());
988
989 derived_quantities_dim_info["total_landings_numbers"] =
991 "total_landings_numbers",
992 fims::Vector<int>{population->n_years.get()},
993 fims::Vector<std::string>{"n_years"});
994
995 derived_quantities["mortality_F"] = fims::Vector<Type>(
996 population->n_years.get() * population->n_ages.get());
998 "mortality_F",
999 fims::Vector<int>{population->n_years.get(),
1000 population->n_ages.get()},
1001 fims::Vector<std::string>{"n_years", "n_ages"});
1002
1003 derived_quantities["mortality_M"] = fims::Vector<Type>(
1004 population->n_years.get() * population->n_ages.get());
1006 "mortality_M",
1007 fims::Vector<int>{population->n_years.get(),
1008 population->n_ages.get()},
1009 fims::Vector<std::string>{"n_years", "n_ages"});
1010
1011 derived_quantities["mortality_Z"] = fims::Vector<Type>(
1012 population->n_years.get() * population->n_ages.get());
1014 "mortality_Z",
1015 fims::Vector<int>{population->n_years.get(),
1016 population->n_ages.get()},
1017 fims::Vector<std::string>{"n_years", "n_ages"});
1018
1019 derived_quantities["numbers_at_age"] = fims::Vector<Type>(
1020 (population->n_years.get() + 1) * population->n_ages.get());
1022 "numbers_at_age",
1023 fims::Vector<int>{(population->n_years.get() + 1),
1024 population->n_ages.get()},
1025 fims::Vector<std::string>{"n_years+1", "n_ages"});
1026
1027 derived_quantities["unfished_numbers_at_age"] = fims::Vector<Type>(
1028 (population->n_years.get() + 1) * population->n_ages.get());
1029 derived_quantities_dim_info["unfished_numbers_at_age"] =
1031 "unfished_numbers_at_age",
1032 fims::Vector<int>{(population->n_years.get() + 1),
1033 population->n_ages.get()},
1034 fims::Vector<std::string>{"n_years+1", "n_ages"});
1035
1036 derived_quantities["biomass"] =
1037 fims::Vector<Type>((population->n_years.get() + 1));
1039 "biomass", fims::Vector<int>{(population->n_years.get() + 1)},
1040 fims::Vector<std::string>{"n_years+1"});
1041
1042 derived_quantities["spawning_biomass"] =
1043 fims::Vector<Type>((population->n_years.get() + 1));
1044 derived_quantities_dim_info["spawning_biomass"] =
1046 "spawning_biomass",
1047 fims::Vector<int>{(population->n_years.get() + 1)},
1048 fims::Vector<std::string>{"n_years+1"});
1049
1050 derived_quantities["unfished_biomass"] =
1051 fims::Vector<Type>((population->n_years.get() + 1));
1052 derived_quantities_dim_info["unfished_biomass"] =
1054 "unfished_biomass",
1055 fims::Vector<int>{(population->n_years.get() + 1)},
1056 fims::Vector<std::string>{"n_years+1"});
1057
1058 derived_quantities["unfished_spawning_biomass"] =
1059 fims::Vector<Type>((population->n_years.get() + 1));
1060 derived_quantities_dim_info["unfished_spawning_biomass"] =
1062 "unfished_spawning_biomass",
1063 fims::Vector<int>{(population->n_years.get() + 1)},
1064 fims::Vector<std::string>{"n_years+1"});
1065
1066 derived_quantities["proportion_mature_at_age"] = fims::Vector<Type>(
1067 (population->n_years.get() + 1) * population->n_ages.get());
1068 derived_quantities_dim_info["proportion_mature_at_age"] =
1070 "proportion_mature_at_age",
1071 fims::Vector<int>{(population->n_years.get() + 1),
1072 population->n_ages.get()},
1073 fims::Vector<std::string>{"n_years+1", "n_ages"});
1074
1075 derived_quantities["expected_recruitment"] =
1076 fims::Vector<Type>((population->n_years.get() + 1));
1077 derived_quantities_dim_info["expected_recruitment"] =
1079 "expected_recruitment",
1080 fims::Vector<int>{(population->n_years.get() + 1)},
1081 fims::Vector<std::string>{"n_years+1"});
1082
1083 derived_quantities["sum_selectivity"] = fims::Vector<Type>(
1084 population->n_years.get() * population->n_ages.get());
1085 derived_quantities_dim_info["sum_selectivity"] =
1087 "sum_selectivity",
1088 fims::Vector<int>{population->n_years.get(),
1089 population->n_ages.get()},
1090 fims::Vector<std::string>{"n_years", "n_ages"});
1091
1092 // replace elements in the variable map
1093
1094 for (fleet_ids_iterator fit = population->fleet_ids->begin();
1095 fit != population->fleet_ids->end(); ++fit) {
1096 fleet_ids.insert(*fit);
1097 }
1098 }
1099
1100 for (fleet_ids_iterator it = fleet_ids.begin(); it != fleet_ids.end();
1101 ++it) {
1102 std::shared_ptr<FleetInterface> fleet_interface =
1103 std::dynamic_pointer_cast<FleetInterface>(
1105 model->InitializeFleetDerivedQuantities(fleet_interface->id);
1106 std::map<std::string, fims::Vector<Type>> &derived_quantities =
1107 model->GetFleetDerivedQuantities(fleet_interface->id);
1108
1109 std::map<std::string, fims_popdy::DimensionInfo>
1111 model->GetFleetDimensionInfo(fleet_interface->id);
1112
1113 // initialize derive quantities
1114 // landings
1115 derived_quantities["landings_numbers_at_age"] = fims::Vector<Type>(
1116 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1117 derived_quantities_dim_info["landings_numbers_at_age"] =
1119 "landings_numbers_at_age",
1120 fims::Vector<int>{(fleet_interface->n_years.get()),
1121 fleet_interface->n_ages.get()},
1122 fims::Vector<std::string>{"n_years", "n_ages"});
1123
1124 derived_quantities["landings_weight_at_age"] = fims::Vector<Type>(
1125 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1126 derived_quantities_dim_info["landings_weight_at_age"] =
1128 "landings_weight_at_age",
1129 fims::Vector<int>{(fleet_interface->n_years.get()),
1130 fleet_interface->n_ages.get()},
1131 fims::Vector<std::string>{"n_years", "n_ages"});
1132
1133 derived_quantities["landings_numbers_at_length"] = fims::Vector<Type>(
1134 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1135 derived_quantities_dim_info["landings_numbers_at_length"] =
1137 "landings_numbers_at_length",
1138 fims::Vector<int>{(fleet_interface->n_years.get()),
1139 fleet_interface->n_lengths.get()},
1140 fims::Vector<std::string>{"n_years", "n_lengths"});
1141
1142 derived_quantities["landings_weight"] =
1143 fims::Vector<Type>(fleet_interface->n_years.get());
1144 derived_quantities_dim_info["landings_weight"] =
1146 "landings_weight",
1147 fims::Vector<int>{(fleet_interface->n_years.get())},
1148 fims::Vector<std::string>{"n_years"});
1149
1150 derived_quantities["landings_numbers"] =
1151 fims::Vector<Type>(fleet_interface->n_years.get());
1152 derived_quantities_dim_info["landings_numbers"] =
1154 "landings_numbers",
1155 fims::Vector<int>{(fleet_interface->n_years.get())},
1156 fims::Vector<std::string>{"n_years"});
1157
1158 derived_quantities["landings_expected"] =
1159 fims::Vector<Type>(fleet_interface->n_years.get());
1160 derived_quantities_dim_info["landings_expected"] =
1162 "landings_expected",
1163 fims::Vector<int>{(fleet_interface->n_years.get())},
1164 fims::Vector<std::string>{"n_years"});
1165
1166 derived_quantities["log_landings_expected"] =
1167 fims::Vector<Type>(fleet_interface->n_years.get());
1168 derived_quantities_dim_info["log_landings_expected"] =
1170 "log_landings_expected",
1171 fims::Vector<int>{(fleet_interface->n_years.get())},
1172 fims::Vector<std::string>{"n_years"});
1173
1174 derived_quantities["agecomp_proportion"] = fims::Vector<Type>(
1175 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1176 derived_quantities_dim_info["agecomp_proportion"] =
1178 "agecomp_proportion",
1179 fims::Vector<int>{(fleet_interface->n_years.get()),
1180 fleet_interface->n_ages.get()},
1181 fims::Vector<std::string>{"n_years", "n_ages"});
1182
1183 derived_quantities["lengthcomp_proportion"] = fims::Vector<Type>(
1184 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1185 derived_quantities_dim_info["lengthcomp_proportion"] =
1187 "lengthcomp_proportion",
1188 fims::Vector<int>{(fleet_interface->n_years.get()),
1189 fleet_interface->n_lengths.get()},
1190 fims::Vector<std::string>{"n_years", "n_lengths"});
1191
1192 // index
1193 derived_quantities["index_numbers_at_age"] = fims::Vector<Type>(
1194 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1195 derived_quantities_dim_info["index_numbers_at_age"] =
1197 "index_numbers_at_age",
1198 fims::Vector<int>{(fleet_interface->n_years.get()),
1199 fleet_interface->n_ages.get()},
1200 fims::Vector<std::string>{"n_years", "n_ages"});
1201
1202 derived_quantities["index_weight_at_age"] = fims::Vector<Type>(
1203 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1204 derived_quantities_dim_info["index_weight_at_age"] =
1206 "index_weight_at_age",
1207 fims::Vector<int>{(fleet_interface->n_years.get()),
1208 fleet_interface->n_ages.get()},
1209 fims::Vector<std::string>{"n_years", "n_ages"});
1210
1211 derived_quantities["index_weight_at_age"] = fims::Vector<Type>(
1212 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1213 derived_quantities_dim_info["index_weight_at_age"] =
1215 "index_weight_at_age",
1216 fims::Vector<int>{(fleet_interface->n_years.get()),
1217 fleet_interface->n_ages.get()},
1218 fims::Vector<std::string>{"n_years", "n_ages"});
1219
1220 derived_quantities["index_numbers_at_length"] = fims::Vector<Type>(
1221 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1222 derived_quantities_dim_info["index_numbers_at_length"] =
1224 "index_numbers_at_length",
1225 fims::Vector<int>{(fleet_interface->n_years.get()),
1226 fleet_interface->n_lengths.get()},
1227 fims::Vector<std::string>{"n_years", "n_lengths"});
1228 derived_quantities["index_weight"] =
1229 fims::Vector<Type>(fleet_interface->n_years.get());
1231 "index_weight", fims::Vector<int>{(fleet_interface->n_years.get())},
1232 fims::Vector<std::string>{"n_years"});
1233
1234 derived_quantities["index_numbers"] =
1235 fims::Vector<Type>(fleet_interface->n_years.get());
1237 "index_numbers", fims::Vector<int>{(fleet_interface->n_years.get())},
1238 fims::Vector<std::string>{"n_years"});
1239
1240 derived_quantities["index_expected"] =
1241 fims::Vector<Type>(fleet_interface->n_years.get());
1243 "index_expected", fims::Vector<int>{(fleet_interface->n_years.get())},
1244 fims::Vector<std::string>{"n_years"});
1245
1246 derived_quantities["log_index_expected"] =
1247 fims::Vector<Type>(fleet_interface->n_years.get());
1248 derived_quantities_dim_info["log_index_expected"] =
1250 "log_index_expected",
1251 fims::Vector<int>{(fleet_interface->n_years.get())},
1252 fims::Vector<std::string>{"n_years"});
1253
1254 derived_quantities["catch_index"] =
1255 fims::Vector<Type>(fleet_interface->n_years.get());
1257 "catch_index", fims::Vector<int>{(fleet_interface->n_years.get())},
1258 fims::Vector<std::string>{"n_years"});
1259
1260 derived_quantities["agecomp_expected"] = fims::Vector<Type>(
1261 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1262 derived_quantities_dim_info["agecomp_expected"] =
1264 "agecomp_expected",
1265 fims::Vector<int>{(fleet_interface->n_years.get()),
1266 (fleet_interface->n_ages.get())},
1267 fims::Vector<std::string>{"n_years", "n_ages"});
1268
1269 derived_quantities["lengthcomp_expected"] = fims::Vector<Type>(
1270 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1271 derived_quantities_dim_info["lengthcomp_expected"] =
1273 "lengthcomp_expected",
1274 fims::Vector<int>{(fleet_interface->n_years.get()),
1275 (fleet_interface->n_lengths.get())},
1276 fims::Vector<std::string>{"n_years", "n_lengths"});
1277
1278 // replace elements in the variable map
1279 info->variable_map[fleet_interface->log_landings_expected.id_m] =
1280 &(derived_quantities["log_landings_expected"]);
1281 info->variable_map[fleet_interface->log_index_expected.id_m] =
1282 &(derived_quantities["log_index_expected"]);
1283 info->variable_map[fleet_interface->agecomp_expected.id_m] =
1284 &(derived_quantities["agecomp_expected"]);
1285 info->variable_map[fleet_interface->agecomp_proportion.id_m] =
1286 &(derived_quantities["agecomp_proportion"]);
1287 info->variable_map[fleet_interface->lengthcomp_expected.id_m] =
1288 &(derived_quantities["lengthcomp_expected"]);
1289 info->variable_map[fleet_interface->lengthcomp_proportion.id_m] =
1290 &(derived_quantities["lengthcomp_proportion"]);
1291 }
1292
1293 return true;
1294 }
1295
1296 virtual bool add_to_fims_tmb() {
1299 return true;
1300 }
1301
1302#endif
1303};
1304
1305#endif
The CatchAtAgeInterface class is used to interface with the CatchAtAge model. It inherits from the Fi...
Definition rcpp_models.hpp:218
virtual std::string to_json()
Serialize the fishery model to a JSON string.
Definition rcpp_models.hpp:664
void AddPopulation(uint32_t id)
Definition rcpp_models.hpp:241
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:453
virtual void finalize()
Extracts derived quantities back to the Rcpp interface object from the Information object.
Definition rcpp_models.hpp:310
CatchAtAgeInterface()
The constructor.
Definition rcpp_models.hpp:223
void DoReporting(bool report)
Enable or disable reporting for the CatchAtAge model.
Definition rcpp_models.hpp:262
virtual uint32_t get_id()
Method to get this id.
Definition rcpp_models.hpp:305
std::string fleet_to_json(FleetInterface *fleet_interface)
Method to convert a fleet to a JSON string.
Definition rcpp_models.hpp:573
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:538
std::string population_to_json(PopulationInterface *population_interface)
Method to convert a population to a JSON string.
Definition rcpp_models.hpp:315
CatchAtAgeInterface(const CatchAtAgeInterface &other)
Construct a new Catch At Age Interface object.
Definition rcpp_models.hpp:235
bool IsReporting()
Check if reporting is enabled for the CatchAtAge model.
Definition rcpp_models.hpp:284
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:575
static std::vector< std::shared_ptr< FIMSRcppInterfaceBase > > fims_interface_objects
FIMS interface object vectors.
Definition rcpp_interface_base.hpp:585
virtual bool add_to_fims_tmb()
A virtual method to inherit to add objects to the TMB model.
Definition rcpp_interface_base.hpp:590
The FisheryModelInterfaceBase class is the base class for all fishery models in the FIMS Rcpp interfa...
Definition rcpp_models.hpp:32
double min(const std::valarray< double > &v)
Minimum method to calculate the minimum of an array or vector of doubles.
Definition rcpp_models.hpp:181
FisheryModelInterfaceBase(const FisheryModelInterfaceBase &other)
Construct a new Data Interface Base object.
Definition rcpp_models.hpp:76
static uint32_t id_g
The static id of the FleetInterfaceBase object.
Definition rcpp_models.hpp:47
virtual uint32_t get_id()=0
Get the ID for the child fleet interface objects to inherit.
FisheryModelInterfaceBase()
The constructor.
Definition rcpp_models.hpp:63
std::set< uint32_t >::iterator population_id_iterator
Iterator for population ids.
Definition rcpp_models.hpp:41
uint32_t id
The local id of the FleetInterfaceBase object.
Definition rcpp_models.hpp:51
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:199
virtual std::string to_json()
Serialize the fishery model to a JSON string.
Definition rcpp_models.hpp:97
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:58
double sum(const std::valarray< double > &v)
Sum method to calculate the sum of an array or vector of doubles.
Definition rcpp_models.hpp:152
Rcpp::NumericVector get_random_parameters_vector()
Get the vector of random effect parameters for the model.
Definition rcpp_models.hpp:133
Rcpp::NumericVector get_fixed_parameters_vector()
Get the vector of fixed effect parameters for the model.
Definition rcpp_models.hpp:113
std::shared_ptr< std::set< uint32_t > > population_ids
The set of population ids that this fishery model operates on.
Definition rcpp_models.hpp:37
virtual ~FisheryModelInterfaceBase()
The destructor.
Definition rcpp_models.hpp:82
double sum(const std::vector< double > &v)
Sum method for a vector of doubles.
Definition rcpp_models.hpp:166
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:35
The Rcpp interface for Fleet to instantiate from R: fleet <- methods::new(Fleet)
Definition rcpp_fleet.hpp:74
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:86
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:136
std::map< uint32_t, std::shared_ptr< fims_popdy::Fleet< Type > > >::iterator fleet_iterator
Definition information.hpp:110
std::map< uint32_t, std::shared_ptr< fims_popdy::Population< Type > > >::iterator population_iterator
Definition information.hpp:120
std::unordered_map< uint32_t, std::shared_ptr< fims_popdy::FisheryModelBase< Type > > >::iterator model_map_iterator
Definition information.hpp:140
static std::shared_ptr< Information< Type > > GetInstance()
Returns a singleton Information object for type T.
Definition information.hpp:238
static std::shared_ptr< Model< Type > > GetInstance()
Evaluate. Calculates the joint negative log-likelihood function.
Definition model.hpp:54
#define FIMS_ERROR_LOG(MESSAGE)
Definition def.hpp:655
The Rcpp interface to declare fleets. Allows for the use of methods::new() in R.
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,...
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