ropensci / nlrx

nlrx NetLogo R
https://docs.ropensci.org/nlrx
GNU General Public License v3.0
77 stars 12 forks source link

Improperly specified VM option 'MaxRAMPercentage=50' #99

Closed danielvartan closed 3 months ago

danielvartan commented 3 months ago

Hi,

I'm trying to run nlrx "Get started" example, but I'm getting the following error.

It seems like an internal issue. Any ideas?


Error

Improperly specified VM option 'MaxRAMPercentage=50'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Error in (function (.x, .f, ..., .progress = FALSE)  : 
  ℹ In index: 1.
Caused by error:
ℹ In index: 1.
Caused by error in `util_gather_results()`:
! Temporary simulation output file not found: C:\Users\Daniel\AppData\Local\Temp\Rtmp4Ufx7S\nlrx_seed_552440159_row_1_31e86a216fdc.csv.
Either the simulation did not run or crashed, check the debugging section in ??run_nl_all() for help.

Code

library(nlrx)

Sys.setenv(JAVA_HOME = "C:/Program Files/Java/jdk-1.8")
netlogopath <- file.path("C:/Program Files/NetLogo 6.4.0")

modelpath <- file.path(
  netlogopath, 
  "/models/Sample Models/Biology/Wolf Sheep Predation.nlogo"
)

outpath <- file.path("C:/out")

nl <- nl(
  nlversion = "6.4.0",
  nlpath = netlogopath,
  modelpath = modelpath,
  jvmmem = 1024
)

nl@experiment <- experiment(
  expname="wolf-sheep",
  outpath=outpath,
  repetition=1,
  tickmetrics="true",
  idsetup="setup",
  idgo="go",
  runtime=50,
  evalticks=seq(40,50),
  metrics=c("count sheep", "count wolves", "count patches with [pcolor = green]"),
  variables = list(
    'initial-number-sheep' = list(min=50, max=150, qfun="qunif"),
    'initial-number-wolves' = list(min=50, max=150, qfun="qunif")
  ),
  constants = list(
    "model-version" = "\"sheep-wolves-grass\"",
    "grass-regrowth-time" = 30,
    "sheep-gain-from-food" = 4,
    "wolf-gain-from-food" = 20,
    "sheep-reproduce" = 4,
    "wolf-reproduce" = 5,
    "show-energy?" = "false"
  )
)

nl@simdesign <- simdesign_lhs(
  nl = nl,
  samples=100,
  nseeds=3,
  precision=3
)

# Evaluate nl object:
eval_variables_constants(nl)
print(nl)

# Run all simulations (loop over all siminputrows and simseeds)
results <- run_nl_all(nl)

Session info

devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.0 (2024-04-24 ucrt)
#>  os       Windows 11 x64 (build 22631)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Portuguese_Brazil.utf8
#>  ctype    Portuguese_Brazil.utf8
#>  tz       America/Sao_Paulo
#>  date     2024-05-20
#>  pandoc   3.1.11 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cachem        1.1.0   2024-05-16 [1] CRAN (R 4.4.0)
#>  cli           3.6.2   2023-12-11 [1] CRAN (R 4.4.0)
#>  devtools      2.4.5   2022-10-11 [1] CRAN (R 4.4.0)
#>  digest        0.6.35  2024-03-11 [1] CRAN (R 4.4.0)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.4.0)
#>  evaluate      0.23    2023-11-01 [1] CRAN (R 4.4.0)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.0)
#>  fs            1.6.4   2024-04-25 [1] CRAN (R 4.4.0)
#>  glue          1.7.0   2024-01-09 [1] CRAN (R 4.4.0)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
#>  htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.4.0)
#>  httpuv        1.6.15  2024-03-26 [1] CRAN (R 4.4.0)
#>  knitr         1.46    2024-04-06 [1] CRAN (R 4.4.0)
#>  later         1.3.2   2023-12-06 [1] CRAN (R 4.4.0)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.0)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.4.0)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.4.0)
#>  mime          0.12    2021-09-28 [1] CRAN (R 4.4.0)
#>  miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.4.0)
#>  pkgbuild      1.4.4   2024-03-17 [1] CRAN (R 4.4.0)
#>  pkgload       1.3.4   2024-01-16 [1] CRAN (R 4.4.0)
#>  profvis       0.3.8   2023-05-02 [1] CRAN (R 4.4.0)
#>  promises      1.3.0   2024-04-05 [1] CRAN (R 4.4.0)
#>  purrr         1.0.2   2023-08-10 [1] CRAN (R 4.4.0)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.4.0)
#>  Rcpp          1.0.12  2024-01-09 [1] CRAN (R 4.4.0)
#>  remotes       2.5.0   2024-03-17 [1] CRAN (R 4.4.0)
#>  reprex        2.1.0   2024-01-11 [1] CRAN (R 4.4.0)
#>  rlang         1.1.3   2024-01-10 [1] CRAN (R 4.4.0)
#>  rmarkdown     2.27    2024-05-17 [1] CRAN (R 4.4.0)
#>  rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.4.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.0)
#>  shiny         1.8.1.1 2024-04-02 [1] CRAN (R 4.4.0)
#>  stringi       1.8.4   2024-05-06 [1] CRAN (R 4.4.0)
#>  stringr       1.5.1   2023-11-14 [1] CRAN (R 4.4.0)
#>  urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.4.0)
#>  usethis       2.2.3   2024-02-19 [1] CRAN (R 4.4.0)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.4.0)
#>  withr         3.0.0   2024-01-16 [1] CRAN (R 4.4.0)
#>  xfun          0.44    2024-05-15 [1] CRAN (R 4.4.0)
#>  xtable        1.8-4   2019-04-21 [1] CRAN (R 4.4.0)
#>  yaml          2.3.8   2023-12-11 [1] CRAN (R 4.4.0)
#> 
#>  [1] C:/Users/Daniel/AppData/Local/R/win-library/4.4
#>  [2] C:/Program Files/R/R-4.4.0/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
danielvartan commented 3 months ago

The issue appears to be related to the JDK (Java Development Kit) version.

I uninstalled version 8u411 and installed the most recent one (22.0.1), and it worked fine.