General discussion, documentation and team work
flr / flasher Goto Github PK
View Code? Open in Web Editor NEWNew version of Flash
Home Page: http://flr-project.org/FLasher
New version of Flash
Home Page: http://flr-project.org/FLasher
Several implementations of Baranov catch equation.
Put into a single method
Use templates from https://github.com/flr/FLR-Project/tree/master/templates/roxygen
When evaluating the target, you may need to get the total catch of a Biol. Should this be calculated using live F and N etc, or just extracted from the FLCatches that catch the biol. The catches in FLCatches may not have been updated to reflect the effort. i.e. the calced catch could be different to the current catches in the objects.
This is also true of the catches in an FLCatch, however when evaluating target catches of an FLCatch we just take it from the object, and not calculate it. This is inconsistent. At the moment the catch of a FLBiol is calculated 'live' whereas catch of a FLCatch is just extracted.
But F is always calculated live. Hmmm.
My feeling is that we just extract from OM and that project_X should always be used to update before doing this. So long as we are clear.
It currently does not. Could easily add it if necessary.
Calculating total catches, landings or discards on a biol.
In most cases the total catch on a biol is the sum of the catches in the FLCatches that catch that biol.
No recalculation is necessary.
However, if an FLCatch that catches the biol also catches another biol (e.g. a FLCatch catches from two biols), then we cannot use the total catch of the FLCatch (it comes from 2 biols).
Then what?
We can't easily split the the total catch into the constituent parts.
Recalculate the catch using F and N etc?
For now, no recalculation. If the FLCatch catches 2 biols, you cannot get the catch of one of the single biols. At least for now.
Lots of other planned changes, like catch_q method, rely on this
In what timestep should abundance targets be set? In an FLBiol abundance is at start of timestep.
Do we keep this pattern in FLasher? i.e. if we have an SSB target we need to know the effort in the previous timestep that gives us that SSB?
Or we solve for the effort in the target timestep (which really affects SSB in next timestep).
I prefer the first option because it is in line with other FLR objects
Needed for SSB calculations.
Fspwn comes from 'spwn' member of fwdBiol and some timing slot in the FLCatch (not yet added)
Need some kind of Fishery / Catches / Biol map to store what Fishery / Catch combinations catch which Biols.
One idea is to use an Rcpp::IntegerMatrix with 3 columns (F, C, B). Each row is a unique Fishery / Catch catching a Biol (although the same C can catch multiple Bs, and the same B can be caught by multiple Cs).
Add this to the fwdControl class.
Need to add Constructor (probably best to build the matrix in R then easy to construct in C++)
Catches can be relative to catches in another fishery, not just to itself.
Test when calc_rec and hperiod etc are finalised
From @poldokim on June 9, 2016 7:40
When I try to compile FLash packages I have this error:
R version 3.3.0 (2016-05-03) -- "Supposedly Educational"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
* installing *source* package ‘FLash’ ...
** libs
g++ -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -I../inst/include -fpic -O3 -m64 -I/opt/intel/composerxe/linux/mkl/include -c FLCoreClasses.cpp -o FLCoreClasses.o
g++ -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -I../inst/include -fpic -O3 -m64 -I/opt/intel/composerxe/linux/mkl/include -c FLashDLL.cpp -o FLashDLL.o
FLashDLL.cpp: In function ‘SEXPREC* fwd_adolc_FLBiol(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)’:
FLashDLL.cpp:83:14: error: cannot convert ‘bool’ to ‘SEXP {aka SEXPREC*}’ in return
return false;
^~~~~
FLashDLL.cpp: In function ‘SEXPREC* fwd_adolc_FLBiols(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)’:
FLashDLL.cpp:133:14: error: cannot convert ‘bool’ to ‘SEXP {aka SEXPREC*}’ in return
return false;
^~~~~
FLashDLL.cpp:139:14: error: cannot convert ‘bool’ to ‘SEXP {aka SEXPREC*}’ in return
return false;
^~~~~
/usr/lib64/R/etc/Makeconf:141: recipe for target 'FLashDLL.o' failed
make: *** [FLashDLL.o] Error 1
ERROR: compilation failed for package ‘FLash’
Do you have any suggestion?
Copied from original issue: flr/FLash#3
Outline is there. Fill it in.
Before dispatch to C++:
Add a 'timestep' column that translates the year / season columns to the timestep.
Check that the timesteps are consecutive
Add 'biol' column for targets that relate to biols
Add a 'target' column (integer, consecutive, starting from 1). 'target' is used to identify which targets are to be processed together, i.e. multiple rows can have the same 'target' value (they are simultaneous targets).
Add the 'FCB' integer matrix as a slot to object@target. This is a map that describes what FLFishery / FLCatch combination catches which FLBiol. It is n x 3 with colnames c('F', 'C', 'B'). The values are integer describing the positions of the FLFishery etc within the lists that are based to the C++ side. See examples for more detail.
Also, better reporting from solver.
What happens if only some iters solve?
Flasher hides stats::poly. Could the name be changed?
stats::poly
function (x, ..., degree = 1, coefs = NULL, raw = FALSE, simple = FALSE)
{ [...]
effort
hperiod
etc
This line (R/rcpp_plugin.R, line 6) has
FLasher.so_location <- paste(.libPaths()[1], "/FLasher/libs/FLasher.so",sep="")
but this should not work in Windows, it will at least need to use
'FLasher.dll'
We need to find out how to make this cross-platform
We currently have one model with covariates in FLCore, rickerCA
rec ~ a * (1 - c * covar) * ssb * exp(-b * ssb)
What would we need to make it work in FLasher? The sr slot in the new FLBiol can accomodate the covariate(s) FLQuant(s), but they would have to be passed via FLBiolCpp to FLasher Rcpp.
Changes made at R level need to be made in C++
The %*%, %/%, %+% and %-% operators for FLQuant are able to extend one dimension of length one in one object to the length in the other. They could be very useful in Cpp.
To be done in the near future
For consistency, the ssb method for FLBiol, both bin FLasher and FLCore, should be called srp, spawning reproductive potential.
Setting ssb or stock targets on the first year of projection can only be done by modifying catch and F in the previous year, so that catch.n, harvest and stock.n are consistent.
Normal practice should be to have ssb/stock targets only from year 2.
A warning will be issued, at both fwdControl() and fwd()
The calculation of from effort and biomass should include 3 variables, alpha, beta and epsilon, to account for scaling, and the non-linearity of F and effort and of F and biomass, respectively.
The new parameter, epsilon, should be added to the catch.q slot of FLCatch flr/FLFishery#4
If hperiod = NA, then no fishing has taken place, all spwn happens before fishing, fprop = 0.0
Currently fwdControl must have n iters even if target is not varying
Need to wait for srp_timelag() to be added and tested
Can we have a constructorfor fwdControl that looks like:
setMethod('fwdElement', signature(element='data.frame', iters='integer'),
which builds the iter array with appropriate number of iters
We only have one minAge and maxAge per target line in fwdControl.
These are used to calculate the Fbar when evaluating get_target_value_hat and eval_om.
However, you can have targets relative to another object. e.g. F on one Biol relative to F on another Biol.
At the moment the same age range will be used to calculate Fbar for both Biols.This is not right.
Solution:
include relMinAge and relMaxAge in Control.
include minAge / maxAge information somewhere else.
Can we have Catch should be relative to Landings etc?
Would need to add relQuant in the fwdControl
Remove F member of operatingModel and replace with F() method. F can be:
'partial': F(Fishery, Catch)
'total': F(Biol). (The sum of all partial Fs fishing that Biol)
How is F calculated?
F = Sel. Q. Effort
F = alpha. Sel. Q. Effort^beta (where do alpha and beta come from?)
How is Q calculated? From Biol and Q_params? Is is age-structured?
All tests have been commented out.
Need better way for getting F = alpha * B ^ beta * sel * effort for each FLC - FLB interaction
And add example to FLash vs FLasher as to how this could go wrong
Does the target time step refer to abundance at start of year (determined by fishing effort in previous year), or abundance at end of the year (determined by fishing effort in current year)?
The calculation for Q is: alpha * B ^-beta
The B should be the biomass at the time of fishing. At the moment the 'biomassb method for a fwdBiol returns the Biomass at the start of the year. If there are more than one FLCatch operating on the stock and they fish at different times, the B will need to be the B at the time of fishing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.