ropensci / nlrx

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

`simdesign` error with `simdesign_ff()` #27

Closed ElCep closed 5 years ago

ElCep commented 5 years ago

Hi, I have a java issue

Exception in thread "main" Expected a literal value. at position 0 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.LiteralParser.readLiteralPrefix(LiteralParser.scala:83)
    at org.nlogo.parse.LiteralParser.getLiteralValue(LiteralParser.scala:33)
    at org.nlogo.parse.CompilerUtilities$.$anonfun$readFromString$3(CompilerUtilities.scala:22)
    at org.nlogo.parse.CompilerUtilities$.$anonfun$numberOrElse$1(CompilerUtilities.scala:37)
    at scala.util.Either$RightProjection.getOrElse(Either.scala:665)
    at org.nlogo.parse.CompilerUtilities$.numberOrElse(CompilerUtilities.scala:36)
    at org.nlogo.parse.CompilerUtilities$.readFromString(CompilerUtilities.scala:22)
    at org.nlogo.fileformat.LabLoader.$anonfun$readProtocolElement$4(LabLoader.scala:70)
    at scala.collection.TraversableLike$WithFilter.$anonfun$map$2(TraversableLike.scala:742)
    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.IterableLike.foreach(IterableLike.scala:74)
    at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
    at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:741)
    at org.nlogo.fileformat.LabLoader.readEnumeratedValueSetElement$1(LabLoader.scala:66)
    at org.nlogo.fileformat.LabLoader.$anonfun$readProtocolElement$5(LabLoader.scala:77)
    at scala.collection.immutable.List.flatMap(List.scala:338)
    at org.nlogo.fileformat.LabLoader.valueSets$1(LabLoader.scala:74)
    at org.nlogo.fileformat.LabLoader.readProtocolElement(LabLoader.scala:94)
    at org.nlogo.fileformat.LabLoader.$anonfun$apply$1(LabLoader.scala:45)
    at scala.collection.immutable.List.map(List.scala:286)
    at org.nlogo.fileformat.LabLoader.apply(LabLoader.scala:45)
    at org.nlogo.fileformat.LabLoader.apply(LabLoader.scala:30)
    at org.nlogo.fileformat.LabFormat.load(NLogoLabFormat.scala:37)
    at org.nlogo.fileformat.LabFormat.load$(NLogoLabFormat.scala:35)
    at org.nlogo.fileformat.NLogoLabFormat.load(NLogoLabFormat.scala:40)
    at org.nlogo.headless.BehaviorSpaceCoordinator$.$anonfun$selectProtocol$1(BehaviorSpaceCoordinator.scala:34)
    at scala.Option.map(Option.scala:163)
    at org.nlogo.headless.BehaviorSpaceCoordinator$.selectProtocol(BehaviorSpaceCoordinator.scala:32)
    at org.nlogo.headless.Main$.runExperiment(Main.scala:23)
    at org.nlogo.headless.Main$.$anonfun$main$1(Main.scala:12)
    at org.nlogo.headless.Main$.$anonfun$main$1$adapted(Main.scala:12)
    at scala.Option.foreach(Option.scala:274)
    at org.nlogo.headless.Main$.main(Main.scala:12)
    at org.nlogo.headless.Main.main(Main.scala)
Error in util_gather_results(nl, outfile, seed, siminputrow) : 
  Output file is empty - simulation aborted due to a runtime error!
         Make sure that parameter value definitions of the experiment are valid and the model code is running properly!
Error in util_gather_results(nl, outfile, seed, siminputrow) : 
  Output file is empty - simulation aborted due to a runtime error!
         Make sure that parameter value definitions of the experiment are valid and the model code is running properly!
