2

I feel I must apologize for such a basic question, but I am getting an error simply trying to run BehaviorSpace experiments in headless mode. I tried running my own model experiments from the command line, but got an error. So I then tried following the exact instructions on the BehaviorSpace documentation. To do this, I created a BehaviorSpace experiment in the Fire.nlogo model called "experiment1" (see screen shot) and then tried to execute commands to run experiment1 from the command line. The screen shot of the terminal shows that I first set the directory where I have NetLogo 5.3 installed, and then tried to run the commands from the BehaviorSpace documentation. The screen shot of the terminal also shows the Java error I am getting. I have never used the terminal before and am not sure what I am doing wrong, but I am sure I am missing something simple.

I am using Mac OS X and NetLogo 5.3. Thank you for your time. enter image description hereenter image description here

user3887089
  • 307
  • 1
  • 8
  • I think you may be having issues with your jar file. Did you add Netlogo.jar to the environmental variables? I would use an absolute path to it. – mattsap Apr 12 '16 at 16:16
  • @mattsap I believe you must be on the right track. A closer look at the BehaviorSpace documentation revealed "(For this to work, NetLogo.jar must be present along with the lib subdirectory containing necessary libraries. Both NetLogo.jar and lib are included with NetLogo.)". However I do not know any Java, and there does not seem to be apparent instructions on how this can be done. Im using Mac and found (http://stackoverflow.com/questions/22842743/setting-java-home-environment-variable-on-mac-osx-10-9) for setting JAVA_HOME variables, but I don't know if this is what I need to be doing. – user3887089 Apr 12 '16 at 17:18
  • I don't think your issue is with java programming at all. I think it's your jar location. – mattsap Apr 12 '16 at 17:44
  • 1
    It looks to me like between NetLogo 5.2 and 5.3 the directory structure changed (NetLogo.jar and the other JARs are now inside a `Java` folder), but the BehaviorSpace documentation wasn't updated to match. – Seth Tisue Apr 13 '16 at 03:02

2 Answers2

1

Seems you're not working in the correct directory.

You need to cd into the netlogo directory: For me:

netlogo_directory = "/Applications/NetLogo 5.2"

so

cd /Applications/NetLogo\ 5.2

Then you can execute your command:

java -Xmx2048m -Dfile.encoding=UTF-8 -cp ./Netlogo.jar org.nlogo.headless.Main --model /path/to/your/file/name/filename.nlogo --experiment experimentname  --table /path/to/log/with/filename.csv --spreadsheet /path/tp/spreadsheet/with/filename.csv
mattsap
  • 3,790
  • 1
  • 15
  • 36
  • thx again for your comment. Indeed I was not in the right directory, rather I was in the folder that contained the folder NetLogo 5.3. Frustratingly, when I did cd to the correct directory, the same error exists (i have edited the screen shot to show this). I also tried adding the "./" that you included before "./Netlogo.jar" in the above comment, but this also made no difference in the result. – user3887089 Apr 12 '16 at 18:21
  • I don't see where your Fire.nlogo file is in your ls in your screenshot. I think you call it mymodel.nlogo instead. – mattsap Apr 12 '16 at 18:26
  • Also, you have an extra - at the end with no name for what the table output should be. – mattsap Apr 12 '16 at 18:28
  • the "-" after table is a copy and paste from the documentation. I have deleted the "-" and also added Fire.nlogo to the directory folder. Neither of these make a difference with the error. There error seems to point towards the .jar file as you mentioned. But the solution to this doesn't seem apparent. Thx. – user3887089 Apr 12 '16 at 18:36
  • I don't see your lib subdirectory. It contains a bunch of necessary jars. That also needs to be in your netlogo directory. – mattsap Apr 12 '16 at 18:46
  • 5.2 and 5.3 have different directory structure. – Seth Tisue Apr 13 '16 at 03:05
  • So how should the behavior space call change? Should there be an explicit copy paste of the lib directory or does the new jar consider that? – mattsap Apr 13 '16 at 04:03
  • 1
    I was able to fix this problem by adding "Java/" before the Netlogo.jar file. The problem is that the jar file and lib file are located inside the Java folder that comes with NetLogo. So the Java subfolder must be given if all files are used in the original place that NetLogo has them stored. Thanks for your help. – user3887089 Apr 13 '16 at 13:37
0

The problem is that the Java file that comes with NetLogo is where the .jar file and lib file are located. Hence, a simple addition of Java/ in the below code allows all files to be found.

java -Xmx1024m -Dfile.encoding=UTF-8 -cp Java/NetLogo.jar \
  org.nlogo.headless.Main \
  --model Fire.nlogo \
  --experiment experiment1 \
  --table mytable.csv
user3887089
  • 307
  • 1
  • 8