Hello,
Could you please provide a series of examples using the check box to set model variables and parameters from the
simulation set up page?
Many thanks
Victor Gleim — 19.12.07
to PJ:
You can work with a Check Box using its API or placing a code in the Action section. Please refer to the Help for more
detail. You can change a model's parameters in the similar way as done in the model 'Bass Diffusion'.
PJ — 02.01.08
Victor,
Are there any examples you can provide of setting up a simulation to allow the user to set model parameters based on a
check box or radio button from the simulation pane (i.e. before the model is running)? I see only the use of sliders in
the Bass Diffusion example.
Many thanks,
Murat Yildizoglu — 03.01.08
Hi PJ,
I am a beginner in AL but I have been able to setup models where the parameters are chosen on the Simulation panel
before launching the run. Here iw what I do in AL 6.2 (the details have changed between 6.1 and 6.2):
If your Main has a parameter called L0 and you want to set the value of this parameter by reading a textbox before
running the model:
Getting the value of the textbox before beginning a run (even if this value has been modified by the user):
Put in the "Before simulation run" box of the Advanced tab of the experiment (for reading the value of L0 in
the example, from editbox_L0):
Double tmp = new Double(this.editbox_L0.getText());
double xx = tmp.doubleValue();
root.L0 = xx;
This will set the value of the variable L0 of the class Main.
You can also use computations for setting these values :
root.L = 2*root.L0
This method can probably be used to read the value of a checkbox and initialize the model in consequence.
I was surprised that this possibility is not at all discussed in the help file given that such a functionality seems
quite standard to me...
I hope this helps.
Murat
PJ — 03.01.08
Murat,
Thanks for this. I've tried your code and it works perfectly!
Cheers,
PJ
Murat — 03.01.08
You are welcome! :-)
I think that the help system should have a "How to" section that covers this kind of information... Anyway, I
am taking notes during my learning process and I will probably later post a AnyLogic Tips page on my web site. I think
that AL is a very beautiful software but its learning curve is quite steep...
Best regards,
Murat