0

I am trying to load NetLogo model using RNetLogo package in R. But I am getting error, please find the details below:

Error: Error in NLLoadModel (absolute.model.path) :

and an error is popped up stating: Error in loading model:java.lang.reflect.InvocationTargetException

NetLogo Version used - 6.2.0 R version used - 4.1.0 System - Windows 10 (64-bit) Java - jdk1.8.0_291

Could anyone please guide me to get this issue fixed.

Devu
  • 1
  • 3
  • Just a hint: there is also the "nlrx" package, maybe that's an alternative. – LittleLynx Jun 02 '21 at 14:12
  • Hi @Lena Thank you for introducing me to an alternative package 'nlrx' – Devu Jun 02 '21 at 22:21
  • I did research on nlrx package and tried to use it, I was able to install the package successfully but I was not able to execute the commands in 'nlrx' for example: nl@experiment : I was getting error -> Error in validObject(.Object) : invalid class “experiment” object: invalid object for slot "metrics.turtles" in class "experiment": got class "character", should be or extend class "list" – Devu Jun 02 '21 at 22:24
  • I don't know your input but something seems to be wrong with the "metrics.turtles" argument. It's expecting a list, like this one: `metrics.turtles=list("turtles" = c("who","pxcor","pycor","color"))`. – LittleLynx Jun 03 '21 at 08:06
  • I have did the same as they explained in the nlrx document, below is the code is used : nl@experiment <- experiment(expname = "nlrx_spatial", outpath="out/", repetition = 1, tickmetrics = "true", idsetup = "setup", – Devu Jun 04 '21 at 14:12
  • idgo = "go", idfinal = NA_character_, idrunnum = NA_character_, runtime = 100, evalticks = seq(1,100), metrics = c("count sheep","count wolves"), metrics.turtles = c("who", "pxcor", "pycor", "breed"), metrics.patches = c("pxcor", "pycor", "pcolor"), constants = list("model-version" = "\"sheep-wolves-grass\"", 'initial-number-sheep' = 100, 'initial-number-wolves' = 50, "grass-regrowth-time" = 30, "sheep-gain-from-food" = 4, "wolf-gain-from-food" = 20, "sheep-reproduce" = 4, "wolf-reproduce" = 5, "show-energy?" = "false") – Devu Jun 04 '21 at 14:14
  • I know it is kind of messy but I dint find any other way to paste the code in a structured way sorry for that. – Devu Jun 04 '21 at 14:17
  • Maybe the file you mention is outdated. I get the same error with your code, but when I replace `metrics.turtles = c("who", "pxcor", "pycor", "breed"), ` with `metrics.turtles = list("turtles" = c("who", "pxcor", "pycor", "breed")),` it works fine. Here is a documentation from November 14, 2020: [nlrx.pdf](https://cran.r-project.org/web/packages/nlrx/nlrx.pdf) – LittleLynx Jun 07 '21 at 07:12
  • I tried to update the code as you suggested in the above comment and the error is fixed but I am getting new error now : Error in (function (cl, name, valueClass) : ‘experiment’ is not a slot in class “function”. – Devu Jun 07 '21 at 14:57
  • I am not able to open the documentation link which you mentioned in comment- https://cran.r-project.org/web/packages/nlrx/nlrx.pdf Getting Error 404 – Devu Jun 07 '21 at 14:58

1 Answers1

0

I was able to fix this issue when I installed NetLogo 6.0.4 version and I was successfully able to load an existing NetLogo model from R. Hence under my analysis I got to know that using NetLogo 6.2.0 version we cannot load existing NetLogo model from R, whereas if we try the same with 6.0.4 version it is working fine. Please let me know if you have come across any other alternative way for this.

Devu
  • 1
  • 3