Skip to content

Commit

Permalink
hockeystick.hcr recovers previous TAC
Browse files Browse the repository at this point in the history
  • Loading branch information
iagomosqueira committed Jan 24, 2024
1 parent 35a66ab commit 0611324
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mse
Title: Tools for Running Management Strategy Evaluations using FLR
Version: 2.2.3.9246
Version: 2.2.3.9248
Authors@R: c(person(given = "Iago", family = "Mosqueira",
role = c("aut", "cre"), email = "[email protected]"),
person("Ernesto", "Jardim", email = "[email protected]",
Expand Down
12 changes: 8 additions & 4 deletions R/hcr.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ hockeystick.hcr <- function(stk, ind, lim, trigger, target, min=0, drop=0,

# EXTRACT args
ay <- args$ay
iy <- args$iy
data_lag <- args$data_lag
man_lag <- args$management_lag
frq <- args$frq
Expand Down Expand Up @@ -139,10 +140,13 @@ hockeystick.hcr <- function(stk, ind, lim, trigger, target, min=0, drop=0,
track(tracking, "decision.hcr", ay) <- ifelse(met < drop, 0,
ifelse(met <= lim, 1, ifelse(met < trigger, 2, 3)))

# LIMITS over previous output
pre <- unitSums(seasonSums(window(do.call(output, list(stk)),
start=ay - man_lag, end=ay - man_lag)))

# GET TAC dy / ay - 1
if(ay == iy)
pre <- areaSums(unitSums(seasonSums(window(do.call(output, list(stk)),
start=ay - man_lag, end=ay - man_lag))))
else
pre <- c(tracking[[1]]["hcr", ac(ay)])

# IF NA, set to previous value
if(any(is.na(out))) {
out[is.na(out)] <- pre[is.na(out)]
Expand Down
2 changes: 1 addition & 1 deletion R/mp.R
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ setMethod("goFish", signature(om="FLombf"),
# BUG: DROP getCtrl
ctrl <- getCtrl(yearMeans(fbar(stk0)[,sqy]), "f", ay + args$management_lag, it)
}

track(tracking, "hcr", mys) <- ctrl

#----------------------------------------------------------
Expand Down

0 comments on commit 0611324

Please sign in to comment.