Controlling API Setup

26 views
Skip to first unread message

Chris Davis Perumal

unread,
Apr 11, 2024, 1:37:39 PMApr 11
to netlogo-devel
Hi Team,

We're trying to run our Netlogo 3D model from Java in a headless format as specified in the documentation https://github.com/NetLogo/NetLogo/wiki/Controlling-API#example-headless

I used the netlogo-6.4.0.jar files that we found in the "app" folder yet still for some reason it was unable to pick up the supporting library files needed to run. Is there a different set of jar files that we are supposed to use?

We weren't sure if we were loading it onto the classpath correctly. Any help you can give us would be appreciated.

Thanks and Regards,
Chris

Aaron Andre Brandes

unread,
Apr 11, 2024, 2:55:31 PMApr 11
to Chris Davis Perumal, netlogo-devel

Hi Chris,

If you are running a NetLogo 3D model you can just use NetLogo_Console

 

For example, on my MacOS system in the terminal

 

cd /Applications/NetLogo 6.4.0

./NetLogo_Console --headless \

  --3D \

  --model "models/3D/Sample Models/GasLab/GasLab Free Gas 3D.nlogo3d" \

  --experiment "100 runs" \

  --table -

 

You can find more information about using the NetLogo_Console in the documentation.

 

If you need to use the Controlling API let us know.

- Aaron

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

 

 

--
You received this message because you are subscribed to the Google Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/1da7e1f3-6188-43e7-bcb9-d015c520d5e0n%40googlegroups.com.

Chris Davis Perumal

unread,
Apr 11, 2024, 3:57:15 PMApr 11
to netlogo-devel
Hi Aaron,

Thanks for your reply. We specifically need to use the controlling API because our big picture idea is to use Java (Spring) backend to interact with netlogo and pull data from it.

If you could help us with that set up, it would be great. That's where I'm stuck right now.

Thanks and Regards,
Chris

Aaron Andre Brandes

unread,
Apr 11, 2024, 4:57:30 PMApr 11
to Chris Davis Perumal, netlogo-devel

Hi

You should put the NetLogo directory that has the jars in your classpath

For MacOS that is

java -classpath "/Applications/NetLogo 6.4.0/app/*"

 

If you use sbt as your build system you can add the contents of attached build.sbt file to your current one to pull in the required jar files.

You could make adjustments if you use Maven, Gradle or some other build tool.

 

Let me know if this works for you.

build.sbt

Aaron Andre Brandes

unread,
Apr 12, 2024, 6:07:43 PMApr 12
to Chris Davis Perumal, netlogo-devel

Hi Chris,

Just in case it might be helpful for you to know – we introduced a number of enhancements to BehaviorSpace in NetLogo 6.4.

You might find the following to be of interest.

 

Pre experiment commands: Commands can be run before the experiment begins.

Post experiment commands: Commands can be run after the experiment ends.

Message has been deleted

Chris Davis Perumal

unread,
Apr 13, 2024, 6:58:06 PMApr 13
to netlogo-devel
We managed to add the jar files to the class path, but we ran into other problem. Is it related to the netlogo version?

java -classpath java -cp "/Users/chrisperumal/Documents/GitHub/3D-CeA-Model-Online/backend/lib/*"  Example2.java

Can't find extension: csv at position 12 in 

at org.nlogo.core.ErrorSource.signalError(ErrorSource.scala:11)

at org.nlogo.workspace.ExtensionManager.importExtension(ExtensionManager.scala:180)

at org.nlogo.parse.StructureParser$.$anonfun$parsingWithExtensions$1(StructureParser.scala:74)

at org.nlogo.parse.StructureParser$.$anonfun$parsingWithExtensions$1$adapted(StructureParser.scala:68)

at scala.collection.immutable.List.foreach(List.scala:431)

at org.nlogo.parse.StructureParser$.parsingWithExtensions(StructureParser.scala:68)

at org.nlogo.parse.StructureParser$.parseSources(StructureParser.scala:33)

at org.nlogo.parse.NetLogoParser.basicParse(NetLogoParser.scala:17)

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:47)

at org.nlogo.compile.Compiler.compileProgram(Compiler.scala:54)

at org.nlogo.headless.HeadlessModelOpener.openFromModel(HeadlessModelOpener.scala:51)

at org.nlogo.headless.HeadlessWorkspace.openModel(HeadlessWorkspace.scala:535)

at org.nlogo.headless.HeadlessWorkspace.open(HeadlessWorkspace.scala:502)

at org.nlogo.api.Controllable.open(Controllable.scala:19)

at Example2.main(Example2.java:7)

at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)

at java.base/java.lang.reflect.Method.invoke(Method.java:580)

at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.execute(SourceLauncher.java:264)

at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.run(SourceLauncher.java:153)

at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.main(SourceLauncher.java:78)

jeremy...@northwestern.edu

unread,
Apr 15, 2024, 11:56:55 AMApr 15
to netlogo-devel
Hey Chris,

NetLogo has some assumptions about where extensions will be located.  See this StackOverflow answer for more info.  The short of it is you'll want to set the `netlogo.extensions.dir` Java property as well, and point it to the bundled NetLogo extensions directory.  

You mentioned running a NetLogo 3D model, so you may need to also set the `java.library.path` Java property to point to the appropriate platform subfolder in the `natives` folder in the NetLogo install directory.  

I hope that helps, good luck with it.

-Jeremy


Reply all
Reply to author
Forward
0 new messages