the-anylogic-company / AnyLogic-Pypeline

A custom AnyLogic library for running Python inside an AnyLogic model (Java)
https://github.com/the-anylogic-company/AnyLogic-Pypeline/wiki
MIT License
107 stars 27 forks source link

"Run and Runresults are not defined" problem #31

Closed hussamaoun closed 1 year ago

hussamaoun commented 1 year ago

i am getting these errors upon execution, any idea ?

Description: The method runResults(Class, String) is undefined for the type Main._pyCommunicator_Population. Location: Trial Model/Main/level/button1 - Button

Description: The method run(String) is undefined for the type Main._pyCommunicator_Population. Location: Trial Model/Main - Agent Type

t-wolfeadam commented 1 year ago

This isn't enough to go on...can you provide more context? As in, what does your call to either look like, how is your communicator setup, etc.? Alternatively, you can just post your model.

hussamaoun commented 1 year ago

i am calling the function run to set x, then i will call the function runresults to get x. To do this i wrote:

pyCommunicator.run("x=3.14"); \ to set x

Attempt xValue= pyCommunicator.runResults(double.class,"x"); \ to get x traceln(xValue);

t-wolfeadam commented 1 year ago

Well if you use the "shortcut" version of runResults - passing the output type - you need to have the variable you're assigning the same.

As in, you want either:

double xValue= pyCommunicator.runResults(double.class,"x");

or

Attempt attempt = pyCommunicator.runResults("x");
double xValue = attempt.getFeedback(double.class);

I don't see why the run call would fail. If it is, please attach your model so I can take a full look at it.

t-wolfeadam commented 1 year ago

I'll assume it works, feel free to reopen if you still have qs