FIMS  v0.11.0
Loading...
Searching...
No Matches
rcpp_selectivity.hpp
Go to the documentation of this file.
1
9#ifndef FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_SELECTIVITY_HPP
10#define FIMS_INTERFACE_RCPP_RCPP_OBJECTS_RCPP_SELECTIVITY_HPP
11
14
20 public:
24 static uint32_t id_g;
28 uint32_t id;
34 static std::map<uint32_t, std::shared_ptr<SelectivityInterfaceBase>>
36
42 /* Create instance of map: key is id and value is pointer to
43 SelectivityInterfaceBase */
44 // SelectivityInterfaceBase::live_objects[this->id] = this;
45 }
46
54
59
63 virtual uint32_t get_id() = 0;
64
69 virtual double evaluate(double x) = 0;
70};
71
78 public:
87
93 std::make_shared<LogisticSelectivityInterface>(*this);
96 }
97
107
112
117 virtual uint32_t get_id() { return this->id; }
118
124 virtual double evaluate(double x) {
126 LogisticSel.inflection_point.resize(1);
127 LogisticSel.inflection_point[0] = this->inflection_point[0].initial_value_m;
128 LogisticSel.slope.resize(1);
129 LogisticSel.slope[0] = this->slope[0].initial_value_m;
130 return LogisticSel.evaluate(x);
131 }
132
137 virtual void finalize() {
138 if (this->finalized) {
139 // log warning that finalize has been called more than once.
140 FIMS_WARNING_LOG("Logistic Selectivity " + fims::to_string(this->id) +
141 " has been finalized already.");
142 }
143
144 this->finalized = true; // indicate this has been called already
145
146 std::shared_ptr<fims_info::Information<double>> info =
148
150
151 // search for maturity in Information
152 it = info->selectivity_models.find(this->id);
153 // if not found, just return
154 if (it == info->selectivity_models.end()) {
155 FIMS_WARNING_LOG("Logistic Selectivity " + fims::to_string(this->id) +
156 " not found in Information.");
157 return;
158 } else {
159 std::shared_ptr<fims_popdy::LogisticSelectivity<double>> sel =
160 std::dynamic_pointer_cast<fims_popdy::LogisticSelectivity<double>>(
161 it->second);
162
163 for (size_t i = 0; i < inflection_point.size(); i++) {
164 if (this->inflection_point[i].estimation_type_m.get() == "constant") {
165 this->inflection_point[i].final_value_m =
166 this->inflection_point[i].initial_value_m;
167 } else {
168 this->inflection_point[i].final_value_m = sel->inflection_point[i];
169 }
170 }
171
172 for (size_t i = 0; i < slope.size(); i++) {
173 if (this->slope[i].estimation_type_m.get() == "constant") {
174 this->slope[i].final_value_m = this->slope[i].initial_value_m;
175 } else {
176 this->slope[i].final_value_m = sel->slope[i];
177 }
178 }
179 }
180 }
181
188 virtual std::string to_json() {
189 std::stringstream ss;
190
191 ss << "{\n";
192 ss << " \"module_name\":\"Selectivity\",\n";
193 ss << " \"module_type\": \"Logistic\",\n";
194 ss << " \"module_id\": " << this->id << ",\n";
195
196 ss << " \"parameters\": [\n{\n";
197 ss << " \"name\": \"inflection_point\",\n";
198 ss << " \"id\":" << this->inflection_point.id_m << ",\n";
199 ss << " \"type\": \"vector\",\n";
200 ss << " \"dimensionality\": {\n";
201 ss << " \"header\": [null],\n";
202 ss << " \"dimensions\": [1]\n},\n";
203 ss << " \"values\":" << this->inflection_point << "},\n ";
204
205 ss << "{\n";
206 ss << " \"name\": \"slope\",\n";
207 ss << " \"id\":" << this->slope.id_m << ",\n";
208 ss << " \"type\": \"vector\",\n";
209 ss << " \"dimensionality\": {\n";
210 ss << " \"header\": [null],\n";
211 ss << " \"dimensions\": [1]\n},\n";
212 ss << " \"values\":" << this->slope << "}]\n";
213
214 ss << "}";
215
216 return ss.str();
217 }
218
219#ifdef TMB_MODEL
220
221 template <typename Type>
222 bool add_to_fims_tmb_internal() {
223 std::shared_ptr<fims_info::Information<Type>> info =
225
226 std::shared_ptr<fims_popdy::LogisticSelectivity<Type>> selectivity =
227 std::make_shared<fims_popdy::LogisticSelectivity<Type>>();
228 std::stringstream ss;
229 // set relative info
230 selectivity->id = this->id;
231 selectivity->inflection_point.resize(this->inflection_point.size());
232 for (size_t i = 0; i < this->inflection_point.size(); i++) {
233 selectivity->inflection_point[i] =
234 this->inflection_point[i].initial_value_m;
235 if (this->inflection_point[i].estimation_type_m.get() ==
236 "fixed_effects") {
237 ss.str("");
238 ss << "Selectivity." << this->id << ".inflection_point."
239 << this->inflection_point[i].id_m;
240 info->RegisterParameterName(ss.str());
241 info->RegisterParameter(selectivity->inflection_point[i]);
242 }
243 if (this->inflection_point[i].estimation_type_m.get() ==
244 "random_effects") {
245 ss.str("");
246 ss << "Selectivity." << this->id << ".inflection_point."
247 << this->inflection_point[i].id_m;
248 info->RegisterRandomEffect(selectivity->inflection_point[i]);
249 info->RegisterRandomEffectName(ss.str());
250 }
251 }
252 info->variable_map[this->inflection_point.id_m] =
253 &(selectivity)->inflection_point;
254
255 selectivity->slope.resize(this->slope.size());
256 for (size_t i = 0; i < this->slope.size(); i++) {
257 selectivity->slope[i] = this->slope[i].initial_value_m;
258 if (this->slope[i].estimation_type_m.get() == "fixed_effects") {
259 ss.str("");
260 ss << "Selectivity." << this->id << ".slope." << this->slope[i].id_m;
261 info->RegisterParameterName(ss.str());
262 info->RegisterParameter(selectivity->slope[i]);
263 }
264 if (this->slope[i].estimation_type_m.get() == "random_effects") {
265 ss.str("");
266 ss << "Selectivity." << this->id << ".slope." << this->slope[i].id_m;
267 info->RegisterRandomEffectName(ss.str());
268 info->RegisterRandomEffect(selectivity->slope[i]);
269 }
270 }
271 info->variable_map[this->slope.id_m] = &(selectivity)->slope;
272
273 // add to Information
274 info->selectivity_models[selectivity->id] = selectivity;
275
276 return true;
277 }
278
283 virtual bool add_to_fims_tmb() {
284 this->add_to_fims_tmb_internal<TMB_FIMS_REAL_TYPE>();
285 this->add_to_fims_tmb_internal<TMBAD_FIMS_TYPE>();
286
287 return true;
288 }
289
290#endif
291};
292
299 public:
316
319 std::make_shared<DoubleLogisticSelectivityInterface>(*this);
322 }
323
336
338
340 virtual uint32_t get_id() { return this->id; }
341
346 virtual double evaluate(double x) {
348 DoubleLogisticSel.inflection_point_asc.resize(1);
349 DoubleLogisticSel.inflection_point_asc[0] =
350 this->inflection_point_asc[0].initial_value_m;
351 DoubleLogisticSel.slope_asc.resize(1);
352 DoubleLogisticSel.slope_asc[0] = this->slope_asc[0].initial_value_m;
353 DoubleLogisticSel.inflection_point_desc.resize(1);
354 DoubleLogisticSel.inflection_point_desc[0] =
355 this->inflection_point_desc[0].initial_value_m;
356 DoubleLogisticSel.slope_desc.resize(1);
357 DoubleLogisticSel.slope_desc[0] = this->slope_desc[0].initial_value_m;
358 return DoubleLogisticSel.evaluate(x);
359 }
364 virtual void finalize() {
365 if (this->finalized) {
366 // log warning that finalize has been called more than once.
367 FIMS_WARNING_LOG("Double Logistic Selectivity " +
368 fims::to_string(this->id) +
369 " has been finalized already.");
370 }
371
372 this->finalized = true; // indicate this has been called already
373
374 std::shared_ptr<fims_info::Information<double>> info =
376
378
379 // search for maturity in Information
380 it = info->selectivity_models.find(this->id);
381 // if not found, just return
382 if (it == info->selectivity_models.end()) {
383 FIMS_WARNING_LOG("Double Logistic Selectivity " +
384 fims::to_string(this->id) +
385 " not found in Information.");
386 return;
387 } else {
388 std::shared_ptr<fims_popdy::DoubleLogisticSelectivity<double>> sel =
389 std::dynamic_pointer_cast<
391
392 for (size_t i = 0; i < inflection_point_asc.size(); i++) {
393 if (this->inflection_point_asc[i].estimation_type_m.get() ==
394 "constant") {
395 this->inflection_point_asc[i].final_value_m =
396 this->inflection_point_asc[i].initial_value_m;
397 } else {
398 this->inflection_point_asc[i].final_value_m =
399 sel->inflection_point_asc[i];
400 }
401 }
402
403 for (size_t i = 0; i < slope_asc.size(); i++) {
404 if (this->slope_asc[i].estimation_type_m.get() == "constant") {
405 this->slope_asc[i].final_value_m = this->slope_asc[i].initial_value_m;
406 } else {
407 this->slope_asc[i].final_value_m = sel->slope_asc[i];
408 }
409 }
410
411 for (size_t i = 0; i < inflection_point_desc.size(); i++) {
412 if (this->inflection_point_desc[i].estimation_type_m.get() ==
413 "constant") {
414 this->inflection_point_desc[i].final_value_m =
415 this->inflection_point_desc[i].initial_value_m;
416 } else {
417 this->inflection_point_desc[i].final_value_m =
418 sel->inflection_point_desc[i];
419 }
420 }
421
422 for (size_t i = 0; i < slope_desc.size(); i++) {
423 if (this->slope_desc[i].estimation_type_m.get() == "constant") {
424 this->slope_desc[i].final_value_m =
425 this->slope_desc[i].initial_value_m;
426 } else {
427 this->slope_desc[i].final_value_m = sel->slope_desc[i];
428 }
429 }
430 }
431 }
432
436 virtual std::string to_json() {
437 std::stringstream ss;
438
439 ss << "{\n";
440 ss << " \"module_name\": \"Selectivity\",\n";
441 ss << " \"module_type\": \"DoubleLogistic\",\n";
442 ss << " \"module_id\": " << this->id << ",\n";
443
444 ss << " \"parameters\":[\n{\n";
445 ss << " \"name\": \"inflection_point_asc\",\n";
446 ss << " \"id\":" << this->inflection_point_asc.id_m << ",\n";
447 ss << " \"type\": \"vector\",\n";
448 ss << " \"dimensionality\": {\n";
449 ss << " \"header\": [null],\n";
450 ss << " \"dimensions\": [1]\n},\n";
451 ss << " \"values\":" << this->inflection_point_asc << "},\n";
452
453 ss << "{\n";
454 ss << " \"name\": \"slope_asc\",\n";
455 ss << " \"id\":" << this->slope_asc.id_m << ",\n";
456 ss << " \"type\": \"vector\",\n";
457 ss << " \"dimensionality\": {\n";
458 ss << " \"header\": [null],\n";
459 ss << " \"dimensions\": [1]\n},\n";
460 ss << " \"values\":" << this->slope_asc << "},\n";
461
462 ss << " {\n";
463 ss << " \"name\": \"inflection_point_desc\",\n";
464 ss << " \"id\":" << this->inflection_point_desc.id_m << ",\n";
465 ss << " \"type\": \"vector\",\n";
466 ss << " \"dimensionality\": {\n";
467 ss << " \"header\": [null],\n";
468 ss << " \"dimensions\": [1]\n},\n";
469 ss << " \"values\":" << this->inflection_point_desc << "},\n";
470
471 ss << "{\n";
472 ss << " \"name\": \"slope_desc\",\n";
473 ss << " \"id\":" << this->slope_desc.id_m << ",\n";
474 ss << " \"type\": \"vector\",\n";
475 ss << " \"dimensionality\": {\n";
476 ss << " \"header\": [null],\n";
477 ss << " \"dimensions\": [1]\n},\n";
478 ss << " \"values\":" << this->slope_desc << "}]\n";
479
480 ss << "}";
481
482 return ss.str();
483 }
484
485#ifdef TMB_MODEL
486
487 template <typename Type>
488 bool add_to_fims_tmb_internal() {
489 std::shared_ptr<fims_info::Information<Type>> info =
491
492 std::shared_ptr<fims_popdy::DoubleLogisticSelectivity<Type>> selectivity =
493 std::make_shared<fims_popdy::DoubleLogisticSelectivity<Type>>();
494
495 std::stringstream ss;
496 // set relative info
497 selectivity->id = this->id;
498 selectivity->inflection_point_asc.resize(this->inflection_point_asc.size());
499 for (size_t i = 0; i < this->inflection_point_asc.size(); i++) {
500 selectivity->inflection_point_asc[i] =
501 this->inflection_point_asc[i].initial_value_m;
502 if (this->inflection_point_asc[i].estimation_type_m.get() ==
503 "fixed_effects") {
504 ss.str("");
505 ss << "Selectivity." << this->id << ".inflection_point_asc."
506 << this->inflection_point_asc[i].id_m;
507 info->RegisterParameterName(ss.str());
508 info->RegisterParameter(selectivity->inflection_point_asc[i]);
509 }
510 if (this->inflection_point_asc[i].estimation_type_m.get() ==
511 "random_effects") {
512 ss.str("");
513 ss << "Selectivity." << this->id << ".inflection_point_asc."
514 << this->inflection_point_asc[i].id_m;
515 info->RegisterRandomEffectName(ss.str());
516 info->RegisterRandomEffect(selectivity->inflection_point_asc[i]);
517 }
518 }
519 info->variable_map[this->inflection_point_asc.id_m] =
520 &(selectivity)->inflection_point_asc;
521
522 selectivity->slope_asc.resize(this->slope_asc.size());
523 for (size_t i = 0; i < this->slope_asc.size(); i++) {
524 selectivity->slope_asc[i] = this->slope_asc[i].initial_value_m;
525
526 if (this->slope_asc[i].estimation_type_m.get() == "fixed_effects") {
527 ss.str("");
528 ss << "Selectivity." << this->id << ".slope_asc."
529 << this->slope_asc[i].id_m;
530 info->RegisterParameterName(ss.str());
531 info->RegisterParameter(selectivity->slope_asc[i]);
532 }
533 if (this->slope_asc[i].estimation_type_m.get() == "random_effects") {
534 ss.str("");
535 ss << "Selectivity." << this->id << ".slope_asc."
536 << this->slope_asc[i].id_m;
537 info->RegisterRandomEffectName(ss.str());
538 info->RegisterRandomEffect(selectivity->slope_asc[i]);
539 }
540 }
541 info->variable_map[this->slope_asc.id_m] = &(selectivity)->slope_asc;
542
543 selectivity->inflection_point_desc.resize(
544 this->inflection_point_desc.size());
545 for (size_t i = 0; i < this->inflection_point_desc.size(); i++) {
546 selectivity->inflection_point_desc[i] =
547 this->inflection_point_desc[i].initial_value_m;
548
549 if (this->inflection_point_desc[i].estimation_type_m.get() ==
550 "fixed_effects") {
551 ss.str("");
552 ss << "Selectivity." << this->id << ".inflection_point_desc."
553 << this->inflection_point_desc[i].id_m;
554 info->RegisterParameterName(ss.str());
555 info->RegisterParameter(selectivity->inflection_point_desc[i]);
556 }
557 if (this->inflection_point_desc[i].estimation_type_m.get() ==
558 "random_effects") {
559 ss.str("");
560 ss << "Selectivity." << this->id << ".inflection_point_desc."
561 << this->inflection_point_desc[i].id_m;
562 info->RegisterRandomEffectName(ss.str());
563 info->RegisterRandomEffect(selectivity->inflection_point_desc[i]);
564 }
565 }
566 info->variable_map[this->inflection_point_desc.id_m] =
567 &(selectivity)->inflection_point_desc;
568
569 selectivity->slope_desc.resize(this->slope_desc.size());
570 for (size_t i = 0; i < this->slope_desc.size(); i++) {
571 selectivity->slope_desc[i] = this->slope_desc[i].initial_value_m;
572
573 if (this->slope_desc[i].estimation_type_m.get() == "fixed_effects") {
574 ss.str("");
575 ss << "Selectivity." << this->id << ".slope_desc."
576 << this->slope_desc[i].id_m;
577 info->RegisterParameterName(ss.str());
578 info->RegisterParameter(selectivity->slope_desc[i]);
579 }
580 if (this->slope_desc[i].estimation_type_m.get() == "random_effects") {
581 ss.str("");
582 ss << "Selectivity." << this->id << ".slope_desc."
583 << this->slope_desc[i].id_m;
584 info->RegisterRandomEffectName(ss.str());
585 info->RegisterRandomEffect(selectivity->slope_desc[i]);
586 }
587 }
588
589 info->variable_map[this->slope_desc.id_m] = &(selectivity)->slope_desc;
590
591 // add to Information
592 info->selectivity_models[selectivity->id] = selectivity;
593
594 return true;
595 }
596
601 virtual bool add_to_fims_tmb() {
602 this->add_to_fims_tmb_internal<TMB_FIMS_REAL_TYPE>();
603 this->add_to_fims_tmb_internal<TMBAD_FIMS_TYPE>();
604
605 return true;
606 }
607
608#endif
609};
610
617 public:
634
640 std::make_shared<AgeSpecificSelectivityInterface>(*this);
643 }
644
656
661
666 virtual uint32_t get_id() { return this->id; }
667
673 virtual double evaluate(double x) {
675 AgeSpecificSel.n_ages = this->n_ages.get();
676 if (this->ages.size() > 0) {
677 AgeSpecificSel.min_age = static_cast<size_t>(*std::min_element(
678 this->ages.storage_m->begin(), this->ages.storage_m->end()));
679 } else {
680 AgeSpecificSel.min_age = static_cast<size_t>(this->min_age.get());
681 }
682 AgeSpecificSel.logit_sel_at_age.resize(this->logit_sel_at_age.size());
683 for (size_t i = 0; i < this->logit_sel_at_age.size(); i++) {
684 AgeSpecificSel.logit_sel_at_age[i] =
685 this->logit_sel_at_age[i].initial_value_m;
686 }
687 return AgeSpecificSel.evaluate(x);
688 }
689
694 virtual void finalize() {
695 if (this->finalized) {
696 // log warning that finalize has been called more than once.
697 FIMS_WARNING_LOG("Age Specific Selectivity " + fims::to_string(this->id) +
698 " has been finalized already.");
699 }
700
701 this->finalized = true; // indicate this has been called already
702
703 std::shared_ptr<fims_info::Information<double>> info =
705
707
708 // search for maturity in Information
709 it = info->selectivity_models.find(this->id);
710 // if not found, just return
711 if (it == info->selectivity_models.end()) {
712 FIMS_WARNING_LOG("Age Specific Selectivity " + fims::to_string(this->id) +
713 " not found in Information.");
714 return;
715 } else {
716 std::shared_ptr<fims_popdy::AgeSpecificSelectivity<double>> sel =
717 std::dynamic_pointer_cast<fims_popdy::AgeSpecificSelectivity<double>>(
718 it->second);
719 for (size_t i = 0; i < logit_sel_at_age.size(); i++) {
720 if (this->logit_sel_at_age[i].estimation_type_m.get() == "constant") {
721 this->logit_sel_at_age[i].final_value_m =
722 this->logit_sel_at_age[i].initial_value_m;
723 } else {
724 this->logit_sel_at_age[i].final_value_m = sel->logit_sel_at_age[i];
725 }
726 }
727 }
728 }
729
736 virtual std::string to_json() {
737 std::stringstream ss;
738
739 ss << "{\n";
740 ss << " \"module_name\":\"Selectivity\",\n";
741 ss << " \"module_type\": \"AgeSpecific\",\n";
742 ss << " \"module_id\": " << this->id << ",\n";
743
744 ss << " \"parameters\": [\n{\n";
745 ss << " \"name\": \"logit_sel_at_age\",\n";
746 ss << " \"id\":" << this->logit_sel_at_age.id_m << ",\n";
747 ss << " \"type\": \"vector\",\n";
748 ss << " \"dimensionality\": {\n";
749 ss << " \"header\": [\"n_ages\"],\n";
750 ss << " \"dimensions\": [" << this->n_ages.get() << "]\n},\n";
751 ss << " \"values\":" << this->logit_sel_at_age << "}]\n";
752
753 ss << "}";
754
755 return ss.str();
756 }
757
758#ifdef TMB_MODEL
759
760 template <typename Type>
761 bool add_to_fims_tmb_internal() {
762 std::shared_ptr<fims_info::Information<Type>> info =
764
765 std::shared_ptr<fims_popdy::AgeSpecificSelectivity<Type>> selectivity =
766 std::make_shared<fims_popdy::AgeSpecificSelectivity<Type>>();
767 std::stringstream ss;
768 // set relative info
769 selectivity->id = this->id;
770 selectivity->n_ages = this->n_ages.get();
771 if (this->ages.size() > 0) {
772 selectivity->min_age = static_cast<size_t>(*std::min_element(
773 this->ages.storage_m->begin(), this->ages.storage_m->end()));
774 } else {
775 selectivity->min_age = static_cast<size_t>(this->min_age.get());
776 }
777 selectivity->logit_sel_at_age.resize(this->logit_sel_at_age.size());
778 for (size_t i = 0; i < this->logit_sel_at_age.size(); i++) {
779 selectivity->logit_sel_at_age[i] =
780 this->logit_sel_at_age[i].initial_value_m;
781 if (this->logit_sel_at_age[i].estimation_type_m.get() ==
782 "fixed_effects") {
783 ss.str("");
784 ss << "Selectivity." << this->id << ".logit_sel_at_age."
785 << this->logit_sel_at_age[i].id_m;
786 info->RegisterParameterName(ss.str());
787 info->RegisterParameter(selectivity->logit_sel_at_age[i]);
788 }
789 if (this->logit_sel_at_age[i].estimation_type_m.get() ==
790 "random_effects") {
791 ss.str("");
792 ss << "Selectivity." << this->id << ".logit_sel_at_age."
793 << this->logit_sel_at_age[i].id_m;
794 info->RegisterRandomEffect(selectivity->logit_sel_at_age[i]);
795 info->RegisterRandomEffectName(ss.str());
796 }
797 }
798 info->variable_map[this->logit_sel_at_age.id_m] =
799 &(selectivity)->logit_sel_at_age;
800
801 // add to Information
802 info->selectivity_models[selectivity->id] = selectivity;
803
804 return true;
805 }
806
811 virtual bool add_to_fims_tmb() {
812 this->add_to_fims_tmb_internal<TMB_FIMS_REAL_TYPE>();
813 this->add_to_fims_tmb_internal<TMBAD_FIMS_TYPE>();
814
815 return true;
816 }
817
818#endif
819};
820
821#endif
Rcpp interface for selectivity_at_age to instantiate the object from R: selectivity_at_age <- methods...
Definition rcpp_selectivity.hpp:616
VariableVector logit_sel_at_age
Age-specific selectivity parameter values.
Definition rcpp_selectivity.hpp:633
virtual ~AgeSpecificSelectivityInterface()
The destructor.
Definition rcpp_selectivity.hpp:660
virtual uint32_t get_id()
Gets the ID of the interface base object.
Definition rcpp_selectivity.hpp:666
SharedInt n_ages
The number of age bins.
Definition rcpp_selectivity.hpp:621
virtual void finalize()
Extracts derived quantities back to the Rcpp interface object from the Information object.
Definition rcpp_selectivity.hpp:694
AgeSpecificSelectivityInterface()
The constructor.
Definition rcpp_selectivity.hpp:638
virtual double evaluate(double x)
Evaluate selectivity using fims_math::inv_logit.
Definition rcpp_selectivity.hpp:673
RealVector ages
Vector of ages.
Definition rcpp_selectivity.hpp:625
virtual std::string to_json()
Converts the data to json representation for the output.
Definition rcpp_selectivity.hpp:736
AgeSpecificSelectivityInterface(const AgeSpecificSelectivityInterface &other)
Construct a new Selectivity-at-age Interface object.
Definition rcpp_selectivity.hpp:650
SharedInt min_age
Minimum observed age.
Definition rcpp_selectivity.hpp:629
Rcpp interface for logistic selectivity as an S4 object. To instantiate from R: logistic_selectivity ...
Definition rcpp_selectivity.hpp:298
DoubleLogisticSelectivityInterface(const DoubleLogisticSelectivityInterface &other)
Construct a new Double Logistic Selectivity Interface object.
Definition rcpp_selectivity.hpp:329
VariableVector slope_desc
How quickly selectivity falls on the descending limb; larger values give a steeper decline.
Definition rcpp_selectivity.hpp:315
virtual double evaluate(double x)
evaluate the double logistic selectivity function
Definition rcpp_selectivity.hpp:346
virtual uint32_t get_id()
returns the id for the double logistic selectivity interface
Definition rcpp_selectivity.hpp:340
VariableVector slope_asc
How quickly selectivity rises on the ascending limb; larger values give a steeper,...
Definition rcpp_selectivity.hpp:307
VariableVector inflection_point_asc
The age at which the ascending limb is 0.5 for models that start at age zero and each age bin represe...
Definition rcpp_selectivity.hpp:303
VariableVector inflection_point_desc
The age at which the descending limb is 0.5 for models that start at age zero and each age bin repres...
Definition rcpp_selectivity.hpp:311
virtual std::string to_json()
Convert the data to json representation for the output.
Definition rcpp_selectivity.hpp:436
virtual void finalize()
finalize function. Extracts derived quantities back to the Rcpp interface object from the Information...
Definition rcpp_selectivity.hpp:364
Base class for all interface objects.
Definition rcpp_interface_base.hpp:655
bool finalized
Is the object already finalized? The default is false.
Definition rcpp_interface_base.hpp:660
static std::vector< std::shared_ptr< FIMSRcppInterfaceBase > > fims_interface_objects
FIMS interface object vectors.
Definition rcpp_interface_base.hpp:665
virtual bool add_to_fims_tmb()
A virtual method to inherit to add objects to the TMB model.
Definition rcpp_interface_base.hpp:670
Rcpp interface for logistic selectivity to instantiate the object from R: logistic_selectivity <- met...
Definition rcpp_selectivity.hpp:77
virtual void finalize()
Extracts derived quantities back to the Rcpp interface object from the Information object.
Definition rcpp_selectivity.hpp:137
VariableVector slope
How quickly selectivity changes with age around the inflection point, per year of age....
Definition rcpp_selectivity.hpp:86
LogisticSelectivityInterface()
The constructor.
Definition rcpp_selectivity.hpp:91
virtual std::string to_json()
Converts the data to json representation for the output.
Definition rcpp_selectivity.hpp:188
virtual ~LogisticSelectivityInterface()
The destructor.
Definition rcpp_selectivity.hpp:111
virtual uint32_t get_id()
Gets the ID of the interface base object.
Definition rcpp_selectivity.hpp:117
VariableVector inflection_point
The age at which 50% of fish are selected for models that start at age zero and each age bin represen...
Definition rcpp_selectivity.hpp:82
LogisticSelectivityInterface(const LogisticSelectivityInterface &other)
Construct a new Logistic Selectivity Interface object.
Definition rcpp_selectivity.hpp:103
virtual double evaluate(double x)
Evaluate selectivity using the logistic function.
Definition rcpp_selectivity.hpp:124
An Rcpp interface class that defines the RealVector class.
Definition rcpp_interface_base.hpp:431
size_t size()
Returns the size of a RealVector.
Definition rcpp_interface_base.hpp:602
std::shared_ptr< std::vector< double > > storage_m
real storage.
Definition rcpp_interface_base.hpp:440
Rcpp interface that serves as the parent class for Rcpp selectivity interfaces. This type should be i...
Definition rcpp_selectivity.hpp:19
virtual ~SelectivityInterfaceBase()
The destructor.
Definition rcpp_selectivity.hpp:58
SelectivityInterfaceBase()
The constructor.
Definition rcpp_selectivity.hpp:40
virtual uint32_t get_id()=0
Get the ID for the child selectivity interface objects to inherit.
SelectivityInterfaceBase(const SelectivityInterfaceBase &other)
Construct a new Selectivity Interface Base object.
Definition rcpp_selectivity.hpp:52
static uint32_t id_g
The static id of the SelectivityInterfaceBase.
Definition rcpp_selectivity.hpp:24
virtual double evaluate(double x)=0
A method for each child selectivity interface object to inherit so each selectivity option can have a...
uint32_t id
The local id of the SelectivityInterfaceBase object.
Definition rcpp_selectivity.hpp:28
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
A class that provides shared ownership of an integer value.
Definition rcpp_shared_primitive.hpp:29
int get() const
Retrieve the value of the integer.
Definition rcpp_shared_primitive.hpp:127
An Rcpp interface class that defines the VariableVector class.
Definition rcpp_interface_base.hpp:143
Variable & get(size_t pos)
An internal accessor for calling a position of a VariableVector from R.
Definition rcpp_interface_base.hpp:266
uint32_t id_m
The local ID of the Variable object.
Definition rcpp_interface_base.hpp:156
void resize(size_t size)
Resizes a VariableVector to the desired length.
Definition rcpp_interface_base.hpp:294
size_t size()
Returns the size of a VariableVector.
Definition rcpp_interface_base.hpp:287
std::map< uint32_t, std::shared_ptr< fims_popdy::SelectivityBase< Type > > > selectivity_models
Definition information.hpp:83
std::map< uint32_t, std::shared_ptr< fims_popdy::SelectivityBase< Type > > >::iterator selectivity_models_iterator
Definition information.hpp:87
static std::shared_ptr< Information< Type > > GetInstance()
Returns a singleton Information object for type T.
Definition information.hpp:262
#define FIMS_WARNING_LOG(MESSAGE)
Definition def.hpp:648
The Rcpp interface to declare objects that are used ubiquitously throughout the Rcpp interface,...
Includes any .hpp files within the subfolders so that only this file needs to included in include sta...
Age-specific selectivity calculated using one parameter per age bin.
Definition age_specific.hpp:49
size_t min_age
Minimum modeled age, used to map input age to logit_sel_at_age.
Definition age_specific.hpp:65
virtual const Type evaluate(const Type &x)
Calculates selectivity for an age using its age-specific parameter.
Definition age_specific.hpp:89
size_t n_ages
Stores the number of modeled age bins.
Definition age_specific.hpp:60
fims::Vector< Type > logit_sel_at_age
Stores the age-specific selectivity parameters on the logit scale.
Definition age_specific.hpp:55
DoubleLogisticSelectivity class that returns the double logistic function value from fims_math.
Definition double_logistic.hpp:23
fims::Vector< Type > inflection_point_asc
The age at which the ascending limb is 0.5 for models that start at age zero and each age bin represe...
Definition double_logistic.hpp:30
fims::Vector< Type > slope_asc
How quickly selectivity rises on the ascending limb; larger values give a steeper,...
Definition double_logistic.hpp:37
fims::Vector< Type > slope_desc
How quickly selectivity falls on the descending limb; larger values give a steeper decline.
Definition double_logistic.hpp:51
fims::Vector< Type > inflection_point_desc
The age at which the descending limb is 0.5 for models that start at age zero and each age bin repres...
Definition double_logistic.hpp:44
virtual const Type evaluate(const Type &x)
Method of the double logistic selectivity class that implements the double logistic function from FIM...
Definition double_logistic.hpp:68
LogisticSelectivity class that returns the logistic function value from fims_math.
Definition logistic.hpp:29
fims::Vector< Type > slope
How quickly selectivity changes with age around the inflection point, per year of age....
Definition logistic.hpp:42
virtual const Type evaluate(const Type &x)
Method of the logistic selectivity class that implements the logistic function from FIMS math.
Definition logistic.hpp:62
fims::Vector< Type > inflection_point
The age at which 50% of fish are selected for models that start at age zero and each age bin represen...
Definition logistic.hpp:36