ropensci / nlrx

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

Understanding error message #61

Closed njirvine closed 2 years ago

njirvine commented 2 years ago

Hi there

This feels really basic but I am getting nowhere searching online for an interpretations. I'm struggling to interpret where my error is with my model.

nlrx all works well for the wolf-sheep sample given. So thought i would try my model, but when I run i get:

Run #1, JAVA EXCEPTION: Expected reporter. Expected reporter. at position 49

I assume its a problem with my model code interacting with nlrx, but i'm struggling to know where it is pointing me to - how do i know what position 49 is so i can find the exact error point?

model works fine in netlogo so all netlogo reporters are in place and working well

Thanks

bitbacchus commented 2 years ago

Hm, this is just a shot in the dark, but nlrx internally uses netlogo-headless and on https://github.com/NetLogo/NetLogo/wiki/Controlling-API it says:

When running headless, there are some restrictions:

The movie- primitives are not available; trying to use them will cause an exception. user- primitives which query the user for input, such as user-yes-or-no will cause an exception.

Do you use any of these?

Position 49 should refer to line 49 of your code. You can open the file in a proper editor (atom, notepad++, visual code, ...) with line numbering so you don't have to count lines by hand.

njirvine commented 2 years ago

Thanks again :)

No movies and no user prompts (all removed for verification/validation) and the experiment code sets the user input values as per the nlrx instuctions.

Line 49 is in the global variables list. Its a big model and a hybrid ABM/DES so the globals list is about 300lines long

I do use the time extension but the link-up for the date/time output is in the set-up. The 49th line in the setup is reset-ticks so not that.

:/

whole error message `


   Expected reporter. at position 49 in
    at org.nlogo.core.Fail$.exception(Fail.scala:27)
    at org.nlogo.core.Fail$.exception(Fail.scala:25)
    at org.nlogo.core.Fail$.exception(Fail.scala:23)
    at org.nlogo.parse.ExpressionParser$.parseExpression(ExpressionParser.scala:305)
    at org.nlogo.parse.ExpressionParser$.$anonfun$parseExpressionInternal$1(ExpressionParser.scala:358)
    at org.nlogo.parse.ExpressionParser$.parseParenthesized(ExpressionParser.scala:317)
    at org.nlogo.parse.ExpressionParser$.parseExpressionInternal(ExpressionParser.scala:363)
    at org.nlogo.parse.ExpressionParser$.parseArgExpression(ExpressionParser.scala:230)
    at org.nlogo.parse.ExpressionParser$.$anonfun$parseArguments$1(ExpressionParser.scala:166)
    at org.nlogo.parse.ExpressionParser$.$anonfun$parseArguments$1$adapted(ExpressionParser.scala:165)
    at scala.collection.immutable.Range.foreach(Range.scala:158)
    at org.nlogo.parse.ExpressionParser$.parseArguments(ExpressionParser.scala:165)
    at org.nlogo.parse.ExpressionParser$.parsePotentiallyVariadicArgumentList(ExpressionParser.scala:88)
    at org.nlogo.parse.ExpressionParser$.parseStatement(ExpressionParser.scala:69)
    at org.nlogo.parse.ExpressionParser$.$anonfun$apply$1(ExpressionParser.scala:30)
    at org.nlogo.parse.ExpressionParser$.parseStatements(ExpressionParser.scala:42)
    at org.nlogo.parse.ExpressionParser$.apply(ExpressionParser.scala:30)
    at org.nlogo.parse.NetLogoParser.parseProcedure(NetLogoParser.scala:45)
    at org.nlogo.parse.NetLogoParser.parseProcedure$(NetLogoParser.scala:29)
    at org.nlogo.parse.FrontEnd$.parseProcedure(FrontEnd.scala:10)
    at org.nlogo.parse.NetLogoParser.$anonfun$basicParse$1(NetLogoParser.scala:25)
    at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:237)
    at scala.collection.Iterator.foreach(Iterator.scala:941)
    at scala.collection.Iterator.foreach$(Iterator.scala:941)   
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1429)
    at scala.collection.MapLike$DefaultValuesIterable.foreach(MapLike.scala:213)
    at scala.collection.TraversableLike.map(TraversableLike.scala:237)
    at scala.collection.TraversableLike.map$(TraversableLike.scala:230)
    at scala.collection.AbstractTraversable.map(Traversable.scala:108)
    at org.nlogo.parse.NetLogoParser.basicParse(NetLogoParser.scala:25)
    at org.nlogo.parse.NetLogoParser.basicParse$(NetLogoParser.scala:15)
    at org.nlogo.parse.FrontEnd$.basicParse(FrontEnd.scala:10)
    at org.nlogo.parse.FrontEndMain.frontEnd(FrontEnd.scala:26)
    at org.nlogo.parse.FrontEndMain.frontEnd$(FrontEnd.scala:25)
    at org.nlogo.parse.FrontEnd$.frontEnd(FrontEnd.scala:10)
    at org.nlogo.compile.CompilerMain$.compile(CompilerMain.scala:43)
    at org.nlogo.compile.Compiler.compileMoreCode(Compiler.scala:86)
    at org.nlogo.compile.Compiler.compileMoreCode(Compiler.scala:100)
    at org.nlogo.workspace.Evaluator.invokeCompiler(Evaluator.scala:159)
    at org.nlogo.workspace.Evaluator.compileReporter(Evaluator.scala:38)
    at org.nlogo.workspace.Evaluating.compileReporter(Evaluating.scala:57)
    at org.nlogo.workspace.Evaluating.compileReporter$(Evaluating.scala:56)
    at org.nlogo.workspace.AbstractWorkspaceScala.compileReporter(AbstractWorkspaceScala.scala:26)
    at org.nlogo.lab.Worker$Procedures.<init>(Worker.scala:71)
    at org.nlogo.lab.Worker$Runner.callHelper(Worker.scala:101)
    at org.nlogo.lab.Worker$Runner.call(Worker.scala:91)
    at org.nlogo.lab.Worker$Runner.call(Worker.scala:74)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)```
njirvine commented 2 years ago

Update. It's fixed. You were on right on the nose about the user commands. I thought i had removed them all, but i had wrongly tried to code them into the experiment script.

                            outpath=outpath,
                            repetition=1,
                            tickmetrics="true",
                            idsetup="setup",
                            "allocate-expert",
                            "allocate-trainee-shift",
                            "allocate-senior-nurse",
                            idgo="go",
                            runtime=56001,

the allocate commands are the user ones. Reviewing the nl object I noticed that the allocate commands had been assigned as other conditions.

ive coded them directly into the model at setup and now it works.

Thanks again :)

bitbacchus commented 2 years ago

Glad to hear that :-)