De plus : Warning messages:
1: In NCOL(x) : redémarrage de l'évaluation d'une promesse interrompue
2: In stop("Failed to determine columns for object of class '", class(x),  :
  redémarrage de l'évaluation d'une promesse interrompue
3: In stop("Failed to determine columns for object of class '", class(x),  :
  redémarrage de l'évaluation d'une promesse interrompue
Error in util_gather_results(nl, outfile, seed, siminputrow) : 
  Output file is empty - simulation aborted due to a runtime error!
         Make sure that parameter value definitions of the experiment are valid and the model code is running properly!
De plus : Warning message:
In .rs.toDataFrame(obj, objName, TRUE) :
 redémarrage de l'évaluation d'une promesse interrompue

with that

nl@experiment <- experiment(expname="explo-review3",
                            outpath=outpath,
                            repetition=1,
                            tickmetrics="true",
                            idsetup="setup",
                            idgo="go",
                            runtime=1000,
                            evalticks=seq(500,1000),
                            metrics=c("sort [size] of turtles", "sort [color] of turtles", "obsMs", "obsMp", "obsMsr", "obsMsa"),
                            metrics.turtles= list("turtles" = c("who", "size", "color")),
                            variables = list('alpha' = list(values=c(0, 0.2), min=0, max=0.2, step = 0.2, qfun="qunif"),
                                             'file_map_space' = list(values = c("data/maps_space/random-map100.txt",
                                                                                "data/maps_space/sugar-map100.txt")),
                                             'file_map_agents' = list(values = c("data/maps_agents/input_agents_506_1_.txt",
                                                                                 "data/maps_agents/input_agents_506_2_.txt",
                                                                                 "data/maps_agents/input_agents_506_3_.txt",
                                                                                 "data/maps_agents/input_agents_506_4_.txt",
                                                                                 "data/maps_agents/input_agents_506_5_.txt",
                                                                                 "data/maps_agents/input_agents_regular_506_1_.txt",
                                                                                 "data/maps_agents/input_agents_regular_506_2_.txt",
                                                                                 "data/maps_agents/input_agents_regular_506_3_.txt",
                                                                                 "data/maps_agents/input_agents_regular_506_4_.txt",
                                                                                 "data/maps_agents/input_agents_regular_506_5_.txt")),
                                             'timeV' = list(values=c(0,1), min=0, max=1,step = 1, qfun="qunif"),
                                             'simplify?' = list(values=c(TRUE,FALSE))
                                             ),
                            constants = list("coop2stock" = 0.5,
                                             "coop2burn" = 0.5,
                                             "seasonPeriod" = 360,
                                             "maxR" = 0.1,
                                             "scenarii_files?" = TRUE,
                                             "maxStock" = 10000,
                                             "vitalSugar" = 2,
                                             "extractRate" = 1,
                                             "nAgent" = 506,
                                             "diffuse-rate" = 0.2,
                                             "hide-turtles" = FALSE,
                                             "minSize" = 0.5,
                                             "maxSize" = 10,
                                             "heterogResugar?" = TRUE,
                                             "initSize" = 1
                                             )
                            )

nl@simdesign <- simdesign_ff(nl=nl, nseeds = 3)

regarding issue 22 it seems to be an algorithm problem but I'm using simdesign_ff() and nl@simdesign@siminput give me

# A tibble: 160 x 20
   alpha file_map_space file_map_agents timeV `simplify?` coop2stock coop2burn seasonPeriod  maxR `scenarii_files… maxStock vitalSugar
   <dbl> <chr>          <chr>           <dbl> <lgl>            <dbl>     <dbl>        <dbl> <dbl> <lgl>               <dbl>      <dbl>
 1   0   data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
 2   0.2 data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
 3   0   data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
 4   0.2 data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
 5   0   data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
 6   0.2 data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
 7   0   data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
 8   0.2 data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
 9   0   data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
10   0.2 data/maps_spa… data/maps_agen…     0 TRUE               0.5       0.5          360   0.1 TRUE                10000          2
# … with 150 more rows, and 8 more variables: extractRate <dbl>, nAgent <dbl>, `diffuse-rate` <dbl>, `hide-turtles` <lgl>, minSize <dbl>,
#   maxSize <dbl>, `heterogResugar?` <lgl>, initSize <dbl>

I can't see any NA's. Any ideas where m I wrong ?

Thank you for this package!

nldoc commented 5 years ago

First of all, sorry for the late response on your question. The last weeks I was travelling around a lot because it is summer holiday time over here. From a first quick look it seems like a problem with one of the variable values you are entering. I am quite sure it is the filenames you are entering in the values vector fields of the variables lists. NetLogo can only read those values as strings. However, when entering strings you always need to add another pair of escaped double quotes. Basically, it should look like this:

...
 'file_map_space' = list(values = c("\"data/maps_space/random-map100.txt\"",
                                    "\"data/maps_space/sugar-map100.txt\"")),
...

Furthermore, in the constants list you also have some logical variables. NetLogo is not able to understand the R TRUE/FALSE variables directly. Instead these need to be entered as strings:

...
"scenarii_files?" = "true",
...

Formatting rules for entering variables and constants are also explained here in more detail.

Can you try this and see if it solves your problem? Cheers, nldoc

ElCep commented 5 years ago

Hi, So sorry to disturb your summer holiday! And many thank's for your input! It works like a charm! You 've done an amazing job with this package ! E.