Closed annfra12 closed 3 years ago
Hello! You are unable to drag it into the experiments because, under the hood, the PyCommunicator object is an agent. It's for this same reason that you cannot drag in your own agent types or discrete event blocks into the experiment window.
To create an agent in the experiment window, you need to programmatically create the PyCommunicator object. I've written the object to be constructed using whatever settings you run your PyCommunicator object with normally.
However, when you do create it, you need to have access to a "live" Agent type - i.e., the code to construct it will only work in the "Before Simulation Run" and "After Simulation Run" callbacks, where you have access to your top-level agent.
Below is an example of a model which collects data across a Parameter Variation experiment, saves it to a Collection object, and after the last iteration, it will dump the data to a JSON file in the model directory (via the toJson
function). Let me know if you have any follow-up Qs about it.
I'm closing it, but again, feel free to ask follow-ups.
I am trying to use py-communicator with any-logic, but I am unable to access pycommunicator library in any of my experiment windows like compare runs or parameter variation experiment. I basically want to run a python code after several runs of a compare runs experiment but py communicatior cannot be dragged.It is working well in the main interface. I am using the anylogic university 8.5.2 version. Basically if can drag pycommunicator to the experiment window, I can create a button in the experiment window which when clicked will run the python code and print the results. But pycommunicator is not getting recognized in the experiment window. So I was trying to call the function with pycommunicator in main to the experiment window but I am not understanding how to call it either. I need this to work please clarify