for i in range(0, int(n)): workspace = nl4py.netlogoWorkspaceFactory.newNetLogoHeadlessWorkspace() workspace.openModel(model) print( "\n2.3) Get all workspaces back with: workspaces = nl4py.getAllExistingWorkspaces() \n\tSetting the parameters for all " + str(n) + " models to random values with workspace.setParamsRandom()") for workspace in nl4py.getAllHeadlessWorkspaces(): workspace.setParamsRandom() print( '\n2.4) Send setup and go commands to each model using: workspace.command("setup") and workspace.command("go") ' ) for workspace in nl4py.getAllHeadlessWorkspaces(): workspace.command("setup") workspace.scheduleReportersAndRun(["ticks"], stopAtTick=5) print( '\n2.5) Get back current state from all executing models using a NetLogo reporter: workspace.report("burned-trees")' ) for workspace in nl4py.getAllHeadlessWorkspaces(): results = workspace.awaitScheduledReporterResults() print(results) print( '\n3) Shutdown the server to release compute resources using: nl4py.stopServer()' ) nl4py.stopServer() print( '\n\n------------------------ Thanks for trying NL4PY -------------------------\n' )
def stopServer(self): nl4py.stopServer()