Skip to content

Commit

Permalink
Added segregDa, testing
Browse files Browse the repository at this point in the history
  • Loading branch information
iagomosqueira committed Dec 9, 2024
1 parent 84268b3 commit e5c5b29
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Description: Projection of future population and fishery dynamics is carried
(fleet) that will result in the required abundances, catches or fishing
mortalities.
X-schema.org-keywords: forecast, fisheries, flr, R
Version: 0.7.1.9221
Version: 0.7.1.9223
Authors@R: c(
person(given = 'Iago', family = 'Mosqueira', role = c('aut', 'cre'),
email = '[email protected]'),
Expand All @@ -26,7 +26,7 @@ Imports:
LinkingTo: Rcpp
SystemRequirements: C++11
Byarch: false
Additional_repositories: http://flr-project.org/R
Additional_repositories: https://flr.r-universe.dev
Suggests:
testthat,
knitr,
Expand Down
7 changes: 4 additions & 3 deletions R/fwd.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ setMethod("fwd", signature(object="FLBiols", fishery="FLFisheries",
control="fwdControl"),
function(object, fishery, control, effort_max=rep(100, length(fishery)),
deviances=residuals, residuals=lapply(lapply(object, spwn),
"[<-", value=1)) {
"[<-", value=1), verbose=FALSE) {

# CHECK valid fwdControl
if(!validObject(control))
Expand Down Expand Up @@ -301,8 +301,9 @@ setMethod("fwd", signature(object="FLBiols", fishery="FLFisheries",

ids <- which(out$solver_codes != 1, arr.ind=TRUE)

warning(paste("Unsolved targets at control rows: ",
paste(unique(ids[,"row"]), collapse=", ")))
if(verbose)
warning(paste("Unsolved targets at control rows: ",
paste(unique(ids[,"row"]), collapse=", ")))
}

# STRUCTURE of out
Expand Down
3 changes: 3 additions & 0 deletions inst/include/fwdSR.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ T cushing(const T srp, const std::vector<double> params);
template <typename T>
T segreg(const T srp, const std::vector<double> params);

template <typename T>
T segregDa(const T srp, const std::vector<double> params);

template <typename T>
T survsrr(const T srp, const std::vector<double> params);

Expand Down
17 changes: 17 additions & 0 deletions src/fwdSR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void fwdSR_base<T>::init_model_map(){
map_model_name_to_function["cushing"] = &cushing;
map_model_name_to_function["Cushing"] = &cushing;
map_model_name_to_function["Segreg"] = &segreg;
map_model_name_to_function["segregDa"] = &segregDa;
map_model_name_to_function["SegregDa"] = &segregDa;
map_model_name_to_function["segreg"] = &segreg;
map_model_name_to_function["survSRR"] = &survsrr;
map_model_name_to_function["survsrr"] = &survsrr;
Expand Down Expand Up @@ -499,6 +501,21 @@ T segreg(const T srp, const std::vector<double> params){
return rec;
}

template <typename T>
T segregDa(const T srp, const std::vector<double> params){
T rec;
// rec = if(ssb < b) a * ssb else a * b
if(pow(srp, params[2]) <= params[1]) {
rec = params[0] * pow(srp, params[2]);
}
else {
rec = params[0] * params[1];
}
return rec;
}



template <typename T>
T survsrr(const T ssf, const std::vector<double> params){
T rec;
Expand Down
2 changes: 1 addition & 1 deletion src/operating_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ std::vector<adouble> operatingModel::calc_rec(const unsigned int biol_no, const
* Calculate the instantaneous fishing mortality
* This method is the workhorse fishing mortality method that is called by other fishing mortality methods that do make checks.
* F = effort * selectivity * catchability.
* F = effort * selectivity * alpha * biomass ^ -beta
* F = effort %*% selectivity * alpha * biomass ^ -beta
* Selectivity and biomass are disaggregated across all the FLQ dimensions (biomass has length 1 in the quant dimension), i.e. they will have seasons and units.
* Effort always has length 1 in the unit and quant dimension and is disaggregated across other dimensions.
* The catchability parameters can be disaggreated across dimensions 2 to 6. If not, they are recycled.
Expand Down

0 comments on commit e5c5b29

Please sign in to comment.