Search code examples
simulationanylogic

Variable from simulation class is not accessible in main class


I have created many variables in my simulation class and would like to access them in my main agent in the StartUp code. First I started to create parameters in the main class like in the AnyLogic tutorial and assign the variables to the Simulation class. This works, but is very time consuming. However, in my StartUp code in the main class I can't access it directly with Simulation.example_parameter even though all variables are on public. Is this simply not possible or does anyone know where a bug might have crept in here?


Solution

  • If your experiment is a "Simulation" experiment, you can use ((Simulation)getExperiment()).myVariable

    PS: You can also wrap all your variables into a Java class and pass that along into 1 parameter in your model, saves a ton of effort