Reputation: 358
I'm trying to show ResourcePool
utilization on a Time Plot chart.
Currently I use Time Plot to display by Value
the utilization of the selected ResourcePool
:
My problem is that every time the stageIndex
changes, the Time Plot resets and starts showing the data from that moment on.
Is there a way to directly access the DataSet
of the ResourcePool
(if there is one) and also get the past information about the utilization?
Thanks a lot.
Upvotes: 0
Views: 125
Reputation: 2517
Resource pools don't store historic utilisation information. (AnyLogic Datasets store time series, but most blocks/elements don't have built-in logic to store such a time series for every numeric statistic calculateable from them...)
The simple (and design best-practice) alternative is to have plots showing the utilisations over time for all resource pools you're indexing into and just control the visibility of these plots dynamically (if, as you suggest, the user selects which agent (with embedded resource pool) they want to view the graph for). They could be at identical x,y coords if you want (with only 1 visible) or not.
You can use AnyLogic's replication functionality to make this easy in this case: replication is useful when you have multiple charts or presentation elements with a common set of 'rules' regarding their number, placement and properties (including visibility). See the 2D and 3D animation --> Animating replicated objects help page. (In particular, this is the only way to have a dynamic number of charts/shapes depending on some potentially-changing-over-time and/or determined-only-at-run-time (e.g., related to input data) piece of information.)
NB: You could define and populate the historic utilisation Datasets yourself, but you still can't use a single plot because the Dataset expression you enter is effectively static: it is only evaluated once at model start. The "Value" expression is 'dynamic' but only because that's how Value plots work: the expression is evaluated at the interval you specify to 'add the next value to the plot' (which is why the behaviour you observe occurs when you change your index).
Upvotes: 1
Reputation: 9421
ok so it seems that you have population that removes agents from the population since that's the only reason why the index (assuming you use getIndex()) would change: adding and removing agents from the population
If you do that, you need to save the utilization independently from the agent itself, so you can do that by just using a collection (outside the population) with that information that is updated every certain amount of time with resourcePool.utilization()
since i don't know exactly what you are trying to do, this is all i can say
Upvotes: 1