Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSE tutorial - getCtrl function issue #14

Open
piaschuchert opened this issue Jul 22, 2019 · 11 comments
Open

MSE tutorial - getCtrl function issue #14

piaschuchert opened this issue Jul 22, 2019 · 11 comments
Assignees

Comments

@piaschuchert
Copy link

Hello,
I try to run the MSE tutorial and found a few small issues. However, one I cannot overcome is the issue with the getCtrl function. There is an error message with the last line in particular, where it says ctrl@trgtArray<-arr0. It seems there is no option in the fwdControl object to add a target array. I used the basic fwdControl function to create an object to get on with the tutorial, however, I believe I need to get something like this target array to proceed with the tutorial in full.

Thanks,

Pia

getCtrl <- function(values, quantity, years, it){
dnms <- list(iter=1:it, year=years, c("min", "val", "max"))
arr0 <- array(NA, dimnames=dnms, dim=unlist(lapply(dnms, length)))
arr0[,,"val"] <- unlist(values)
arr0 <- aperm(arr0, c(2,3,1))
ctrl <- fwdControl(data.frame(year=years, quantity=quantity, val=NA))
ctrl@trgtArray <- arr0
ctrl
}
M

@iagomosqueira
Copy link
Member

That tutorial is in need of an update, I am afraid. I will contact the people that wrote it and ask them to take a look, but that might take a little while.

@piaschuchert
Copy link
Author

piaschuchert commented Jul 26, 2019 via email

@iagomosqueira
Copy link
Member

Thanks for this.

Yes, please do send it, or create a pull request. Were you using FLasher?

@piaschuchert
Copy link
Author

piaschuchert commented Jul 26, 2019 via email

@iagomosqueira
Copy link
Member

It was written for FLash. OK, do try otherwise send me the code and I will change it.

@Marcurius419
Copy link

Hi Pia and Iago,
I'm working with this tutorial now (as a MsC student), and I'm getting an error at the last for loop of the code: "negative length vectors are not allowed". Is this also because the tutorial needs updating or did I do something wrong (I get it when I exactly copy everything so I don't think that I did something wrong).

@ejardim
Copy link
Member

ejardim commented Oct 15, 2021 via email

@Marcurius419
Copy link

Hi EJ,
Thanks for the quick reply! Sad to hear you're so busy but if you could help that would be absolutely great! :)

I put 'my code' (which is just the MSE tutorial basically copy-pasted) in a zip file (github didn't allow me to upload an R-file). The error occurs in the final for loop on line 190 (I made a comment there as well). The error I get is:

2018  > 
Error in .local(stock, indices, ...) : 
  negative length vectors are not allowed

I tried to solve it myself with the debug and traceback function, but didn't know how to fix it.
intro_MSE_FLR.zip

Thanks again and hopefully you can help

@Marcurius419
Copy link

Hi EJ,

I have an update about the MSE error that may make it easier for you to understand what's the issue.
It occurs in the for loop specifically when the line
out.assess <- xsa(stk.mp, idx.mp)
is run.
This calls the function xsa which in turn calls the function
FLXSA(stk, idx, control)
We looked up the code for the FLXSA function which we found here: https://github.com/flr/FLXSA/blob/master/R/flxsa.R
And we think that the issue is on line 278 at
res<-.Call("runFLXSA", iter(stock, 1), lapply(indices, iter, 1), control, FALSE)

My supervisor thinks, however, that this is partly written in C++, so maybe that helps.

This might also be useful information, the R and package version I'm running:

sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252
[3] LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] FLBRP_2.5.8 ggplotFL_2.6.10 ggplot2_3.3.5 FLXSA_2.6.5
[5] FLAssess_2.6.3 FLash_2.5.11 FLa4a_1.8.2 FLCore_2.6.17
[9] iterators_1.0.13 lattice_0.20-44

loaded via a namespace (and not attached):
[1] pcaPP_1.9-74 RColorBrewer_1.1-2 pillar_1.6.2 compiler_4.1.1
[5] tools_4.1.1 pspline_1.0-18 lifecycle_1.0.0 tibble_3.1.4
[9] gtable_0.3.0 nlme_3.1-152 mgcv_1.8-37 png_0.1-7
[13] pkgconfig_2.0.3 rlang_0.4.11 Matrix_1.3-4 DBI_1.1.1
[17] mvtnorm_1.1-2 gridExtra_2.3 coda_0.19-4 copula_1.0-1
[21] withr_2.4.2 dplyr_1.0.7 generics_0.1.0 vctrs_0.3.8
[25] cowplot_1.1.1 stats4_4.1.1 grid_4.1.1 tidyselect_1.1.1
[29] ADGofTest_0.3 data.table_1.14.2 glue_1.4.2 triangle_0.12
[33] R6_2.5.1 jpeg_0.1-9 fansi_0.5.0 latticeExtra_0.6-29
[37] purrr_0.3.4 magrittr_2.0.1 scales_1.1.1 ellipsis_0.3.2
[41] MASS_7.3-54 splines_4.1.1 stabledist_0.7-1 assertthat_0.2.1
[45] colorspace_2.0-2 numDeriv_2016.8-1.1 utf8_1.2.2 gsl_2.1-6
[49] munsell_0.5.0 crayon_1.4.1

@ejardim
Copy link
Member

ejardim commented Oct 26, 2021 via email

@iagomosqueira
Copy link
Member

Could you please contact me directly? iago AT mosqueira DOT eu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants