Title: | Projection and Forecasting of Fish Populations, Stocks and Fleets |
---|---|
Description: | Projection of future population and fishery dynamics is carried out for a given set of management targets. A system of equations is solved, using Automatic Differentation (AD), for the levels of effort by fishery (fleet) that will result in the required abundances, catches or fishing mortalities. |
Authors: | Iago Mosqueira [aut, cre], Finlay Scott [aut] |
Maintainer: | Iago Mosqueira <[email protected]> |
License: | EUPL |
Version: | 0.7.1.9221 |
Built: | 2024-11-11 05:01:21 UTC |
Source: | https://github.com/flr/FLasher |
We're Pastie to be Grill You
## S4 method for signature 'fwdControl,ANY,ANY,ANY' x[i, j] ## S4 replacement method for signature 'fwdControl,ANY,ANY,vector' x[i, j, k, ...] <- value ## S4 replacement method for signature 'fwdControl,ANY,ANY,ANY' x[i, j, k, ...] <- value ## S4 method for signature 'fwdControl' x$name ## S4 replacement method for signature 'fwdControl,vector' x$name <- value ## S4 replacement method for signature 'fwdControl,AsIs' x$name <- value
## S4 method for signature 'fwdControl,ANY,ANY,ANY' x[i, j] ## S4 replacement method for signature 'fwdControl,ANY,ANY,vector' x[i, j, k, ...] <- value ## S4 replacement method for signature 'fwdControl,ANY,ANY,ANY' x[i, j, k, ...] <- value ## S4 method for signature 'fwdControl' x$name ## S4 replacement method for signature 'fwdControl,vector' x$name <- value ## S4 replacement method for signature 'fwdControl,AsIs' x$name <- value
x |
A fwdControl object |
i |
Row of both target and iters |
j |
Third dimenions of iters |
k |
The replacement. |
... |
Some things. |
value |
Replacement value |
name |
Column name of target or value column of iters. |
Add the order column to the control target data.frame so that targets are processed in the correct order.
add_target_order_fls(control)
add_target_order_fls(control)
control |
A fwdControl object |
It is important that the targets in the control object are processed in the correct order. Targets can happen simultaneously. For example, if there are multiple FLFishery objects in operating model each will need to have a target to solve for at the same time as the others. The targets are processed in a time ordered sequence (year / season). However, within the same year and season it is necessary for the min and max targets to be processed separatley and after the other targets.
A fwdControl object with an order column.
Look up and see the flying saucers cruising in the sky I saw one myself it ain't no lie Look down and see the road you're on as if you are on a marathon That's the spirit, victory or die
height of box
width of box
x coordinate of centre of box
y coordinate of centre of box
text to go in the box
size of text to go in the box
Finlay Scott - EC JRC.
A class for drawing a biological stock
height of box
width of box
x coordinate of centre of box
y coordinate of centre of box
text to go in the box
size of text to go in the box
neck length
size of the circle bit
Finlay Scott - EC JRC.
An FLBiols object with two FLBiol objects, one for plaice and one for sole. These are used in the mixed fishery example vignette.
An FLFisheries object with two FLFishery objects, a beam trawl and a gill netter. These are used in the mixed fishery example vignette.
biols flfs
biols flfs
An FLBiols object with two FLBiol objects.
An FLFisheries object with two FLFishery objects.
Calculate F in the same way as the internal C++ does
calc_F(catch, biol, effort)
calc_F(catch, biol, effort)
catch |
The FLCatch |
biol |
The FLBiol |
effort |
The fishing effort |
A class for drawing a catch
height of box
width of box
x coordinate of centre of box
y coordinate of centre of box
text to go in the box
size of text to go in the box
tail length
Finlay Scott - EC JRC.
A call to as(from, 'to') will coerce the object from, of a certain class, to one of class to, as specified in the method.
from |
Object to be coerced into one of another class. |
to |
Name of the output class, character. |
An object of class FLQuants can be coerced into a fwdControl, through a call to as.data.frame. The name of the element, or elements, in the object specifies the 'quant' in fwdControl. The 'quant' in the FLQuant object, the name of the first dimension, is ignored unles is one of 'min', 'value' or 'max'. See the examples below on how to pass one or more FLQuant objects to fwd.
An object of the requested class.
Iago Mosqueira. EC JRC.
# Single *catch* target as(FLQuants(catch=FLQuant(4500, dimnames=list(year=2000))), "fwdControl") # Single single *f* range as(FLQuants(f=FLQuant(c(0.1, 0.9), dimnames=list(quant=c("min", "max"), year=2000))), 'fwdControl') # Single *f* target, *value* specified as(FLQuants(f=FLQuant(0.5, dimnames=list(quant=c("value"), year=2000))), 'fwdControl') # *catch* and *ssb* targets as(FLQuants(catch=FLQuant(4500, dimnames=list(year=2000)), ssb_end=FLQuant(12000, dimnames=list(year=2000))), "fwdControl") # *f* target and *catch* limits as(FLQuants(f=FLQuant(0.5, dimnames=list(year=2000)), catch=FLQuant(c(100, 4000), dimnames=list(quant=c("min", "max"), year=2000))), 'fwdControl') # *f* target and *catch* minimum as(FLQuants(f=FLQuant(0.5, dimnames=list(year=2000)), catch=FLQuant(c(100), dimnames=list(quant=c("min"), year=2000))), 'fwdControl') # targets with iters as(FLQuants(fbar=propagate(FLQuant(seq(0.1, 0.5, by=0.1), dim=c(1,5)), 10)), "fwdControl") # targets with different iters as(FLQuants(fbar=FLQuant(rep(seq(0.1, 0.5, by=0.1), each=10), dim=c(1,5,1,1,1,10))), "fwdControl")
# Single *catch* target as(FLQuants(catch=FLQuant(4500, dimnames=list(year=2000))), "fwdControl") # Single single *f* range as(FLQuants(f=FLQuant(c(0.1, 0.9), dimnames=list(quant=c("min", "max"), year=2000))), 'fwdControl') # Single *f* target, *value* specified as(FLQuants(f=FLQuant(0.5, dimnames=list(quant=c("value"), year=2000))), 'fwdControl') # *catch* and *ssb* targets as(FLQuants(catch=FLQuant(4500, dimnames=list(year=2000)), ssb_end=FLQuant(12000, dimnames=list(year=2000))), "fwdControl") # *f* target and *catch* limits as(FLQuants(f=FLQuant(0.5, dimnames=list(year=2000)), catch=FLQuant(c(100, 4000), dimnames=list(quant=c("min", "max"), year=2000))), 'fwdControl') # *f* target and *catch* minimum as(FLQuants(f=FLQuant(0.5, dimnames=list(year=2000)), catch=FLQuant(c(100), dimnames=list(quant=c("min"), year=2000))), 'fwdControl') # targets with iters as(FLQuants(fbar=propagate(FLQuant(seq(0.1, 0.5, by=0.1), dim=c(1,5)), 10)), "fwdControl") # targets with different iters as(FLQuants(fbar=FLQuant(rep(seq(0.1, 0.5, by=0.1), each=10), dim=c(1,5,1,1,1,10))), "fwdControl")
fwd()
run with the defined targets.A comparison between the objects or objects returned by fwd()
and the
targets and limits set in the fwdControl
object used to run, is returned
by this method.
## S4 method for signature 'FLStock,fwdControl' compare(result, target, simplify = FALSE) ## S4 method for signature 'fwdControl,FLStock' compare(result, target) ## S4 method for signature 'FLBiol,fwdControl' compare(result, target, fishery, simplify = FALSE)
## S4 method for signature 'FLStock,fwdControl' compare(result, target, simplify = FALSE) ## S4 method for signature 'fwdControl,FLStock' compare(result, target) ## S4 method for signature 'FLBiol,fwdControl' compare(result, target, fishery, simplify = FALSE)
result |
Object returned by the call to fwd() |
target |
fwdControl object with required targets |
simplify |
Return whole table or logical vector only, logical |
fishery |
FLFishery oir FKFisheries object |
A comparison is carried out for each row in a fwdControl
object,
that is, for every target or limit.
A data.frame
is returned with columns 'year', 'quant', 'season' and
'unit' if relevant, and 'achieved'. The last is of class logical
and will
have value TRUE
if the target or limits have been achieved for every
iteration, and FALSE
otherwise.
Values are compared using all.equal
.
A table of comparisons, one for each target, of class data.frame.
Iago Mosqueira (WMR)
data(ple4) control <- fwdControl( list(quant="fbar", value=0.5, year=1990), list(quant="catch", value=1, year=1991, relYear=1990), list(quant="catch", min=10000, year=1993, max=100000)) run <- fwd(ple4, sr=predictModel(model=rec~a*ssb*exp(-b*ssb), params=FLPar(a=9.16, b=3.55e-6)), control=control) # Returns the full comparison table compare(run, control) # Returns a logical vector compare(run, control, simplify=TRUE)
data(ple4) control <- fwdControl( list(quant="fbar", value=0.5, year=1990), list(quant="catch", value=1, year=1991, relYear=1990), list(quant="catch", min=10000, year=1993, max=100000)) run <- fwd(ple4, sr=predictModel(model=rec~a*ssb*exp(-b*ssb), params=FLPar(a=9.16, b=3.55e-6)), control=control) # Returns the full comparison table compare(run, control) # Returns a logical vector compare(run, control, simplify=TRUE)
Used to draw individual components or the whole FCB matrix
draw(object, ...) ## S4 method for signature 'basicBlock' draw(object) ## S4 method for signature 'biolBlock' draw(object) ## S4 method for signature 'fisheryBlock' draw(object) ## S4 method for signature 'catchBlock' draw(object) ## S4 method for signature 'FCBDrawing' draw(object) ## S4 method for signature 'matrix' draw(object, fisheryNames = NULL, catchNames = NULL, biolNames = NULL) ## S4 method for signature 'fwdControl' draw(object, fisheryNames = NULL, catchNames = NULL, biolNames = NULL)
draw(object, ...) ## S4 method for signature 'basicBlock' draw(object) ## S4 method for signature 'biolBlock' draw(object) ## S4 method for signature 'fisheryBlock' draw(object) ## S4 method for signature 'catchBlock' draw(object) ## S4 method for signature 'FCBDrawing' draw(object) ## S4 method for signature 'matrix' draw(object, fisheryNames = NULL, catchNames = NULL, biolNames = NULL) ## S4 method for signature 'fwdControl' draw(object, fisheryNames = NULL, catchNames = NULL, biolNames = NULL)
object |
The object - linkbasicBlock, linkbiolBlock, linkfisheryBlock, linkcatchBlock, linkmatrix, linkFCBDrawing |
... |
Other arguments |
fisheryNames |
A vector of names of the FLFishery blocks |
catchNames |
A vector of names of the FLCatch blocks |
biolNames |
A vector of names of the FLBiol blocks |
Nothing. Just draws something
FCB <- matrix(c(1,1,1,1,2,2,2,1,2,2,2,3,2,2,4), nrow=5, byrow=TRUE) draw(FCB)
FCB <- matrix(c(1,1,1,1,2,2,2,1,2,2,2,3,2,2,4), nrow=5, byrow=TRUE) draw(FCB)
The FCB slot in fwdControl specifies the relationships between the catches ('C') taken by each fishery ('F') from different biological units ('B').
FCB(object, ...) <- value ## S4 method for signature 'fwdControl' FCB(object) ## S4 replacement method for signature 'fwdControl,matrix' FCB(object) <- value
FCB(object, ...) <- value ## S4 method for signature 'fwdControl' FCB(object) ## S4 replacement method for signature 'fwdControl,matrix' FCB(object) <- value
object |
Input object to construct or extract from. |
... |
Extract input arguments |
value |
Input matrix |
This slot is of class *matrix* and has thre columns, named 'F', 'C' and 'B', and as many rows as relationships between the FLBiol(s) and FLFishery(ies) objects the fwdControl refers to.
control <- fwdControl() # Access FCB slot FCB(control) # Assign to existing fwdControl FCB(control) <- FCB(c(f=1, c=1, b=2), c(f=1, c=2, b=2))
control <- fwdControl() # Access FCB slot FCB(control) # Assign to existing fwdControl FCB(control) <- FCB(c(f=1, c=1, b=2), c(f=1, c=2, b=2))
Has to figure out the height, width and positions of the FCB components
FCBDrawing(FCB, ...) ## S4 method for signature 'matrix' FCBDrawing(FCB, fisheryNames = NULL, catchNames = NULL, biolNames = NULL)
FCBDrawing(FCB, ...) ## S4 method for signature 'matrix' FCBDrawing(FCB, fisheryNames = NULL, catchNames = NULL, biolNames = NULL)
FCB |
The (FCB matrix) |
... |
Other arguments |
fisheryNames |
A vector of names of the FLFishery blocks |
catchNames |
A vector of names of the FLCatch blocks |
biolNames |
A vector of names of the FLBiol blocks |
An FCBDrawing object
A list of biolBlocks
A list of fisheryBlocks
A list of catchBlocks
A list of coordinates connecting catches and biols
The FCB matrix
Finlay Scott - EC JRC.
Fill the character slots (name etc) with something.
fillchar(object) ## S4 method for signature 'FLFisheries' fillchar(object) ## S4 method for signature 'FLBiols' fillchar(object)
fillchar(object) ## S4 method for signature 'FLFisheries' fillchar(object) ## S4 method for signature 'FLBiols' fillchar(object)
object |
The object (FLFisheries or FLBiols) |
A class for drawing a fishery
height of box
width of box
x coordinate of centre of box
y coordinate of centre of box
text to go in the box
size of text to go in the box
neck length
number of catches
space between catches
tail length
Finlay Scott - EC JRC.
fwd() projects the fishery through time and attempts to hit the specified targets by finding the appropriate fishing effort.
## S4 method for signature 'FLBiols,FLFisheries,fwdControl' fwd( object, fishery, control, effort_max = rep(100, length(fishery)), deviances = residuals, residuals = lapply(lapply(object, spwn), "[<-", value = 1) ) ## S4 method for signature 'FLBiols,FLFishery,fwdControl' fwd(object, fishery, control, ...) ## S4 method for signature 'FLBiol,FLFisheries,fwdControl' fwd(object, fishery, control, deviances = "missing", ...) ## S4 method for signature 'FLBiol,FLFishery,fwdControl' fwd( object, fishery, control, deviances = residuals, residuals = FLQuant(1, dimnames = dimnames(rec(object))), ... ) ## S4 method for signature 'FLBiol,FLFishery,missing' fwd( object, fishery, ..., effort_max = 10, deviances = residuals, residuals = FLQuant(1, dimnames = dimnames(m(object))) ) ## S4 method for signature 'FLStock,missing,fwdControl' fwd( object, control, sr, maxF = 4, deviances = residuals, residuals = FLQuant(1, dimnames = dimnames(rec(object))), effort_max = 100, ... ) ## S4 method for signature 'FLStock,ANY,missing' fwd( object, fishery = missing, sr, maxF = 4, deviances = residuals, residuals = FLQuant(1, dimnames = dimnames(rec(object))), ... )
## S4 method for signature 'FLBiols,FLFisheries,fwdControl' fwd( object, fishery, control, effort_max = rep(100, length(fishery)), deviances = residuals, residuals = lapply(lapply(object, spwn), "[<-", value = 1) ) ## S4 method for signature 'FLBiols,FLFishery,fwdControl' fwd(object, fishery, control, ...) ## S4 method for signature 'FLBiol,FLFisheries,fwdControl' fwd(object, fishery, control, deviances = "missing", ...) ## S4 method for signature 'FLBiol,FLFishery,fwdControl' fwd( object, fishery, control, deviances = residuals, residuals = FLQuant(1, dimnames = dimnames(rec(object))), ... ) ## S4 method for signature 'FLBiol,FLFishery,missing' fwd( object, fishery, ..., effort_max = 10, deviances = residuals, residuals = FLQuant(1, dimnames = dimnames(m(object))) ) ## S4 method for signature 'FLStock,missing,fwdControl' fwd( object, control, sr, maxF = 4, deviances = residuals, residuals = FLQuant(1, dimnames = dimnames(rec(object))), effort_max = 100, ... ) ## S4 method for signature 'FLStock,ANY,missing' fwd( object, fishery = missing, sr, maxF = 4, deviances = residuals, residuals = FLQuant(1, dimnames = dimnames(rec(object))), ... )
object |
An FLStock, an FLBiol or an FLBiols object. |
fishery |
If object is an FLBiol(s), a FLFishery(ies). Else this argument is ignored. |
control |
A fwdControl object. |
effort_max |
Sets a maximum effort limit by fishery as a multiplier over the maximum observed effort. |
deviances |
An FLQuant of deviances for the stock recruitment relationship (if object is an FLStock). |
residuals |
Old argument name for deviances, to be deleted |
... |
Stormbending. |
sr |
a predictModel, FLSR or list that describes the stock recruitment relationship (if object is an FLStock). Also an FLQuant with actual recruitment values. |
maxF |
Maximum yearly fishing mortality, when called on an FLStock object. |
A projection is run on either an FLStock object (for a single species, single fishery projection), or a pair of FLBiol(s) and FLFishery(ies) objects (for more advanced mixed fisheries projections).
The projection is controlled by the fwdControl object (although it is also possible to control the projection of an FLStock using a different interface). In each timestep of the projection, the fishing effort of each FLFishery (or the equivalent F multiplier if object is an FLStock) is found so that the targets specified in the fwdControl object are hit.
For more details and examples, see the vignettes in the package and also the tutorial at: http://www.flr-project.org/doc/Forecasting_on_the_Medium_Term_for_advice_using_FLasher.html
Either an FLStock, or a list of FLFishery and FLBiol objects.
The FLR Team
data(ple4) # Hindcast with past rec and fbar hinf <- fwd(ple4, sr=rec(ple4)[, ac(1980:2017)], control=fwdControl(year=1980:2017, value=fbar(ple4)[, ac(1980:2017)], quant="fbar")) plot(FLStocks(PLE=ple4, FWD=hinf)) #' Hindcast with past rec and catch hind <- fwd(ple4, sr=rec(ple4)[, ac(1980:2017)], catch=catch(ple4)[, ac(1980:2017)])
data(ple4) # Hindcast with past rec and fbar hinf <- fwd(ple4, sr=rec(ple4)[, ac(1980:2017)], control=fwdControl(year=1980:2017, value=fbar(ple4)[, ac(1980:2017)], quant="fbar")) plot(FLStocks(PLE=ple4, FWD=hinf)) #' Hindcast with past rec and catch hind <- fwd(ple4, sr=rec(ple4)[, ac(1980:2017)], catch=catch(ple4)[, ac(1980:2017)])
The desired targets, limits and time steps used in fishery projections can be
specified by creating an object of class fwdControl
.
Constructor for fwdControl objects. Bare bones man pages. Better to look at the vignettes and tutorials.
fwdControl(target, iters, ...) G(...) ## S4 method for signature 'data.frame,array' fwdControl(target, iters, ...) ## S4 method for signature 'data.frame,numeric' fwdControl(target, iters, ...) ## S4 method for signature 'data.frame,missing' fwdControl(target, iters, ...) ## S4 method for signature 'list,missing' fwdControl(target, iters, ...) ## S4 method for signature 'list,list' fwdControl(target, iters, ...) ## S4 method for signature 'missing,missing' fwdControl(target, iters, ...) ## S4 method for signature 'FLQuant,missing' fwdControl(target, quant, ...)
fwdControl(target, iters, ...) G(...) ## S4 method for signature 'data.frame,array' fwdControl(target, iters, ...) ## S4 method for signature 'data.frame,numeric' fwdControl(target, iters, ...) ## S4 method for signature 'data.frame,missing' fwdControl(target, iters, ...) ## S4 method for signature 'list,missing' fwdControl(target, iters, ...) ## S4 method for signature 'list,list' fwdControl(target, iters, ...) ## S4 method for signature 'missing,missing' fwdControl(target, iters, ...) ## S4 method for signature 'FLQuant,missing' fwdControl(target, quant, ...)
target |
The target. Can be a data.frame, a list or missing. |
iters |
target The iters. Can be an array, a numeric or missing. |
... |
Something |
quant |
name of target to assign 'FLQuant' to, 'character' |
target
The table of quantities and time steps used as target, data.frame.
iters
The values and limits for each target quantity and time step, array.
FCB
The matrix describing which FLCatch of which FLFishery catches which FLBiol. A matrix with 3 columns: F, C, and B.
Neque porro quisquam est qui dolorem ipsum.
All slots in the class have accessor and replacement methods defined that allow retrieving and substituting individual slots.
The values passed for replacement need to be of the class of that slot. A numeric vector can also be used when replacing FLQuant slots, and the vector will be used to substitute the values in the slot, but not its other attributes.
A construction method exists for this class that can take named arguments for
any of its slots. All slots are then created to match the requirements of the
class validity. If an unnamed FLQuant
object is provided, this is used
for sizing but not stored in any slot.
Iago Mosqueira, Finlay Scott - EC JRC.
# CREATE targets on fishing mortality ('f') by year target <- data.frame(year=2000:2010, value=rlnorm(11), quant='f') fwc <- fwdControl(target=target) # INSPECT fwdControl object show(fwc) # Construct from data.frame and array fcn <- fwdControl(data.frame(year=2000:2005, quant='f', value=0.5)) # Construct a fwdControl with some targets having multiple Biols, specified using the G() function fwdControl(list(year=2000:2001, value=200, quant="catch", biol=G(1,2)), list(year=2002:2003, value=100, quant="catch", biol=c(1,2))) # Vector of values by year fwdControl(data.frame(year=2010:2015, quant="f", value=seq(1, 1.3, length=6))) # Two targets, with ranges for one fwdControl(data.frame(year=rep(2010:2015, each=2), quant=c("f", "catch"), min=c(rbind(NA, 20000)), max=c(rbind(NA, 30000)), value=c(rbind(seq(1, 1.3, length=6), NA)))) # Single target value fwdControl(list(year=2010:2014, quant='catch', value=2900)) # One value per target (year) fwdControl(list(year=2010:2014, quant='catch', value=seq(2900, 3500, length=5))) # With 40 values (iters) in each target fwdControl(list(year=2010:2014, quant='catch', value=rnorm(200, seq(2900, 3500, length=5)))) # lapply can be used to constructs a list fwdControl(lapply(2005:2020, function(x) list(quant="catch", value=runif(1, 1e5, 1e6), year=x))) fwdControl(lapply(2005, function(x) list(quant="catch", value=runif(1, 1e5, 1e6), year=x))) # FLQuant, needs 'quant' name fwdControl(FLQuant(0.2, dimnames=list(year=2000)), quant="fbar")
# CREATE targets on fishing mortality ('f') by year target <- data.frame(year=2000:2010, value=rlnorm(11), quant='f') fwc <- fwdControl(target=target) # INSPECT fwdControl object show(fwc) # Construct from data.frame and array fcn <- fwdControl(data.frame(year=2000:2005, quant='f', value=0.5)) # Construct a fwdControl with some targets having multiple Biols, specified using the G() function fwdControl(list(year=2000:2001, value=200, quant="catch", biol=G(1,2)), list(year=2002:2003, value=100, quant="catch", biol=c(1,2))) # Vector of values by year fwdControl(data.frame(year=2010:2015, quant="f", value=seq(1, 1.3, length=6))) # Two targets, with ranges for one fwdControl(data.frame(year=rep(2010:2015, each=2), quant=c("f", "catch"), min=c(rbind(NA, 20000)), max=c(rbind(NA, 30000)), value=c(rbind(seq(1, 1.3, length=6), NA)))) # Single target value fwdControl(list(year=2010:2014, quant='catch', value=2900)) # One value per target (year) fwdControl(list(year=2010:2014, quant='catch', value=seq(2900, 3500, length=5))) # With 40 values (iters) in each target fwdControl(list(year=2010:2014, quant='catch', value=rnorm(200, seq(2900, 3500, length=5)))) # lapply can be used to constructs a list fwdControl(lapply(2005:2020, function(x) list(quant="catch", value=runif(1, 1e5, 1e6), year=x))) fwdControl(lapply(2005, function(x) list(quant="catch", value=runif(1, 1e5, 1e6), year=x))) # FLQuant, needs 'quant' name fwdControl(FLQuant(0.2, dimnames=list(year=2000)), quant="fbar")
Given an FLQuant and the indices, returns the 1D element accessor.
get_FLQuant_element(flq, indices)
get_FLQuant_element(flq, indices)
flq |
The FLQuant |
indices |
The indices (integer vector, length 6) |
Given an FLQuant and the indices range, returns the vector of indices
get_FLQuant_elements(flq, indices_min, indices_max)
get_FLQuant_elements(flq, indices_min, indices_max)
flq |
The FLQuant |
indices_min |
The min indices (integer vector, length 6) |
indices_max |
The max indices (integer vector, length 6) |
Make the plug in for inline Cxx
inlineCxxPlugin(...)
inlineCxxPlugin(...)
... |
I have no idea. |
Access and replace the iters slot of the fwdControl
Access the iters slot of the fwdControl
Set the iters slot of the fwdControl
iters(object, ...) <- value ## S4 method for signature 'fwdControl' iters(object) ## S4 replacement method for signature 'fwdControl,array' iters(object) <- value
iters(object, ...) <- value ## S4 method for signature 'fwdControl' iters(object) ## S4 replacement method for signature 'fwdControl,array' iters(object) <- value
object |
The fwdControl. |
... |
Other things. |
value |
The iters array to replace the existing one with. |
Number of fisheries, catches and biols are taken from the FCB argument.
make_test_operatingModel( fls, FCB, nseasons = 1, recruitment_seasons = 1, recruitment_age = 1, niters = 1000, sd = 0.1 )
make_test_operatingModel( fls, FCB, nseasons = 1, recruitment_seasons = 1, recruitment_age = 1, niters = 1000, sd = 0.1 )
fls |
The FLStock that the OM is based on |
FCB |
The FCB matrix |
nseasons |
The number of seasons |
recruitment_seasons |
A vector of seasons in which recruitment occurs (1 - 4) |
recruitment_age |
The age of recruitment to the fishery |
niters |
The number of iterations. |
sd |
The standard deviation when applying random lognormal noise to some of the slots. |
A list of objects for sending to C++
Change names of biols, catches and fisheries in the control object into integer positions
match_posns_names(trg, biol_names, fishery_catch_names)
match_posns_names(trg, biol_names, fishery_catch_names)
trg |
The target slot of a fwdControl object |
biol_names |
A vector of names in the FLBiols objects |
fishery_catch_names |
A named list - elements of list are vector of the catch names of each fishery |
Before calling the C++ code it is necessary for the catch, fishery and biol columns (and their Rel) equivalents to be integers. The user can specify by name. This function changes the name to integer position and throws an error if the name does not match.
The updated target slot
Call the CPP operatingModel run method
operatingModelRun( flfs, biols, ctrl, effort_max, effort_mult_initial, indep_min, indep_max, nr_iters = 50L )
operatingModelRun( flfs, biols, ctrl, effort_max, effort_mult_initial, indep_min, indep_max, nr_iters = 50L )
flfs |
FLFisheries. |
biols |
List of the Biol bits. |
ctrl |
fwdControl. |
effort_max |
Maximum yearly rate of change in effort for each fishery. |
effort_mult_initial |
Initial effort multiplier. |
indep_min |
Minimum independent solver value. |
indep_max |
Maximum independent solver value. |
nr_iters |
Maximum number of iterations for solver. |
Internal function
parsefwdList(...)
parsefwdList(...)
... |
Things |
Fishing mortalities at age for one of both stock ('FLBiol') are partitioned along the fisheries ('FLFisheries') exploiting them.
partialF(object, fisheries, ...) ## S4 method for signature 'FLBiols,FLFisheries' partialF(object, fisheries, biol = seq(length(object)), fcb = "missing") ## S4 method for signature 'FLBiol,FLFisheries' partialF(object, fisheries, fcb = "missing")
partialF(object, fisheries, ...) ## S4 method for signature 'FLBiols,FLFisheries' partialF(object, fisheries, biol = seq(length(object)), fcb = "missing") ## S4 method for signature 'FLBiol,FLFisheries' partialF(object, fisheries, fcb = "missing")
object |
The exploited population or populations, 'FLBiol' or 'FLBiols'. |
fisheries |
The fisheries exploiting the resource, 'FLFisheries'. |
... |
Any extra argument. |
biol |
Position of the biols or biols to do the calculation for. |
fcb |
FCB matrix of the fishery-catch-biol relationships. |
plot methods that highlight years in fwdControl
plot method for FLStocks, fwdControl
## S4 method for signature 'FLStock,fwdControl' plot(x, y, fill = "#E69F00", ...) ## S4 method for signature 'FLQuant,fwdControl' plot(x, y, fill = "#E69F00", ...) ## S4 method for signature 'FLQuants,fwdControl' plot(x, y, fill = "#E69F00", ...) ## S4 method for signature 'FLStocks,fwdControl' plot(x, y, fill = "#E69F00", ...)
## S4 method for signature 'FLStock,fwdControl' plot(x, y, fill = "#E69F00", ...) ## S4 method for signature 'FLQuant,fwdControl' plot(x, y, fill = "#E69F00", ...) ## S4 method for signature 'FLQuants,fwdControl' plot(x, y, fill = "#E69F00", ...) ## S4 method for signature 'FLStocks,fwdControl' plot(x, y, fill = "#E69F00", ...)
x |
FlStock object to plot |
y |
fwdControl from which to extract year ranges |
fill |
Colour to fill projection years background |
... |
Any other argument to be passed to [ggplotFL::plot] |
plot(x, y)
data(ple4) control <- fwdControl(year=2008:2017, quant="f", value=0.3) # No fwd projection took place, simply passing year range plot(ple4, control) plot(ssb(ple4), control) plot(FLQuants(SSB=ssb(ple4), F=fbar(ple4)), control) data(ple4) control <- fwdControl(year=2008:2017, quant="f", value=0.3) # No fwd projection took place, simply passing year range plot(FLStocks(PLE4=ple4), control)
data(ple4) control <- fwdControl(year=2008:2017, quant="f", value=0.3) # No fwd projection took place, simply passing year range plot(ple4, control) plot(ssb(ple4), control) plot(FLQuants(SSB=ssb(ple4), F=fbar(ple4)), control) data(ple4) control <- fwdControl(year=2008:2017, quant="f", value=0.3) # No fwd projection took place, simply passing year range plot(FLStocks(PLE4=ple4), control)
Change the nuber of iterations in the iter slot of the fwdControl.
## S4 method for signature 'fwdControl' propagate(object, iter, fill.iter = TRUE)
## S4 method for signature 'fwdControl' propagate(object, iter, fill.iter = TRUE)
object |
A fwdControl object. |
iter |
The number of iterations. |
fill.iter |
Fill the new iters with original values (TRUE) or NA (FALSE) |
Generate an FLBiolcpp of random size and filled with normally distributed random numbers with a mean of 0. Used for automatic testing, particularly of the fwdBiol class in CPP.
random_FLBiolcpp_generator(sd = 100, ...)
random_FLBiolcpp_generator(sd = 100, ...)
sd |
The standard deviation of the random numbers. Passed to rnorm() Default is 100. |
... |
Other arguments to pass to random_FLQuant_generator(). |
An FLBiolcpp
flb <- random_FLBiolcpp_generator() summary(flb)
flb <- random_FLBiolcpp_generator() summary(flb)
Generate an FLCatch of random size and filled with normally distributed random numbers with a mean of 0. Used for automatic testing, particularly of the FLCatch class in CPP.
random_FLCatch_generator(sd = 100, ...)
random_FLCatch_generator(sd = 100, ...)
sd |
The standard deviation of the random numbers. Passed to rnorm() Default is 100. |
... |
Other arguments passed to random_FLQuant_generator(). |
An FLCatch
flc <- random_FLCatch_generator() summary(flc)
flc <- random_FLCatch_generator() summary(flc)
Generates a list of identically sized FLCatch objects filled with normally distributed random numbers with a mean of 0. Used for automatic testing, particularly of the FLCatches_base<T> class in CPP.
random_FLCatches_generator(min_catches = 2, max_catches = 5, ...)
random_FLCatches_generator(min_catches = 2, max_catches = 5, ...)
min_catches |
The minimum number of catches. Default is 2. |
max_catches |
The maximum number of catches. Default is 5. |
... |
Other arguments passed to random_FLQuant_generator(). |
An FLCatches objects
flcs <- random_FLCatches_generator() length(flcs) summary(flcs) lapply(flcs, summary)
flcs <- random_FLCatches_generator() length(flcs) summary(flcs) lapply(flcs, summary)
Generate a randomly sized FLFisheries object filled with normally distributed random numbers with a mean of 0. Used for automatic testing, particularly of the FLFisheries_base<T> class in CPP.
random_FLFisheries_generator(min_fisheries = 2, max_fisheries = 5, ...)
random_FLFisheries_generator(min_fisheries = 2, max_fisheries = 5, ...)
min_fisheries |
The minimum number of FLFisheries in the fisheries list. Default is 2. |
max_fisheries |
The maximum number of FLFisheries in the fisheries list. Default is 5. |
... |
Other arguments to pass to random_FLFishery_generator(). |
An FLFishery object
flf <- random_FLFisheries_generator(fixed_dims = c(NA,10,1,1,1,1))
flf <- random_FLFisheries_generator(fixed_dims = c(NA,10,1,1,1,1))
Generate a randomly sized FLFishery object filled with normally distributed random numbers with a mean of 0. Used for automatic testing, particularly of the FLFishery_base<T> class in CPP.
random_FLFishery_generator(min_catches = 2, max_catches = 5, sd = 1, ...)
random_FLFishery_generator(min_catches = 2, max_catches = 5, sd = 1, ...)
min_catches |
The minimum number of catches. Default is 2. |
max_catches |
The maximum number of FLCatches in the catches list. Default is 5. |
sd |
Standard deviation of the randomly generated FLQuant slots. |
... |
Other arguments passed to random_FLCatches_generator(). |
An FLFishery object
flf <- random_FLFishery_generator(fixed_dims = c(NA,10,1,1,1,1)) lapply(flf, summary) flf <- random_FLFishery_generator(fixed_dims = c(NA,10,1,1,1,1), max_dims = c(100,NA,NA,NA,NA,NA))
flf <- random_FLFishery_generator(fixed_dims = c(NA,10,1,1,1,1)) lapply(flf, summary) flf <- random_FLFishery_generator(fixed_dims = c(NA,10,1,1,1,1), max_dims = c(100,NA,NA,NA,NA,NA))
Generate a randomly or fixed sized FLQuant filled with normally distributed random numbers with a mean of 0. Used for automatic testing.
random_FLQuant_generator( fixed_dims = rep(NA, 6), min_dims = rep(1, 6), max_dims = pmax(min_dims, c(5, 10, 5, 4, 4, 5)), min_age_name = 1, sd = 100 )
random_FLQuant_generator( fixed_dims = rep(NA, 6), min_dims = rep(1, 6), max_dims = pmax(min_dims, c(5, 10, 5, 4, 4, 5)), min_age_name = 1, sd = 100 )
fixed_dims |
A vector of length 6 with the fixed length of each of the FLQuant dimensions. If any value is NA it is randomly set using the max_dims argument. Default value is rep(NA,6). |
min_dims |
A vector of length 6 with minimum size of each of the FLQuant dimensions. Default value is c(1,1,1,1,1,1). |
max_dims |
A vector of length 6 with maximum size of each of the FLQuant dimensions. Default value is c(5,10,5,4,4,5). |
min_age_name |
The name of the first age group. |
sd |
The standard deviation of the random numbers. Passed to rnorm() Default is 100. |
An FLQuant
flq <- random_FLQuant_generator() dim(flq) summary(flq) flq <- random_FLQuant_generator(fixed_dims = c(NA,10,1,4,1,NA)) dim(flq) summary(flq)
flq <- random_FLQuant_generator() dim(flq) summary(flq) flq <- random_FLQuant_generator(fixed_dims = c(NA,10,1,4,1,NA)) dim(flq) summary(flq)
Generate a list of FLQuant objects filled with normally distributed random numbers with a mean of 0. FLQuant objects can be randomly sized, depening on arguments passed to random_FLQuant_generator(). Used for automatic testing, particularly of the FLQuant7_base<T> class in CPP.
random_FLQuant_list_generator(min_elements = 1, max_elements = 10, ...)
random_FLQuant_list_generator(min_elements = 1, max_elements = 10, ...)
min_elements |
The minimum number of elements in the list. Default is 1. |
max_elements |
The maximum number of elements in the list. Default is 10. |
... |
Other arguments to pass to random_FLQuant_generator(), e.g. those that fix the size of the objects. |
A list of FLQuant objects
flq_list <- random_FLQuant_list_generator() length(flq_list) summary(flq_list) lapply(flq_list, summary)
flq_list <- random_FLQuant_list_generator() length(flq_list) summary(flq_list) lapply(flq_list, summary)
The fwdBiols constructor takes a list (fwdbiols_list). Each element of fwdbiols_list is a list of: FLBiolcpp, SRR residuals and SRR residuals mult. This function generates randomly filled FLBiolcpp objects. Objects may be of different sizes unless appropriate arguments to random_FLBiolcpp_generator() are specified. Used for automatic testing, particularly of the fwdBiols<T> class in CPP.
random_fwdBiols_list_generator(min_biols = 1, max_biols = 5, ...)
random_fwdBiols_list_generator(min_biols = 1, max_biols = 5, ...)
min_biols |
The minimum number of fwdBiols in the list. Default is 1. |
max_biols |
The maximum number of fwdBiols in the list. Default is 5. |
... |
Other arguments passed to random_FLBiolcpp_generator(). |
A list object
fwdBiols <- random_fwdBiols_list_generator()
fwdBiols <- random_fwdBiols_list_generator()
Creates a random fwdControl object for testing purposes
random_fwdControl_generator( years = 1:round(runif(1, min = 2, max = 3)), nseasons = 2, max_nsim_target = 3, niters = round(runif(1, min = 5, max = 10)) )
random_fwdControl_generator( years = 1:round(runif(1, min = 2, max = 3)), nseasons = 2, max_nsim_target = 3, niters = round(runif(1, min = 5, max = 10)) )
years |
numeric vector of years in the control object. Default value is 1:random interger (max = 10). |
nseasons |
number of seasons in the projection |
max_nsim_target |
maximum number of simultaneous targets in each timestep |
niters |
the number of iterations. Default number is random integer (max = 10). |
A fwdControl object
More Gills Less Fishcakes
## S4 method for signature 'fwdControl' show(object)
## S4 method for signature 'fwdControl' show(object)
object |
A fwdControl |
Similar to the old STF method in FLAssess. Extends the object by a number of years and fill in the life history characteristics by taking a mean of the last few years.
stf(object, ...) ## S4 method for signature 'FLStock' stf( object, nyears = 3, wts.nyears = 3, fbar.nyears = wts.nyears, f.rescale = FALSE, arith.mean = TRUE, na.rm = TRUE, end = dims(object)$maxyear + nyears, disc.nyears = wts.nyears ) ## S4 method for signature 'FLBiol' stf( object, nyears = 3, wts.nyears = 3, arith.mean = TRUE, na.rm = TRUE, end = dims(object)$maxyear + nyears ) ## S4 method for signature 'FLStocks' stf(object, ...)
stf(object, ...) ## S4 method for signature 'FLStock' stf( object, nyears = 3, wts.nyears = 3, fbar.nyears = wts.nyears, f.rescale = FALSE, arith.mean = TRUE, na.rm = TRUE, end = dims(object)$maxyear + nyears, disc.nyears = wts.nyears ) ## S4 method for signature 'FLBiol' stf( object, nyears = 3, wts.nyears = 3, arith.mean = TRUE, na.rm = TRUE, end = dims(object)$maxyear + nyears ) ## S4 method for signature 'FLStocks' stf(object, ...)
object |
The object (FLStock or FLBiol) |
... |
Other things. |
nyears |
Number of years to extend the object |
wts.nyears |
Number of years to average over to get the future mean weights at age. |
fbar.nyears |
Number of years to average the F over (only used if object is an FLStock) |
f.rescale |
Rescale F (TRUE or FALSE - default is FALSE) |
arith.mean |
If TRUE the arithmetic mean is used. If FALSE the geometric mean is used. Default is TRUE. |
na.rm |
For the mean function. |
end |
My beautiful friend |
disc.nyears |
Number of years to average over to get the future mean proportion of discards at age. |
data(ple4) proj <- stf(ple4, 3)
data(ple4) proj <- stf(ple4, 3)
summary method for fwdControl
## S4 method for signature 'fwdControl' summary(object)
## S4 method for signature 'fwdControl' summary(object)
object |
fwdControl object to show summary of |
summary(object)
control <- fwdControl(data.frame(year=rep(2010:2015, each=2), quant=c("f", "catch"), min=c(rbind(NA, 20000)), max=c(rbind(NA, 30000)), value=c(rbind(seq(1, 1.3, length=6), NA)))) summary(control)
control <- fwdControl(data.frame(year=rep(2010:2015, each=2), quant=c("f", "catch"), min=c(rbind(NA, 20000)), max=c(rbind(NA, 30000)), value=c(rbind(seq(1, 1.3, length=6), NA)))) summary(control)
Access and replace the target slot of a fwdControl object
Replace the target slot of a fwdControl object
target(object, ...) target(object, ...) <- value ## S4 method for signature 'fwdControl' target(object) ## S4 replacement method for signature 'fwdControl,data.frame' target(object) <- value
target(object, ...) target(object, ...) <- value ## S4 method for signature 'fwdControl' target(object) ## S4 replacement method for signature 'fwdControl,data.frame' target(object) <- value
object |
The fwdControl object |
... |
Other things. |
value |
The target object to replace the existing one with. |
Targets must be processed by FLasher in the correct order. Internal function. Ignore.
targetOrder(target, iters)
targetOrder(target, iters)
target |
The target. |
iters |
The iters. |