'Development in Java inside Anylogic - Trying acess parametrs of agents

I created a simulation using an Anylogic package. The traffic light simulation package. It turns out that now I need to use this simulation for an algorithm to generate random numbers before the start of each simulation of traffic light times.

I am not able to access the attributes of the agents that create within the simulation. I need to access the parameters of the traffic lights that I put in the model so that through the code in Java I can change these values ​​according to the results of the simulation. How can I do this?

enter image description here

enter image description here



Solution 1:[1]

Create a public (!) function on the parent class of your package (likely main) that changes the parameter value using a given argument.

After compiling into a jar file, you will have access to that function and can set the param.

You might also try to call an auto-generated function set_myParam(..) if your param is called myParam. AnyLogic auto-generates such setters. Depends on how the package was created

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Benjamin