Capturing the maximum value of and ExpressionEntity during a run

129 views
Skip to first unread message

john.b...@arup.com

unread,
Nov 2, 2023, 2:14:32 PM11/2/23
to JaamSim Users Discussion Group
Hi there,

I have an ExpressionEntity which calculates some value. I use an EntityLogger with ValueTrace, etc and get a log file which nicely records all values as they change during a run. I can, of course, analyse the log file to find the maximum value the Expression Entity produced during the run.

However, I'd like to be able to have an additional output (e.g. RunMaxValue) from the ExpressionEntity itself which keeps track of the maximum value obtained as the model runs, so that it could be used or displayed within the model. 

I have tried to bodge together something by using TimeBasedStatistics  or SampleStatistics classes within ExpressionEntity Java source with partial success: yes, I define a new output and the RunMaxValue is roughly the right value, but it isn't the actual maximum. If I run the model slowly around the time of the maximum, then the actual maximum is captured. So it must be something to do with updates/timing, etc. I'm not saying this is a bug, by the way, just my limited understanding of trying to implement this in Java.

Anyhow, would it be possible to add this extra output to the ExpressionEntity object? I could see that a MaxRunValue and a MinRunValue might make sense. The other typical stats (average, etc) I suppose might have some value, though I suppose unlike the Min and Max, you'd need to choose Sample or TimeBased to make any sense.

Kind regards,

John


Harry King

unread,
Nov 15, 2023, 2:10:35 PM11/15/23
to JaamSim Users Discussion Group
Hi John,

The value for an ExpressionEntity is calculated on demand, which can happen at an event time when its value is used by some other object or when the value is needed for display by the graphics system. If the value depends on one or more continuous variables, then there is no guarantee that its value will be calculated exactly when it reaches its maximum value.

It is possible to ignore the values that were calculated for the graphics system, and only track those calculated for events, but I am not sure if it is appropriate to add statistics to the simple ExpressionEntity object. It might be better to create a new ExpressionStatistics object in the same way that there are separate ExpressionLogger and EntityLogger objects.

Can you describe your application to give me some context?

Harry

john.b...@arup.com

unread,
Nov 16, 2023, 7:08:20 AM11/16/23
to JaamSim Users Discussion Group
Hi Harry,

Here's a simple example. I have two queues. Each queue object maintains the maximum length (e.g. [Queue1].QueueLengthMaximum) that the queue reached during a run - so far so good. But I'm also interested in the _combined_ length of the two queues. Therefore, I use an ExpressionEntity (call it, for instance, CombinedQueueLength) to calculate [Queue1].QueueLength+[Queue2].QueueLength - and that obviously works fine too. But I'd like to find the maximum value, reached during a run, of the combined length of the two queues. Hence the idea of extending the ExpressionEntity object to capture this.

I do see the problem of capturing a maximum value of an ExpressionEntity if it were dependent upon a continuous variable, as you say - and that might be a good reason not to try to extend the functionality of an ExpressionEntity object. In the example, however, this is not the case since the queue lengths only depend only upon events. An ExpressionLogger object can record any/all changes seen in the ExpressionEntity I defined (CombinedQueueLength) using ValueTraceList. I can analyse the resulting log file to find the maximum value (which is, of course, absolutely right). However, I'd like to capture the maximum value within the model to display it during a run.

Your thinking of a new ExpressionStatistics object - that may be a better idea. It's a sort of combination of elements of existing functionality: (a) Statistics (i.e. something that captures Max, Min, etc) and (b) ExpresssionLogger with ValueTraceList (i.e. something that captures any change in the monitored value). I think Max and Min are pretty unambiguous values to calculate/report. I've not thought through Average, Standard Deviation, in this context, but whatever the existing logic/functionality used in the Statistics object I guess will continue to make sense. 

Perhaps, in summary, we are talking about a new ExpressionStatistics object that is like the existing Statistics object, but whose values/calcs/outputs are updated based on ValueTraceList logic, instead of an entity passing through it?

Does that make sense?

Best wishes,

John

Harry King

unread,
Nov 21, 2023, 6:26:57 PM11/21/23
to JaamSim Users Discussion Group
Hi John,

I will add the ExpressionStatistics object to the next release.

Harry

john.b...@arup.com

unread,
Nov 22, 2023, 9:16:06 AM11/22/23
to JaamSim Users Discussion Group
Thanks, Harry. That's marvellous. J

Harry King

unread,
Dec 4, 2023, 1:55:51 AM12/4/23
to JaamSim Users Discussion Group
ExpressionStatistics is included in release 2023-09.

Harry

john.b...@arup.com

unread,
Dec 4, 2023, 4:25:37 AM12/4/23
to JaamSim Users Discussion Group
Thanks Harry. Have used the new ExpressionEntity in model - and works as expected. Appreciate your help/work with this.

John

Reply all
Reply to author
Forward
0 new messages