I am working on an evacuation process project and would like to know if its possible to acquire a dataset for text or a variable from main and run in parameter variation experiment (for 100 runs) while storing/saving it after every iteration. This text keeps changing every time the simulation runs because the number of people able to escape during evacuation is different. An alarm (event) goes off and it triggers another event (event1), this then updates the text that counts the number of people in the building.
stopCounting of type boolean is false and peopleRemaining of type long
getPeopleInsideCount() comes from my function
The code I tried using in After experiment run for parameter variation experiment is
iteration3++;
dataset2.add(iteration3,(double)Long.parseLong(root.text2.getText()));
I understand that this code is unable to read the text from the main as a dataset. I have run the simulation in main and the text updates while also noticing that the peopleRemaining variable follows the number in text. Maybe it is possible to obtain variable in a dataset?
please learn to use the AnyLogic help as well. There, you will learn that a Dataset object only stores numbers. Also, a text object has only text as a String. They are not compatible.
You will want to store your evacuation number in a variable of type Int, name it myEvacNumber
. So in addition of showing it in your text, you must manually store it in that variable. Best do that at the end of your evacuation ;-)
Then in your experiment in the "after simulation run" codebox, you can access it and store it into your dataset using
dataset.add(root.myEvacNumber);
Note that this will store the value that was in that variable at the very end of each simulation run!
Sorry Sir, I'm fairly new with this software. I tried copying the code form text into the variable initial value and the simulation window shows an error in red text "Error while drawing animation frame. Possibly caused by dynamic properties of animation shapes. The picture will be stored when and if the error goes away" I'm not sure what you meant by manually storing it and at the end of my evacuation.
I've updated the question in more detail and can update my question with a screenshot of the error I receive when I run the simulation.
Sorry sir, I've made a small mistake. I could simply use the code dataset.add(root.peopleRemaining); as shown in my question. And it worked. Thank you so much. I watched some of your videos and understood Anylogic as a beginner and would like to thank you for it.