Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
699 changes: 699 additions & 0 deletions inst/design_docs/Refactor_S4_2_XPtr.Rmd

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class DistributionsInterfaceBase : public FIMSRcppInterfaceBase {
/**
* @brief The type of density input. The options are prior, re, or data.
*/
SharedString input_type_m;
std::string input_type_m;
/**
* @brief Control flag indicating whether to use the expected mean in the
* distribution calculations.
*
* This shared string member serves as a boolean flag (i.e., "yes" or "no")
* This string member serves as a boolean flag (i.e., "yes" or "no")
* that determines whether the distribution should use the `expected_mean`
* vector or other expected values (e.g., from data or random effects) when
* computing the expected value in the likelihood calculations.
Expand All @@ -57,7 +57,7 @@ class DistributionsInterfaceBase : public FIMSRcppInterfaceBase {
* @see DensityComponentBase::get_expected() in density_components_base.hpp
* for the implementation that checks this flag.
*/
SharedString use_mean_m = fims::to_string("no");
std::string use_mean_m = "no";
/**
* @brief The map associating the ID of the DistributionsInterfaceBase to the
DistributionsInterfaceBase objects. This is a live object, which is an
Expand All @@ -68,7 +68,7 @@ class DistributionsInterfaceBase : public FIMSRcppInterfaceBase {
/**
* @brief The ID of the observed data object, which is set to -999.
*/
SharedInt interface_observed_data_id_m = -999;
int interface_observed_data_id_m = -999;

/**
* @brief The log probability density function value.
Expand Down Expand Up @@ -230,7 +230,7 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase {
* @param observed_data_id Unique ID for the observed data object.
*/
virtual bool set_observed_data(int observed_data_id) {
this->interface_observed_data_id_m.set(observed_data_id);
this->interface_observed_data_id_m = observed_data_id;
return true;
}

Expand All @@ -240,7 +240,7 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase {
virtual bool set_distribution_mean(double input_value) {
this->expected_mean[0].initial_value_m = input_value;
this->expected_mean[0].estimation_type_m.set("fixed_effects");
this->use_mean_m.set(fims::to_string("yes"));
this->use_mean_m = "yes";
return true;
}

Expand All @@ -249,7 +249,7 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase {
*/
virtual bool set_distribution_links(std::string input_type,
Rcpp::IntegerVector ids) {
this->input_type_m.set(input_type);
this->input_type_m = input_type;
this->key_m->resize(ids.size());
for (R_xlen_t i = 0; i < ids.size(); i++) {
this->key_m->at(i) = ids[i];
Expand Down Expand Up @@ -486,7 +486,7 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase {
}
info->variable_map[this->log_sd.id_m] = &(distribution)->log_sd;

distribution->use_mean = this->use_mean_m.get();
distribution->use_mean = this->use_mean_m;
distribution->expected_mean.resize(this->expected_mean.size());
for (size_t i = 0; i < this->expected_mean.size(); i++) {
distribution->expected_mean[i] = this->expected_mean[i].initial_value_m;
Expand Down Expand Up @@ -590,7 +590,7 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase {
* @param observed_data_id Unique ID for the observed data object.
*/
virtual bool set_observed_data(int observed_data_id) {
this->interface_observed_data_id_m.set(observed_data_id);
this->interface_observed_data_id_m = observed_data_id;
return true;
}

Expand All @@ -604,7 +604,7 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase {
*/
virtual bool set_distribution_links(std::string input_type,
Rcpp::IntegerVector ids) {
this->input_type_m.set(input_type);
this->input_type_m = input_type;
this->key_m->resize(ids.size());
for (R_xlen_t i = 0; i < ids.size(); i++) {
this->key_m->at(i) = ids[i];
Expand Down Expand Up @@ -875,7 +875,7 @@ class DmultinomDistributionsInterface : public DistributionsInterfaceBase {
* @brief TODO: document this.
*
*/
SharedString notes;
std::string notes;

/**
* @brief The constructor.
Expand Down Expand Up @@ -915,7 +915,7 @@ class DmultinomDistributionsInterface : public DistributionsInterfaceBase {
* @param observed_data_id Unique ID for the observed data object.
*/
virtual bool set_observed_data(int observed_data_id) {
this->interface_observed_data_id_m.set(observed_data_id);
this->interface_observed_data_id_m = observed_data_id;
return true;
}

Expand All @@ -929,7 +929,7 @@ class DmultinomDistributionsInterface : public DistributionsInterfaceBase {
*/
virtual bool set_distribution_links(std::string input_type,
Rcpp::IntegerVector ids) {
this->input_type_m.set(input_type);
this->input_type_m = input_type;
this->key_m->resize(ids.size());
for (R_xlen_t i = 0; i < ids.size(); i++) {
this->key_m->at(i) = ids[i];
Expand All @@ -942,7 +942,7 @@ class DmultinomDistributionsInterface : public DistributionsInterfaceBase {
*
* @param note
*/
void set_note(std::string note) { this->notes.set(note); }
void set_note(std::string note) { this->notes = note; }

/**
* @brief
Expand Down
74 changes: 37 additions & 37 deletions inst/include/interface/rcpp/rcpp_objects/rcpp_fleet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,51 +69,51 @@ class FleetInterface : public FleetInterfaceBase {
/**
* @brief The ID of the observed age-composition data object.
*/
SharedInt interface_observed_agecomp_data_id_m = -999;
int interface_observed_agecomp_data_id_m = -999;
/**
* @brief The ID of the observed length-composition data object.
*/
SharedInt interface_observed_lengthcomp_data_id_m = -999;
int interface_observed_lengthcomp_data_id_m = -999;
/**
* @brief The ID of the observed index data object.
*/
SharedInt interface_observed_index_data_id_m = -999;
int interface_observed_index_data_id_m = -999;
/**
* @brief The ID of the observed landings data object.
*/
SharedInt interface_observed_landings_data_id_m = -999;
int interface_observed_landings_data_id_m = -999;
/**
* @brief The ID of the selectivity object.
*/
SharedInt interface_selectivity_id_m = -999;
int interface_selectivity_id_m = -999;

public:
/**
* @brief The name of the fleet.
*/
SharedString name = fims::to_string("NA");
std::string name = "NA";
/**
* @brief The number of age bins in the fleet data.
*/
SharedInt n_ages = 0;
int n_ages = 0;
/**
* @brief The number of length bins in the fleet data.
*/
SharedInt n_lengths = 0;
int n_lengths = 0;
/**
* @brief The number of years in the fleet data.
*/
SharedInt n_years = 0;
int n_years = 0;
/**
* @brief What units are the observed landings for this fleet measured in.
* Options are weight or numbers, default is weight.
*/
SharedString observed_landings_units = fims::to_string("weight");
std::string observed_landings_units = "weight";
/**
* @brief What units is the observed index of abundance for this fleet
* measured in. Options are weight or numbers, default is weight.
*/
SharedString observed_index_units = fims::to_string("weight");
std::string observed_index_units = "weight";
/**
* @brief The natural log of the index of abundance scaling parameter
* for this fleet.
Expand Down Expand Up @@ -282,87 +282,87 @@ class FleetInterface : public FleetInterfaceBase {
* @brief Sets the name of the fleet.
* @param name The name to set.
*/
void SetName(const std::string &name) { this->name.set(name); }
void SetName(const std::string &name) { this->name = name; }

/**
* @brief Gets the name of the fleet.
* @return The name.
*/
std::string GetName() const { return this->name.get(); }
std::string GetName() const { return this->name; }

/**
* @brief Set the unique ID for the observed age-composition data object.
* @param observed_agecomp_data_id Unique ID for the observed data object.
*/
void SetObservedAgeCompDataID(int observed_agecomp_data_id) {
interface_observed_agecomp_data_id_m.set(observed_agecomp_data_id);
interface_observed_agecomp_data_id_m = observed_agecomp_data_id;
}

/**
* @brief Set the unique ID for the observed length-composition data object.
* @param observed_lengthcomp_data_id Unique ID for the observed data object.
*/
void SetObservedLengthCompDataID(int observed_lengthcomp_data_id) {
interface_observed_lengthcomp_data_id_m.set(observed_lengthcomp_data_id);
interface_observed_lengthcomp_data_id_m = observed_lengthcomp_data_id;
}

/**
* @brief Set the unique ID for the observed index data object.
* @param observed_index_data_id Unique ID for the observed data object.
*/
void SetObservedIndexDataID(int observed_index_data_id) {
interface_observed_index_data_id_m.set(observed_index_data_id);
interface_observed_index_data_id_m = observed_index_data_id;
}

/**
* @brief Set the unique ID for the observed landings data object.
* @param observed_landings_data_id Unique ID for the observed data object.
*/
void SetObservedLandingsDataID(int observed_landings_data_id) {
interface_observed_landings_data_id_m.set(observed_landings_data_id);
interface_observed_landings_data_id_m = observed_landings_data_id;
}
/**
* @brief Set the unique ID for the selectivity object.
* @param selectivity_id Unique ID for the observed object.
*/
void SetSelectivityID(int selectivity_id) {
interface_selectivity_id_m.set(selectivity_id);
interface_selectivity_id_m = selectivity_id;
}

/**
* @brief Get the unique ID for the selectivity object.
*
* @return uint32_t
*/
uint32_t GetSelectivityID() { return interface_selectivity_id_m.get(); }
int GetSelectivityID() { return interface_selectivity_id_m; }

/**
* @brief Get the unique ID for the observed age-composition data object.
*/
int GetObservedAgeCompDataID() {
return interface_observed_agecomp_data_id_m.get();
return interface_observed_agecomp_data_id_m;
}

/**
* @brief Get the unique ID for the observed length-composition data
* object.
*/
int GetObservedLengthCompDataID() {
return interface_observed_lengthcomp_data_id_m.get();
return interface_observed_lengthcomp_data_id_m;
}

/**
* @brief Get the unique id for the observed index data object.
*/
int GetObservedIndexDataID() {
return interface_observed_index_data_id_m.get();
return interface_observed_index_data_id_m;
}

/**
* @brief Get the unique id for the observed landings data object.
*/
int GetObservedLandingsDataID() {
return interface_observed_landings_data_id_m.get();
return interface_observed_landings_data_id_m;
}
/**
* @brief Extracts the derived quantities from `Information` to the Rcpp
Expand Down Expand Up @@ -435,24 +435,24 @@ class FleetInterface : public FleetInterfaceBase {

// set relative info
fleet->id = this->id;
fleet->n_ages = this->n_ages.get();
fleet->n_lengths = this->n_lengths.get();
fleet->n_years = this->n_years.get();
fleet->n_ages = this->n_ages;
fleet->n_lengths = this->n_lengths;
fleet->n_years = this->n_years;
fleet->observed_landings_units = this->observed_landings_units;
fleet->observed_index_units = this->observed_index_units;

fleet->fleet_observed_agecomp_data_id_m =
interface_observed_agecomp_data_id_m.get();
interface_observed_agecomp_data_id_m;

fleet->fleet_observed_lengthcomp_data_id_m =
interface_observed_lengthcomp_data_id_m.get();
interface_observed_lengthcomp_data_id_m;

fleet->fleet_observed_index_data_id_m =
interface_observed_index_data_id_m.get();
interface_observed_index_data_id_m;
fleet->fleet_observed_landings_data_id_m =
interface_observed_landings_data_id_m.get();
interface_observed_landings_data_id_m;

fleet->fleet_selectivity_id_m = interface_selectivity_id_m.get();
fleet->fleet_selectivity_id_m = interface_selectivity_id_m;

fleet->log_q.resize(this->log_q.size());
for (size_t i = 0; i < this->log_q.size(); i++) {
Expand All @@ -472,16 +472,16 @@ class FleetInterface : public FleetInterfaceBase {
}
}

if (this->log_Fmort.size() != static_cast<size_t>(this->n_years.get())) {
if (this->log_Fmort.size() != static_cast<size_t>(this->n_years)) {
FIMS_ERROR_LOG("The size of `log_Fmort` does not match `n_years`: " +
fims::to_string(this->log_Fmort.size()) +
" != " + fims::to_string(this->n_years.get()));
" != " + fims::to_string(this->n_years));
throw std::invalid_argument(
"Fleet log_Fmort size mismatch."
"Fleet log_Fmort is of size " +
fims::to_string(this->log_Fmort.size()) +
" and the number of years is " +
fims::to_string(this->n_years.get()));
fims::to_string(this->n_years));
}
fleet->log_Fmort.resize(static_cast<size_t>(this->log_Fmort.size()));
for (size_t i = 0; i < log_Fmort.size(); i++) {
Expand All @@ -503,16 +503,16 @@ class FleetInterface : public FleetInterfaceBase {
// add to variable_map
info->variable_map[this->log_Fmort.id_m] = &(fleet)->log_Fmort;

if (this->n_lengths.get() > 0) {
if (this->n_lengths > 0) {
fleet->age_to_length_conversion.resize(
this->age_to_length_conversion.size());

if (this->age_to_length_conversion.size() !=
static_cast<size_t>(this->n_ages.get() * this->n_lengths.get())) {
static_cast<size_t>(this->n_ages * this->n_lengths)) {
FIMS_ERROR_LOG(
"age_to_length_conversion don't match, " +
fims::to_string(this->age_to_length_conversion.size()) + " != " +
fims::to_string((this->n_ages.get() * this->n_lengths.get())));
fims::to_string((this->n_ages * this->n_lengths)));
}

for (size_t i = 0; i < fleet->age_to_length_conversion.size(); i++) {
Expand Down
Loading
Loading