Warm tip: This article is reproduced from stackoverflow.com, please click
anylogic

How to get the dataset for text from Main and run in parameter variation experiment using anylogic?

发布于 2020-03-27 10:31:33

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.

enter image description here enter image description here

stopCounting of type boolean is false and peopleRemaining of type long

getPeopleInsideCount() comes from my function enter image description here

The code I tried using in After experiment run for parameter variation experiment is

iteration3++;

dataset2.add(iteration3,(double)Long.parseLong(root.text2.getText()));

enter image description here

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?

Questioner
Shariff Ghanem
Viewed
49
Benjamin 2019-07-03 20:20

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!