FIMS  v0.8.1
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"
14#include "../../../models/fisheries_models.hpp"
15#include "../../../utilities/fims_json.hpp"
16
18#include "rcpp_population.hpp"
19#include "rcpp_fleet.hpp"
20#include "rcpp_maturity.hpp"
21#include "rcpp_recruitment.hpp"
22#include "rcpp_selectivity.hpp"
23#include <valarray>
24#include <cmath>
25#include <mutex>
26
34 public:
38 static uint32_t id_g;
48 static std::map<uint32_t, std::shared_ptr<FisheryModelInterfaceBase>>
50
56 /* Create instance of map: key is id and value is pointer to
57 FleetInterfaceBase */
58 // FisheryModelInterfaceBase::live_objects[this->id] = this;
59 }
60
68
73
87 virtual std::string to_json() {
88 return "std::string to_json() not yet implemented.";
89 }
90
94 virtual uint32_t get_id() = 0;
95};
96// static id of the FleetInterfaceBase object
98
99// FleetInterfaceBase to the FleetInterfaceBase objects
100std::map<uint32_t, std::shared_ptr<FisheryModelInterfaceBase>>
102
111 std::shared_ptr<std::set<uint32_t>> population_ids;
115 typedef typename std::set<uint32_t>::iterator population_id_iterator;
116
122 std::map<std::string, std::vector<double>> se_values;
123
124 public:
129 this->population_ids = std::make_shared<std::set<uint32_t>>();
130 std::shared_ptr<CatchAtAgeInterface> caa =
131 std::make_shared<CatchAtAgeInterface>(*this);
134 }
135
143 population_ids(other.population_ids) {}
144
149 this->population_ids->insert(id);
150
151 std::map<uint32_t, std::shared_ptr<PopulationInterfaceBase>>::iterator pit;
154 std::shared_ptr<PopulationInterfaceBase> &pop = (*pit).second;
155 pop->initialize_catch_at_age.set(true);
156 } else {
157 FIMS_ERROR_LOG("Population with id " + fims::to_string(id) +
158 " not found.");
159 }
160 }
161
169 void DoReporting(bool report) {
170#ifdef TMB_MODEL
171 std::shared_ptr<fims_info::Information<double>> info =
174 model_it = info->models_map.find(this->get_id());
175 if (model_it != info->models_map.end()) {
176 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
177 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
178 (*model_it).second);
179 model_ptr->do_reporting = report;
180 }
181#endif
182 }
183
191 bool IsReporting() {
192#ifdef TMB_MODEL
193 std::shared_ptr<fims_info::Information<double>> info =
196 model_it = info->models_map.find(this->get_id());
197 if (model_it != info->models_map.end()) {
198 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
199 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
200 (*model_it).second);
201 return model_ptr->do_reporting;
202 }
203 return false;
204#else
205 return false;
206#endif
207 }
208
212 virtual uint32_t get_id() { return this->id; }
213
217 virtual void finalize() {}
218
223 std::stringstream ss;
224
225 typename std::map<uint32_t,
226 std::shared_ptr<PopulationInterfaceBase>>::iterator
227 pi_it; // population interface iterator
229 population_interface->get_id());
231 FIMS_ERROR_LOG("Population with id " +
232 fims::to_string(population_interface->get_id()) +
233 " not found in live objects.");
234 return "{}"; // Return empty JSON
235 }
236
237 std::shared_ptr<PopulationInterface> population_interface_ptr =
238 std::dynamic_pointer_cast<PopulationInterface>((*pi_it).second);
239
240 std::shared_ptr<fims_info::Information<double>> info =
242
244 model_it = info->models_map.find(this->get_id());
245 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
246 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
247 (*model_it).second);
248
250
251 pit = info->populations.find(population_interface->get_id());
252
253 if (pit != info->populations.end()) {
254 std::shared_ptr<fims_popdy::Population<double>> &pop = (*pit).second;
255 ss << "{\n";
256
257 ss << " \"module_name\": \"Population\",\n";
258 ss << " \"population\": \"" << population_interface->name << "\",\n";
259 ss << " \"module_id\": " << population_interface->id << ",\n";
260 ss << " \"recruitment_id\": " << population_interface->recruitment_id
261 << ",\n";
262 ss << " \"growth_id\": " << population_interface->growth_id << ",\n";
263 ss << " \"maturity_id\": " << population_interface->maturity_id << ",\n";
264
265 ss << " \"parameters\": [\n";
266 for (size_t i = 0; i < pop->log_M.size(); i++) {
267 population_interface_ptr->log_M[i].final_value_m = pop->log_M[i];
268 }
269
270 ss << "{\n \"name\": \"log_M\",\n";
271 ss << " \"id\":" << population_interface->log_M.id_m << ",\n";
272 ss << " \"type\": \"vector\",\n";
273 ss << " \"dimensionality\": {\n";
274 ss << " \"header\": [" << "\"n_years\", \"n_ages\"" << "],\n";
275 ss << " \"dimensions\": [" << population_interface->n_years.get() << ", "
276 << population_interface->n_ages.get() << "]\n},\n";
277 ss << " \"values\": " << population_interface->log_M << "\n\n";
278 ss << "},\n";
279
280 for (size_t i = 0; i < pop->log_f_multiplier.size(); i++) {
281 population_interface_ptr->log_f_multiplier[i].final_value_m =
282 pop->log_f_multiplier[i];
283 }
284
285 ss << "{\n \"name\": \"log_f_multiplier\",\n";
286 ss << " \"id\":" << population_interface->log_f_multiplier.id_m << ",\n";
287 ss << " \"type\": \"vector\",\n";
288 ss << " \"dimensionality\": {\n";
289 ss << " \"header\": [" << "\"n_years\"" << "],\n";
290 ss << " \"dimensions\": [" << population_interface->n_years.get()
291 << "]\n},\n";
292 ss << " \"values\": " << population_interface->log_f_multiplier << "\n\n";
293 ss << "},\n";
294
295 for (size_t i = 0; i < pop->spawning_biomass_ratio.size(); i++) {
296 population_interface_ptr->spawning_biomass_ratio[i].final_value_m =
297 pop->spawning_biomass_ratio[i];
298 }
299
300 ss << "{\n \"name\": \"spawning_biomass_ratio\",\n";
301 ss << " \"id\":" << population_interface->spawning_biomass_ratio.id_m
302 << ",\n";
303 ss << " \"type\": \"vector\",\n";
304 ss << " \"dimensionality\": {\n";
305 ss << " \"header\": [" << "\"n_years\"" << "],\n";
306 ss << " \"dimensions\": [" << (population_interface->n_years.get() + 1)
307 << "]\n},\n";
308 ss << " \"values\": " << population_interface->spawning_biomass_ratio
309 << "\n\n";
310 ss << "},\n";
311
312 for (size_t i = 0; i < pop->log_init_naa.size(); i++) {
313 population_interface_ptr->log_init_naa[i].final_value_m =
314 pop->log_init_naa[i];
315 }
316 ss << " {\n\"name\": \"log_init_naa\",\n";
317 ss << " \"id\":" << population_interface->log_init_naa.id_m << ",\n";
318 ss << " \"type\": \"vector\",\n";
319 ss << " \"dimensionality\": {\n";
320 ss << " \"header\": [" << "\"n_ages\"" << "],\n";
321 ss << " \"dimensions\": [" << population_interface->n_ages.get()
322 << "]\n},\n";
323
324 ss << " \"values\":" << population_interface->log_init_naa << "\n";
325 ss << "}],\n";
326
327 ss << " \"derived_quantities\": [\n";
328
329 std::map<std::string, fims::Vector<double>> dqs =
330 model_ptr->GetPopulationDerivedQuantities(
331 population_interface->get_id());
332
333 std::map<std::string, fims_popdy::DimensionInfo> dim_info =
334 model_ptr->GetPopulationDimensionInfo(population_interface->get_id());
336 << " ]}\n";
337 } else {
338 ss << "{\n";
339 ss << " \"name\": \"Population\",\n";
340
341 ss << " \"type\": \"population\",\n";
342 ss << " \"tag\": \"" << population_interface->get_id()
343 << " not found in Information.\",\n";
344 ss << " \"id\": " << population_interface->get_id() << ",\n";
345 ss << " \"recruitment_id\": " << population_interface->recruitment_id
346 << ",\n";
347 ss << " \"growth_id\": " << population_interface->growth_id << ",\n";
348 ss << " \"maturity_id\": " << population_interface->maturity_id << ",\n";
349 ss << " \"derived_quantities\": []}\n";
350 }
351
352 return ss.str();
353 }
354
361 std::map<std::string, fims::Vector<double>>::iterator it,
363 std::stringstream ss;
364 fims::Vector<double> &dq = (*it).second;
365 std::stringstream dim_entry;
366 // gather dimension information
367 switch (dim_info.ndims) {
368 case 1:
369 dim_entry << "\"dimensionality\": {\n";
370 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\"],\n";
371 dim_entry << " \"dimensions\": [";
372 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
373 if (i > 0) dim_entry << ", ";
374 dim_entry << dim_info.dims[i];
375 }
376 dim_entry << "]\n";
377 dim_entry << "}";
378 break;
379 case 2:
380 dim_entry << "\"dimensionality\": {\n";
381 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\", \""
382 << dim_info.dim_names[1] << "\"],\n";
383 dim_entry << " \"dimensions\": [";
384 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
385 if (i > 0) dim_entry << ", ";
386 dim_entry << dim_info.dims[i];
387 }
388 dim_entry << "]\n";
389 dim_entry << "}";
390 break;
391 case 3:
392 dim_entry << "\"dimensionality\": {\n";
393 dim_entry << " \"header\": [\"" << dim_info.dim_names[0] << "\", \""
394 << dim_info.dim_names[1] << "\", \"" << dim_info.dim_names[2]
395 << "\"],\n";
396 dim_entry << " \"dimensions\": [";
397 for (size_t i = 0; i < dim_info.dims.size(); ++i) {
398 if (i > 0) dim_entry << ", ";
399 dim_entry << dim_info.dims[i];
400 }
401 dim_entry << "]\n";
402 dim_entry << "}";
403 break;
404 default:
405 dim_entry << "\"dimensionality\": {\n";
406 dim_entry << " \"header\": [],\n";
407 dim_entry << " \"dimensions\": []\n";
408 dim_entry << "}";
409 break;
410 }
411
412 // build JSON string
413 ss << "{\n";
414 ss << "\"name\":\"" << (*it).first << "\",\n";
415 ss << dim_entry.str() << ",\n";
416 ss << "\"value\":[";
417 ss << std::fixed << std::setprecision(10);
418 if (dq.size() > 0) {
419 for (size_t i = 0; i < dq.size() - 1; i++) {
420 if (dq[i] != dq[i]) // check for NaN
421 {
422 ss << "-999" << ", ";
423 } else {
424 ss << dq[i] << ", ";
425 }
426 }
427 if (dq[dq.size() - 1] != dq[dq.size() - 1]) // check for NaN
428 {
429 ss << "-999]" << "\n";
430 } else {
431 ss << dq[dq.size() - 1] << "]\n";
432 }
433 } else {
434 ss << "]\n";
435 }
436 ss << "}";
437
438 return ss.str();
439 }
440
446 std::map<std::string, fims::Vector<double>> &dqs,
447 std::map<std::string, fims_popdy::DimensionInfo> &dim_info) {
448 std::stringstream ss;
449 std::map<std::string, fims_popdy::DimensionInfo>::iterator dim_info_it;
450 std::map<std::string, fims::Vector<double>>::iterator it;
451 std::map<std::string, fims::Vector<double>>::iterator end_it;
452 end_it = dqs.end();
453 typename std::map<std::string, fims::Vector<double>>::iterator
455 second_to_last = dqs.end();
456 if (it != end_it) {
458 }
459
460 it = dqs.begin();
461 for (; it != second_to_last; ++it) {
462 dim_info_it = dim_info.find(it->first);
463 ss << this->derived_quantity_to_json(it, dim_info_it->second) << ",\n";
464 }
465
466 dim_info_it = dim_info.find(second_to_last->first);
467 if (dim_info_it != dim_info.end()) {
468 ss << this->derived_quantity_to_json(second_to_last, dim_info_it->second)
469 << "\n";
470 } else {
471 ss << "{}";
472 // Handle case where dimension info is not found
473 }
474 return ss.str();
475 }
476
481 std::stringstream ss;
482
483 if (!fleet_interface) {
485 "Fleet pointer is null; cannot get id. Not found in live objects.");
486 return "{}"; // Return empty JSON
487 }
488
489 std::shared_ptr<fims_info::Information<double>> info =
491
493 model_it = info->models_map.find(this->get_id());
494 std::shared_ptr<fims_popdy::CatchAtAge<double>> model_ptr =
495 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
496 (*model_it).second);
497
499
500 fit = info->fleets.find(fleet_interface->get_id());
501
502 if (fit != info->fleets.end()) {
503 std::shared_ptr<fims_popdy::Fleet<double>> &fleet = (*fit).second;
504
505 ss << "{\n";
506 ss << " \"module_name\": \"Fleet\",\n";
507 ss << " \"fleet\": \"" << fleet_interface->name << "\",\n";
508 ss << " \"module_id\": " << fleet_interface->id << ",\n";
509 ss << " \"n_ages\": " << fleet_interface->n_ages.get() << ",\n";
510 ss << " \"n_years\": " << fleet_interface->n_years.get() << ",\n";
511 ss << " \"n_lengths\": " << fleet_interface->n_lengths.get() << ",\n";
512 ss << "\"data_ids\" : [\n";
513 ss << "{\"agecomp\": " << fleet_interface->GetObservedAgeCompDataID()
514 << "},\n";
515 ss << "{\"lengthcomp\": "
516 << fleet_interface->GetObservedLengthCompDataID() << "},\n";
517 ss << "{\"index\": " << fleet_interface->GetObservedIndexDataID()
518 << "},\n";
519 ss << "{\"landings\": " << fleet_interface->GetObservedLandingsDataID()
520 << "}\n";
521 ss << "],\n";
522 ss << "\"parameters\": [\n";
523 ss << "{\n";
524 for (size_t i = 0; i < fleet_interface->log_Fmort.size(); i++) {
525 fleet_interface->log_Fmort[i].final_value_m = fleet->log_Fmort[i];
526 }
527
528 ss << " \"name\": \"log_Fmort\",\n";
529 ss << " \"id\":" << fleet_interface->log_Fmort.id_m << ",\n";
530 ss << " \"type\": \"vector\",\n";
531 ss << " \"dimensionality\": {\n";
532 ss << " \"header\": [\"" << "n_years" << "\"],\n";
533 ss << " \"dimensions\": [" << fleet_interface->n_years.get()
534 << "]\n},\n";
535 ss << " \"values\": " << fleet_interface->log_Fmort << "},\n";
536
537 ss << " {\n";
538 for (size_t i = 0; i < fleet->log_q.size(); i++) {
539 fleet_interface->log_q[i].final_value_m = fleet->log_q[i];
540 }
541 ss << " \"name\": \"log_q\",\n";
542 ss << " \"id\":" << fleet_interface->log_q.id_m << ",\n";
543 ss << " \"type\": \"vector\",\n";
544 ss << " \"dimensionality\": {\n";
545 ss << " \"header\": [\"" << "na" << "\"],\n";
546 ss << " \"dimensions\": [" << fleet->log_q.size() << "]\n},\n";
547
548 ss << " \"values\": " << fleet_interface->log_q << "}\n";
549
550 ss << "], \"derived_quantities\": [";
551
552 std::map<std::string, fims::Vector<double>> dqs =
553 model_ptr->GetFleetDerivedQuantities(fleet_interface->get_id());
554 std::map<std::string, fims_popdy::DimensionInfo> dim_info =
555 model_ptr->GetFleetDimensionInfo(fleet_interface->get_id());
556 ss << this->derived_quantities_component_to_json(dqs, dim_info) << "]}\n";
557 } else {
558 ss << "{\n";
559 ss << " \"name\": \"Fleet\",\n";
560 ss << " \"type\": \"fleet\",\n";
561 ss << " \"tag\": \"" << fleet_interface->get_id()
562 << " not found in Information.\",\n";
563 ss << " \"derived_quantities\": []}\n";
564 }
565 return ss.str();
566 }
567
575 Rcpp::NumericVector get_fixed_parameters_vector() {
576 // base model
577 std::shared_ptr<fims_info::Information<double>> info0 =
579
580 Rcpp::NumericVector p;
581
582 for (size_t i = 0; i < info0->fixed_effects_parameters.size(); i++) {
583 p.push_back(*info0->fixed_effects_parameters[i]);
584 }
585
586 return p;
587 }
588
596 Rcpp::NumericVector get_random_parameters_vector() {
597 // base model
598 std::shared_ptr<fims_info::Information<double>> d0 =
600
601 Rcpp::NumericVector p;
602
603 for (size_t i = 0; i < d0->random_effects_parameters.size(); i++) {
604 p.push_back(*d0->random_effects_parameters[i]);
605 }
606
607 return p;
608 }
609
613 virtual std::string to_json() {
614 std::set<uint32_t> recruitment_ids;
615 std::set<uint32_t> growth_ids;
616 std::set<uint32_t> maturity_ids;
617 std::set<uint32_t> selectivity_ids;
618 std::set<uint32_t> fleet_ids;
619 // gather sub-module info from population and fleets
620 typename std::set<uint32_t>::iterator module_id_it; // generic
621 typename std::set<uint32_t>::iterator pit;
622 typename std::set<uint32_t>::iterator fids;
623 for (pit = this->population_ids->begin();
624 pit != this->population_ids->end(); pit++) {
625 std::shared_ptr<PopulationInterface> population_interface =
626 std::dynamic_pointer_cast<PopulationInterface>(
629 recruitment_ids.insert(population_interface->recruitment_id.get());
630 growth_ids.insert(population_interface->growth_id.get());
631 maturity_ids.insert(population_interface->maturity_id.get());
632
633 for (fids = population_interface->fleet_ids->begin();
634 fids != population_interface->fleet_ids->end(); fids++) {
635 fleet_ids.insert(*fids);
636 }
637 }
638 }
639
640 for (fids = fleet_ids.begin(); fids != fleet_ids.end(); fids++) {
641 std::shared_ptr<FleetInterface> fleet_interface =
642 std::dynamic_pointer_cast<FleetInterface>(
644 if (fleet_interface) {
645 selectivity_ids.insert(fleet_interface->GetSelectivityID());
646 }
647 }
648
649 std::shared_ptr<fims_info::Information<double>> info =
651
652 std::shared_ptr<fims_popdy::CatchAtAge<double>> model =
653 std::dynamic_pointer_cast<fims_popdy::CatchAtAge<double>>(
654 info->models_map[this->get_id()]);
655
656 std::shared_ptr<fims_model::Model<double>> model_internal =
658
659#ifdef TMB_MODEL
660 model->do_reporting = false;
661#endif
662
663 double value = model_internal->Evaluate();
664
665 std::stringstream ss;
666
667 ss.str("");
668
669 ss << "{\n";
670 ss << " \"name\": \"CatchAtAge\",\n";
671 ss << " \"type\": \"model\",\n";
672 ss << " \"estimation_framework\": ";
673#ifdef TMB_MODEL
674 ss << "\"Template_Model_Builder (TMB)\",";
675#else
676 ss << "\"FIMS\",";
677#endif
678 ss << " \"id\": " << this->get_id() << ",\n";
679 ss << " \"objective_function_value\": " << value << ",\n";
680 ss << "\"growth\":[\n";
681 for (module_id_it = growth_ids.begin(); module_id_it != growth_ids.end();
682 module_id_it++) {
683 std::shared_ptr<GrowthInterfaceBase> growth_interface =
685
686 if (growth_interface != NULL) {
687 growth_interface->finalize();
688 ss << growth_interface->to_json();
689 if (std::next(module_id_it) != growth_ids.end()) {
690 ss << ", ";
691 }
692 }
693 }
694
695 ss << "],\n";
696
697 ss << "\"recruitment\": [\n";
698 for (module_id_it = recruitment_ids.begin();
700 std::shared_ptr<RecruitmentInterfaceBase> recruitment_interface =
703 recruitment_interface->finalize();
704 ss << recruitment_interface->to_json();
705 if (std::next(module_id_it) != recruitment_ids.end()) {
706 ss << ", ";
707 }
708 }
709 }
710 ss << "],\n";
711
712 ss << "\"maturity\": [\n";
713 for (module_id_it = maturity_ids.begin();
715 std::shared_ptr<MaturityInterfaceBase> maturity_interface =
717 if (maturity_interface) {
718 maturity_interface->finalize();
719 ss << maturity_interface->to_json();
720 if (std::next(module_id_it) != maturity_ids.end()) {
721 ss << ", ";
722 }
723 }
724 }
725 ss << "],\n";
726
727 ss << "\"selectivity\": [\n";
728 for (module_id_it = selectivity_ids.begin();
730 std::shared_ptr<SelectivityInterfaceBase> selectivity_interface =
733 selectivity_interface->finalize();
734 ss << selectivity_interface->to_json();
735 if (std::next(module_id_it) != selectivity_ids.end()) {
736 ss << ", ";
737 }
738 }
739 }
740 ss << "],\n";
741
742 ss << " \"population_ids\": [";
743 for (pit = this->population_ids->begin();
744 pit != this->population_ids->end(); pit++) {
745 ss << *pit;
746 if (std::next(pit) != this->population_ids->end()) {
747 ss << ", ";
748 }
749 }
750 ss << "],\n";
751 ss << " \"fleet_ids\": [";
752
753 for (fids = fleet_ids.begin(); fids != fleet_ids.end(); fids++) {
754 ss << *fids;
755 if (std::next(fids) != fleet_ids.end()) {
756 ss << ", ";
757 }
758 }
759 ss << "],\n";
760 ss << "\"populations\": [\n";
761 typename std::set<uint32_t>::iterator pop_it;
762 typename std::set<uint32_t>::iterator pop_end_it;
763 pop_end_it = this->population_ids->end();
764 typename std::set<uint32_t>::iterator pop_second_to_last_it;
765 if (pop_end_it != this->population_ids->begin()) {
767 } else {
769 }
770 for (pop_it = this->population_ids->begin();
772 std::shared_ptr<PopulationInterface> population_interface =
773 std::dynamic_pointer_cast<PopulationInterface>(
776 std::set<uint32_t>::iterator fids;
777 for (fids = population_interface->fleet_ids->begin();
778 fids != population_interface->fleet_ids->end(); fids++) {
779 fleet_ids.insert(*fids);
780 }
781 population_interface->finalize();
782 ss << this->population_to_json(population_interface.get()) << ",";
783 } else {
784 FIMS_ERROR_LOG("Population with id " + fims::to_string(*pop_it) +
785 " not found in live objects.");
786 ss << "{}"; // Return empty JSON for this population
787 }
788 }
789
790 std::shared_ptr<PopulationInterface> population_interface =
791 std::dynamic_pointer_cast<PopulationInterface>(
794 std::set<uint32_t>::iterator fids;
795 for (fids = population_interface->fleet_ids->begin();
796 fids != population_interface->fleet_ids->end(); fids++) {
797 fleet_ids.insert(*fids);
798 }
799 ss << this->population_to_json(population_interface.get());
800 } else {
801 FIMS_ERROR_LOG("Population with id " + fims::to_string(*pop_it) +
802 " not found in live objects.");
803 ss << "{}"; // Return empty JSON for this population
804 }
805
806 ss << "]";
807 ss << ",\n";
808 ss << "\"fleets\": [\n";
809
810 typename std::set<uint32_t>::iterator fleet_it;
811 typename std::set<uint32_t>::iterator fleet_end_it;
812 fleet_end_it = fleet_ids.end();
813 typename std::set<uint32_t>::iterator fleet_second_to_last_it;
814
815 if (fleet_end_it != fleet_ids.begin()) {
817 }
818 for (fleet_it = fleet_ids.begin(); fleet_it != fleet_second_to_last_it;
819 fleet_it++) {
820 std::shared_ptr<FleetInterface> fleet_interface =
821 std::dynamic_pointer_cast<FleetInterface>(
823 if (fleet_interface) {
824 fleet_interface->finalize();
825 ss << this->fleet_to_json(fleet_interface.get()) << ",";
826 } else {
827 FIMS_ERROR_LOG("Fleet with id " + fims::to_string(*fleet_it) +
828 " not found in live objects.");
829 ss << "{}"; // Return empty JSON for this fleet
830 }
831 }
832 std::shared_ptr<FleetInterface> fleet_interface =
833 std::dynamic_pointer_cast<FleetInterface>(
835 if (fleet_interface) {
836 ss << this->fleet_to_json(fleet_interface.get());
837 } else {
838 FIMS_ERROR_LOG("Fleet with id " + fims::to_string(*fleet_it) +
839 " not found in live objects.");
840 ss << "{}"; // Return empty JSON for this fleet
841 }
842
843 ss << "],\n";
844
845 ss << "\"density_components\": [\n";
846
847 typename std::map<
848 uint32_t, std::shared_ptr<DistributionsInterfaceBase>>::iterator dit;
851 std::shared_ptr<DistributionsInterfaceBase> dist_interface =
852 (*dit).second;
853 if (dist_interface) {
854 dist_interface->finalize();
855 ss << dist_interface->to_json();
856 if (std::next(dit) != DistributionsInterfaceBase::live_objects.end()) {
857 ss << ",\n";
858 }
859 }
860 }
861 ss << "\n],\n";
862 ss << "\"data\": [\n";
863 typename std::map<uint32_t, std::shared_ptr<DataInterfaceBase>>::iterator
864 d_it;
867 std::shared_ptr<DataInterfaceBase> data_interface = (*d_it).second;
868 if (data_interface) {
869 data_interface->finalize();
870 ss << data_interface->to_json();
871 if (std::next(d_it) != DataInterfaceBase::live_objects.end()) {
872 ss << ",\n";
873 }
874 }
875 }
876 ss << "\n],\n";
877 // add log
878 ss << " \"log\": {\n";
879 ss << "\"info\": " << fims::FIMSLog::fims_log->get_info() << ","
880 << "\"warnings\": " << fims::FIMSLog::fims_log->get_warnings() << ","
881 << "\"errors\": " << fims::FIMSLog::fims_log->get_errors() << "}}";
882#ifdef TMB_MODEL
883 model->do_reporting = true;
884#endif
886 }
887
894 double sum(const std::valarray<double> &v) {
895 double sum = 0.0;
896 for (size_t i = 0; i < v.size(); i++) {
897 sum += v[i];
898 }
899 return sum;
900 }
901
908 double sum(const std::vector<double> &v) {
909 double sum = 0.0;
910 for (size_t i = 0; i < v.size(); i++) {
911 sum += v[i];
912 }
913 return sum;
914 }
915
923 double min(const std::valarray<double> &v) {
924 double min = v[0];
925 for (size_t i = 1; i < v.size(); i++) {
926 if (v[i] < min) {
927 min = v[i];
928 }
929 }
930 return min;
931 }
940 std::valarray<double> fabs(const std::valarray<double> &v) {
941 std::valarray<double> result(v.size());
942 for (size_t i = 0; i < v.size(); i++) {
943 result[i] = std::fabs(v[i]);
944 }
945 return result;
946 }
947
948#ifdef TMB_MODEL
949
950 template <typename Type>
952 std::shared_ptr<fims_info::Information<Type>> info =
954
955 std::shared_ptr<fims_popdy::CatchAtAge<Type>> model =
956 std::make_shared<fims_popdy::CatchAtAge<Type>>();
957
958 population_id_iterator it;
959
960 for (it = this->population_ids->begin(); it != this->population_ids->end();
961 ++it) {
962 model->AddPopulation((*it));
963 }
964
965 std::set<uint32_t> fleet_ids; // all fleets in the model
966 typedef typename std::set<uint32_t>::iterator fleet_ids_iterator;
967
968 // add to Information
969 info->models_map[this->get_id()] = model;
970
971 for (it = this->population_ids->begin(); it != this->population_ids->end();
972 ++it) {
975 throw std::runtime_error("Population ID " + std::to_string(*it) +
976 " not found in live_objects");
977 }
978 auto population =
979 std::dynamic_pointer_cast<PopulationInterface>(it2->second);
980 model->InitializePopulationDerivedQuantities(population->id);
981 std::map<std::string, fims::Vector<Type>> &derived_quantities =
982 model->GetPopulationDerivedQuantities(population->id);
983
984 std::map<std::string, fims_popdy::DimensionInfo>
986 model->GetPopulationDimensionInfo(population->id);
987
988 std::stringstream ss;
989
990 derived_quantities["total_landings_weight"] =
991 fims::Vector<Type>(population->n_years.get());
992
993 derived_quantities_dim_info["total_landings_weight"] =
995 "total_landings_weight",
996 fims::Vector<int>{(int)population->n_years.get()},
997 fims::Vector<std::string>{"n_years"});
998
999 derived_quantities["total_landings_numbers"] =
1000 fims::Vector<Type>(population->n_years.get());
1001
1002 derived_quantities_dim_info["total_landings_numbers"] =
1004 "total_landings_numbers",
1005 fims::Vector<int>{population->n_years.get()},
1006 fims::Vector<std::string>{"n_years"});
1007
1008 derived_quantities["mortality_F"] = fims::Vector<Type>(
1009 population->n_years.get() * population->n_ages.get());
1011 "mortality_F",
1012 fims::Vector<int>{population->n_years.get(),
1013 population->n_ages.get()},
1014 fims::Vector<std::string>{"n_years", "n_ages"});
1015
1016 derived_quantities["mortality_M"] = fims::Vector<Type>(
1017 population->n_years.get() * population->n_ages.get());
1019 "mortality_M",
1020 fims::Vector<int>{population->n_years.get(),
1021 population->n_ages.get()},
1022 fims::Vector<std::string>{"n_years", "n_ages"});
1023
1024 derived_quantities["mortality_Z"] = fims::Vector<Type>(
1025 population->n_years.get() * population->n_ages.get());
1027 "mortality_Z",
1028 fims::Vector<int>{population->n_years.get(),
1029 population->n_ages.get()},
1030 fims::Vector<std::string>{"n_years", "n_ages"});
1031
1032 derived_quantities["numbers_at_age"] = fims::Vector<Type>(
1033 (population->n_years.get() + 1) * population->n_ages.get());
1035 "numbers_at_age",
1036 fims::Vector<int>{(population->n_years.get() + 1),
1037 population->n_ages.get()},
1038 fims::Vector<std::string>{"n_years+1", "n_ages"});
1039
1040 derived_quantities["unfished_numbers_at_age"] = fims::Vector<Type>(
1041 (population->n_years.get() + 1) * population->n_ages.get());
1042 derived_quantities_dim_info["unfished_numbers_at_age"] =
1044 "unfished_numbers_at_age",
1045 fims::Vector<int>{(population->n_years.get() + 1),
1046 population->n_ages.get()},
1047 fims::Vector<std::string>{"n_years+1", "n_ages"});
1048
1049 derived_quantities["biomass"] =
1050 fims::Vector<Type>((population->n_years.get() + 1));
1052 "biomass", fims::Vector<int>{(population->n_years.get() + 1)},
1053 fims::Vector<std::string>{"n_years+1"});
1054
1055 derived_quantities["spawning_biomass"] =
1056 fims::Vector<Type>((population->n_years.get() + 1));
1057 derived_quantities_dim_info["spawning_biomass"] =
1059 "spawning_biomass",
1060 fims::Vector<int>{(population->n_years.get() + 1)},
1061 fims::Vector<std::string>{"n_years+1"});
1062
1063 derived_quantities["unfished_biomass"] =
1064 fims::Vector<Type>((population->n_years.get() + 1));
1065 derived_quantities_dim_info["unfished_biomass"] =
1067 "unfished_biomass",
1068 fims::Vector<int>{(population->n_years.get() + 1)},
1069 fims::Vector<std::string>{"n_years+1"});
1070
1071 derived_quantities["unfished_spawning_biomass"] =
1072 fims::Vector<Type>((population->n_years.get() + 1));
1073 derived_quantities_dim_info["unfished_spawning_biomass"] =
1075 "unfished_spawning_biomass",
1076 fims::Vector<int>{(population->n_years.get() + 1)},
1077 fims::Vector<std::string>{"n_years+1"});
1078
1079 derived_quantities["proportion_mature_at_age"] = fims::Vector<Type>(
1080 (population->n_years.get() + 1) * population->n_ages.get());
1081 derived_quantities_dim_info["proportion_mature_at_age"] =
1083 "proportion_mature_at_age",
1084 fims::Vector<int>{(population->n_years.get() + 1),
1085 population->n_ages.get()},
1086 fims::Vector<std::string>{"n_years+1", "n_ages"});
1087
1088 derived_quantities["expected_recruitment"] =
1089 fims::Vector<Type>((population->n_years.get() + 1));
1090 derived_quantities_dim_info["expected_recruitment"] =
1092 "expected_recruitment",
1093 fims::Vector<int>{(population->n_years.get() + 1)},
1094 fims::Vector<std::string>{"n_years+1"});
1095
1096 derived_quantities["sum_selectivity"] = fims::Vector<Type>(
1097 population->n_years.get() * population->n_ages.get());
1098 derived_quantities_dim_info["sum_selectivity"] =
1100 "sum_selectivity",
1101 fims::Vector<int>{population->n_years.get(),
1102 population->n_ages.get()},
1103 fims::Vector<std::string>{"n_years", "n_ages"});
1104
1105 // replace elements in the variable map
1106
1107 for (fleet_ids_iterator fit = population->fleet_ids->begin();
1108 fit != population->fleet_ids->end(); ++fit) {
1109 fleet_ids.insert(*fit);
1110 }
1111 }
1112
1113 for (fleet_ids_iterator it = fleet_ids.begin(); it != fleet_ids.end();
1114 ++it) {
1115 std::shared_ptr<FleetInterface> fleet_interface =
1116 std::dynamic_pointer_cast<FleetInterface>(
1118 model->InitializeFleetDerivedQuantities(fleet_interface->id);
1119 std::map<std::string, fims::Vector<Type>> &derived_quantities =
1120 model->GetFleetDerivedQuantities(fleet_interface->id);
1121
1122 std::map<std::string, fims_popdy::DimensionInfo>
1124 model->GetFleetDimensionInfo(fleet_interface->id);
1125
1126 // initialize derive quantities
1127 // landings
1128 derived_quantities["landings_numbers_at_age"] = fims::Vector<Type>(
1129 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1130 derived_quantities_dim_info["landings_numbers_at_age"] =
1132 "landings_numbers_at_age",
1133 fims::Vector<int>{(fleet_interface->n_years.get()),
1134 fleet_interface->n_ages.get()},
1135 fims::Vector<std::string>{"n_years", "n_ages"});
1136
1137 derived_quantities["landings_weight_at_age"] = fims::Vector<Type>(
1138 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1139 derived_quantities_dim_info["landings_weight_at_age"] =
1141 "landings_weight_at_age",
1142 fims::Vector<int>{(fleet_interface->n_years.get()),
1143 fleet_interface->n_ages.get()},
1144 fims::Vector<std::string>{"n_years", "n_ages"});
1145
1146 derived_quantities["landings_numbers_at_length"] = fims::Vector<Type>(
1147 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1148 derived_quantities_dim_info["landings_numbers_at_length"] =
1150 "landings_numbers_at_length",
1151 fims::Vector<int>{(fleet_interface->n_years.get()),
1152 fleet_interface->n_lengths.get()},
1153 fims::Vector<std::string>{"n_years", "n_lengths"});
1154
1155 derived_quantities["landings_weight"] =
1156 fims::Vector<Type>(fleet_interface->n_years.get());
1157 derived_quantities_dim_info["landings_weight"] =
1159 "landings_weight",
1160 fims::Vector<int>{(fleet_interface->n_years.get())},
1161 fims::Vector<std::string>{"n_years"});
1162
1163 derived_quantities["landings_numbers"] =
1164 fims::Vector<Type>(fleet_interface->n_years.get());
1165 derived_quantities_dim_info["landings_numbers"] =
1167 "landings_numbers",
1168 fims::Vector<int>{(fleet_interface->n_years.get())},
1169 fims::Vector<std::string>{"n_years"});
1170
1171 derived_quantities["landings_expected"] =
1172 fims::Vector<Type>(fleet_interface->n_years.get());
1173 derived_quantities_dim_info["landings_expected"] =
1175 "landings_expected",
1176 fims::Vector<int>{(fleet_interface->n_years.get())},
1177 fims::Vector<std::string>{"n_years"});
1178
1179 derived_quantities["log_landings_expected"] =
1180 fims::Vector<Type>(fleet_interface->n_years.get());
1181 derived_quantities_dim_info["log_landings_expected"] =
1183 "log_landings_expected",
1184 fims::Vector<int>{(fleet_interface->n_years.get())},
1185 fims::Vector<std::string>{"n_years"});
1186
1187 derived_quantities["agecomp_proportion"] = fims::Vector<Type>(
1188 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1189 derived_quantities_dim_info["agecomp_proportion"] =
1191 "agecomp_proportion",
1192 fims::Vector<int>{(fleet_interface->n_years.get()),
1193 fleet_interface->n_ages.get()},
1194 fims::Vector<std::string>{"n_years", "n_ages"});
1195
1196 derived_quantities["lengthcomp_proportion"] = fims::Vector<Type>(
1197 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1198 derived_quantities_dim_info["lengthcomp_proportion"] =
1200 "lengthcomp_proportion",
1201 fims::Vector<int>{(fleet_interface->n_years.get()),
1202 fleet_interface->n_lengths.get()},
1203 fims::Vector<std::string>{"n_years", "n_lengths"});
1204
1205 // index
1206 derived_quantities["index_numbers_at_age"] = fims::Vector<Type>(
1207 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1208 derived_quantities_dim_info["index_numbers_at_age"] =
1210 "index_numbers_at_age",
1211 fims::Vector<int>{(fleet_interface->n_years.get()),
1212 fleet_interface->n_ages.get()},
1213 fims::Vector<std::string>{"n_years", "n_ages"});
1214
1215 derived_quantities["index_weight_at_age"] = fims::Vector<Type>(
1216 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1217 derived_quantities_dim_info["index_weight_at_age"] =
1219 "index_weight_at_age",
1220 fims::Vector<int>{(fleet_interface->n_years.get()),
1221 fleet_interface->n_ages.get()},
1222 fims::Vector<std::string>{"n_years", "n_ages"});
1223
1224 derived_quantities["index_weight_at_age"] = fims::Vector<Type>(
1225 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1226 derived_quantities_dim_info["index_weight_at_age"] =
1228 "index_weight_at_age",
1229 fims::Vector<int>{(fleet_interface->n_years.get()),
1230 fleet_interface->n_ages.get()},
1231 fims::Vector<std::string>{"n_years", "n_ages"});
1232
1233 derived_quantities["index_numbers_at_length"] = fims::Vector<Type>(
1234 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1235 derived_quantities_dim_info["index_numbers_at_length"] =
1237 "index_numbers_at_length",
1238 fims::Vector<int>{(fleet_interface->n_years.get()),
1239 fleet_interface->n_lengths.get()},
1240 fims::Vector<std::string>{"n_years", "n_lengths"});
1241 derived_quantities["index_weight"] =
1242 fims::Vector<Type>(fleet_interface->n_years.get());
1244 "index_weight", fims::Vector<int>{(fleet_interface->n_years.get())},
1245 fims::Vector<std::string>{"n_years"});
1246
1247 derived_quantities["index_numbers"] =
1248 fims::Vector<Type>(fleet_interface->n_years.get());
1250 "index_numbers", fims::Vector<int>{(fleet_interface->n_years.get())},
1251 fims::Vector<std::string>{"n_years"});
1252
1253 derived_quantities["index_expected"] =
1254 fims::Vector<Type>(fleet_interface->n_years.get());
1256 "index_expected", fims::Vector<int>{(fleet_interface->n_years.get())},
1257 fims::Vector<std::string>{"n_years"});
1258
1259 derived_quantities["log_index_expected"] =
1260 fims::Vector<Type>(fleet_interface->n_years.get());
1261 derived_quantities_dim_info["log_index_expected"] =
1263 "log_index_expected",
1264 fims::Vector<int>{(fleet_interface->n_years.get())},
1265 fims::Vector<std::string>{"n_years"});
1266
1267 derived_quantities["catch_index"] =
1268 fims::Vector<Type>(fleet_interface->n_years.get());
1270 "catch_index", fims::Vector<int>{(fleet_interface->n_years.get())},
1271 fims::Vector<std::string>{"n_years"});
1272
1273 derived_quantities["agecomp_expected"] = fims::Vector<Type>(
1274 fleet_interface->n_years.get() * fleet_interface->n_ages.get());
1275 derived_quantities_dim_info["agecomp_expected"] =
1277 "agecomp_expected",
1278 fims::Vector<int>{(fleet_interface->n_years.get()),
1279 (fleet_interface->n_ages.get())},
1280 fims::Vector<std::string>{"n_years", "n_ages"});
1281
1282 derived_quantities["lengthcomp_expected"] = fims::Vector<Type>(
1283 fleet_interface->n_years.get() * fleet_interface->n_lengths.get());
1284 derived_quantities_dim_info["lengthcomp_expected"] =
1286 "lengthcomp_expected",
1287 fims::Vector<int>{(fleet_interface->n_years.get()),
1288 (fleet_interface->n_lengths.get())},
1289 fims::Vector<std::string>{"n_years", "n_lengths"});
1290
1291 // replace elements in the variable map
1292 info->variable_map[fleet_interface->log_landings_expected.id_m] =
1293 &(derived_quantities["log_landings_expected"]);
1294 info->variable_map[fleet_interface->log_index_expected.id_m] =
1295 &(derived_quantities["log_index_expected"]);
1296 info->variable_map[fleet_interface->agecomp_expected.id_m] =
1297 &(derived_quantities["agecomp_expected"]);
1298 info->variable_map[fleet_interface->agecomp_proportion.id_m] =
1299 &(derived_quantities["agecomp_proportion"]);
1300 info->variable_map[fleet_interface->lengthcomp_expected.id_m] =
1301 &(derived_quantities["lengthcomp_expected"]);
1302 info->variable_map[fleet_interface->lengthcomp_proportion.id_m] =
1303 &(derived_quantities["lengthcomp_proportion"]);
1304 }
1305
1306 return true;
1307 }
1308
1309 virtual bool add_to_fims_tmb() {
1312 return true;
1313 }
1314
1315#endif
1316};
1317
1318#endif
The CatchAtAgeInterface class is used to interface with the CatchAtAge model. It inherits from the Fi...
Definition rcpp_models.hpp:107
double min(const std::valarray< double > &v)
Minimum method to calculate the minimum of an array or vector of doubles.
Definition rcpp_models.hpp:923
virtual std::string to_json()
Serialize the fishery model to a JSON string.
Definition rcpp_models.hpp:613
Rcpp::NumericVector get_fixed_parameters_vector()
Get the vector of fixed effect parameters for the CatchAtAge model.
Definition rcpp_models.hpp:575
void AddPopulation(uint32_t id)
Definition rcpp_models.hpp:148
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:360
virtual void finalize()
Extracts derived quantities back to the Rcpp interface object from the Information object.
Definition rcpp_models.hpp:217
CatchAtAgeInterface()
The constructor.
Definition rcpp_models.hpp:128
Rcpp::NumericVector get_random_parameters_vector()
Get the vector of random effect parameters for the CatchAtAge model.
Definition rcpp_models.hpp:596
void DoReporting(bool report)
Enable or disable reporting for the CatchAtAge model.
Definition rcpp_models.hpp:169
virtual uint32_t get_id()
Method to get this id.
Definition rcpp_models.hpp:212
double sum(const std::vector< double > &v)
Sum method for a vector of doubles.
Definition rcpp_models.hpp:908
std::string fleet_to_json(FleetInterface *fleet_interface)
Method to convert a fleet to a JSON string.
Definition rcpp_models.hpp:480
double sum(const std::valarray< double > &v)
Sum method to calculate the sum of an array or vector of doubles.
Definition rcpp_models.hpp:894
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:445
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:940
std::string population_to_json(PopulationInterface *population_interface)
Method to convert a population to a JSON string.
Definition rcpp_models.hpp:222
CatchAtAgeInterface(const CatchAtAgeInterface &other)
Construct a new Catch At Age Interface object.
Definition rcpp_models.hpp:141
bool IsReporting()
Check if reporting is enabled for the CatchAtAge model.
Definition rcpp_models.hpp:191
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:68
Base class for all interface objects.
Definition rcpp_interface_base.hpp:574
static std::vector< std::shared_ptr< FIMSRcppInterfaceBase > > fims_interface_objects
FIMS interface object vectors.
Definition rcpp_interface_base.hpp:584
virtual bool add_to_fims_tmb()
A virtual method to inherit to add objects to the TMB model.
Definition rcpp_interface_base.hpp:589
The FisheryModelInterfaceBase class is the base class for all fishery models in the FIMS Rcpp interfa...
Definition rcpp_models.hpp:33
FisheryModelInterfaceBase(const FisheryModelInterfaceBase &other)
Construct a new Data Interface Base object.
Definition rcpp_models.hpp:66
static uint32_t id_g
The static id of the FleetInterfaceBase object.
Definition rcpp_models.hpp:38
virtual uint32_t get_id()=0
Get the ID for the child fleet interface objects to inherit.
FisheryModelInterfaceBase()
The constructor.
Definition rcpp_models.hpp:54
uint32_t id
The local id of the FleetInterfaceBase object.
Definition rcpp_models.hpp:42
virtual std::string to_json()
Serialize the fishery model to a JSON string.
Definition rcpp_models.hpp:87
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:49
virtual ~FisheryModelInterfaceBase()
The destructor.
Definition rcpp_models.hpp:72
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::shared_ptr< FIMSLog > fims_log
A singleton instance of the log, i.e., where there is only one log. The object is created when the ....
Definition def.hpp:215
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()
Definition model.hpp:45
#define FIMS_ERROR_LOG(MESSAGE)
Definition def.hpp:553
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:239
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