diff --git a/R/MP_3c_HCR_ICES_MSY.R b/R/MP_3c_HCR_ICES_MSY.R index f0acbb1..4e61bd5 100644 --- a/R/MP_3c_HCR_ICES_MSY.R +++ b/R/MP_3c_HCR_ICES_MSY.R @@ -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)){ @@ -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) @@ -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) diff --git a/R/OM_1b_Population_Growth_Functions_ASPG_DDW.R b/R/OM_1b_Population_Growth_Functions_ASPG_DDW.R new file mode 100644 index 0000000..209b343 --- /dev/null +++ b/R/OM_1b_Population_Growth_Functions_ASPG_DDW.R @@ -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) +} + + diff --git a/R/OM_2b_Update_catch.R b/R/OM_2b_Update_catch.R index d4316f0..d155a01 100644 --- a/R/OM_2b_Update_catch.R +++ b/R/OM_2b_Update_catch.R @@ -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) diff --git a/src/FLBEIA.dll b/src/FLBEIA.dll index d95d1f7..f17fd61 100644 Binary files a/src/FLBEIA.dll and b/src/FLBEIA.dll differ