Skip to content

Commit

Permalink
new argument to IcesMSY & Densodependece in ASPG_DDW
Browse files Browse the repository at this point in the history
- Optional Ftarget above MSY Btrigger
- Densodependece in growth
  • Loading branch information
dorleta committed Jan 8, 2024
1 parent 22bcc8c commit 2b6b6bc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/MP_3c_HCR_ICES_MSY.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ IcesHCR <- function(stocks, advice, advice.ctrl, year, stknm,...){
stk@discards <- computeDiscards(stk)

ageStruct <- ifelse(dim(stk@m)[1] > 1, TRUE, FALSE)



if(ageStruct == TRUE){
if(any(stk@catch[,tail(dimnames(stk@catch)$year,3)]<1e-2)){
Expand All @@ -57,7 +59,9 @@ IcesHCR <- function(stocks, advice, advice.ctrl, year, stknm,...){

ref.pts <- advice.ctrl[[stknm]]$ref.pts # matrix[3,it] rows = Blim, Btrigger, Fmsy
Cadv <- ifelse(advice.ctrl[[stknm]][['AdvCatch']][year+1] == TRUE, 'catch', 'landings')

target <- advice.ctrl[[stknm]]$target # Target when the biomass is above MSY BTrigger, it can be Fupp or Fmsy, or other target in the reference points


iter <- dim(stk@m)[6]
yrsnames <- dimnames(stk@m)[[2]]
yrsnumbs <- as.numeric(yrsnames)
Expand Down Expand Up @@ -186,7 +190,7 @@ IcesHCR <- function(stocks, advice, advice.ctrl, year, stknm,...){
# Find where the SSB (Age structured) OR Biomass (Aggregated) in relation to reference points.
b.pos <- findInterval(b.datyr, ref.pts[c('Blim', 'Btrigger'),i]) # [1]

Ftg <- ifelse(b.pos == 0, 0, ifelse(b.pos == 1, ref.pts['Fmsy',i]*b.datyr/ref.pts[ 'Btrigger',i], ref.pts['Fmsy',i]))
Ftg <- ifelse(b.pos == 0, 0, ifelse(b.pos == 1, ref.pts['Fmsy',i]*b.datyr/ref.pts[ 'Btrigger',i], ref.pts[target,i]))

print(Ftg)

Expand Down
27 changes: 27 additions & 0 deletions R/OM_1b_Population_Growth_Functions_ASPG_DDW.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Age structured population growth with densodependence
ASPG_DDW <- function(biols, SRs, fleets, year, season, stknm, biols.ctrl,...){

# update wt of stknm
ddw.model <- biols.ctrl[[stkm]][['DDW.model']]
lfd <- biols.ctrl[[stkm]][['LFD']]
a <- biols.ctrl[[stkm]][['a.lw']]
lbins <- as.numeric(colNames(lfd))

B <- quantSums((biols[[stkm]]@wt*biols[[stkm]]@n)[,year-1])[drop=T]

condF <- predict(LW_lm, data.frame(biomass = B))

wy <- a*(lbins)^condF

wt <- rowSums(sweep(lfd, 2, wy, "*"))

biols[[stkm]]@wt[,year] <- wt

# use normal ASPG to project the population

res <- ASPG(biols, SRs, fleets, year, season, stknm, biols.ctrl,...)

return(res)
}


2 changes: 2 additions & 0 deletions R/OM_2b_Update_catch.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ BioPop.CAA <- function(fleets, biols, BDs, biols.ctrl, fleets.ctrl, advice, adv
#-------------------------------------------------------------------------------
AgePop.CAA <- function(fleets, biols, BDs, biols.ctrl, fleets.ctrl, advice, advice.ctrl, year = 1, season = 1, flnm = 1, stknm = 1,...){

# if(flnm == 'OT_WHB_-9') browser()

rho <- fleets.ctrl[['catch.threshold']][stknm,year,, season,drop=T] # [it]

nf <- length(fleets)
Expand Down
Binary file modified src/FLBEIA.dll
Binary file not shown.

0 comments on commit 2b6b6bc

Please sign in to comment.