Importing and exporting netlogo worlds via python strings

106 Views Asked by At

I am running an ensemble of netlogo models through pynetlogo. Every few steps i export the world to file, perform some minor incantations and then import those worlds from file again and keep running the model.
Works like a charm, very happy.

I wanted however to cut down on the write/read operations on disc and I realized that the extensions export-the and import-a would output the world string. So I want to:

  1. save the export-the:world call to the string saved_world
  2. then re import it through import-a:world

Unfortunately when I try do to this, and more specifically:

saved_world = netlogo.report('export-the:world')
netlogo.command('import-a:world '+ str(saved_world))

I get hit by a torrent of Scala exceptions, the legible few related to illegal characters. My guess is that the conversion netlogo string to java string object to python string and back to command, some escape parameters are lost or added in a way that is illegal.

Has anybody gone through something similar? I tried encoding/decoding the saved_world string in many different ways (raw, non-raw, utf8, etc...) but with no success.

0

There are 0 best solutions below