seize & match behaviour

707 views
Skip to first unread message

klh...@gmail.com

unread,
Nov 7, 2016, 7:21:25 AM11/7/16
to Jaamsim Users Discussion Group
I am very new to jaamsim but am impressed by it so far. However my trial model has an issue I just cannot get my head around.

I have two sequences that use the same resource with one a higher priority than the other. As the resource is shared I want to use a common queue for entities using the resource. In order to distinguish the entities I use an entity attribute (P) with values 1 for the higher priority sequence and 2 for the lower sequence. The respective SEIZE objects then have a "match" expression - this.obj.P==1 and this.obj.P==2

This is accepted by the model BUT when I run it the model breaks with an exception:

EXCEPTION AT TIME: 2.911487 s
Error: null
com.jaamsim.input.ExpEvaluator$EntityResolver.resolve(ExpEvaluator.java:303)
com.jaamsim.input.ExpParser$ResolveOutput.evaluate(ExpParser.java:227)
com.jaamsim.input.ExpParser$BinaryOp.evaluate(ExpParser.java:389)
com.jaamsim.input.ExpParser$Expression.evaluate(ExpParser.java:110)
com.jaamsim.input.ExpEvaluator.evaluateExpression(ExpEvaluator.java:364)
com.jaamsim.Samples.SampleExpression.getNextSample(SampleExpression.java:62)
com.jaamsim.ProcessFlow.LinkedService.getNextMatchValue(LinkedService.java:116)
com.jaamsim.ProcessFlow.Seize.startProcessing(Seize.java:78)
com.jaamsim.ProcessFlow.Seize.queueChanged(Seize.java:71)
com.jaamsim.ProcessFlow.Queue$DoQueueChanged.process(Queue.java:251)
com.jaamsim.events.EventManager.executeTarget(EventManager.java:175)
com.jaamsim.events.EventManager.execute(EventManager.java:256)
com.jaamsim.events.Process.run(Process.java:101)

Any suggestions much appreciated

cheers

Kevin

Zoli

unread,
Nov 7, 2016, 9:58:53 AM11/7/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

I wanted to say that you should set the queue's match value to this.obj.P and the two seize's match value just to 1 and 2, but I noticed something interesting, so I only have questions, not answers.

The attached seizequeuematch.cfg contains what you've described. seizequeuematch2.cfg has three seize units for the same queue. Here, the simentity's Temp attribute can have four values: 10, 20, 30 and 40. Seize1 only accepts entities with a Temp of 10, seize2 only accepts entities with a Temp of 20 and sieze3 does not have a match value.
What I've noticed is that while seizequeuematch2.cfg works properly, seizequeuematch.cfg's sieze units will only consider the match values if I let the simentities accumulate(I changed the resource capacity from 10 to 1 for this) and even then, EntityGenerator1_1 is processed incorrectly. Is this a bug?

(I would also like to ask whether its possible to write a conditional expression for the seize unit's match value which can return the default 'null' value if a condition is met?)

Best regards,
Zoli
seizequeuematch.cfg
seizequeuematch2.cfg

klh...@gmail.com

unread,
Nov 7, 2016, 10:18:16 AM11/7/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Hi Zoli, Thank you for the reply and importantly your examples. Having looked at the first one I understand the syntax better and my model behaves as I expect (so far) so my immediate problem is solved.

As for you other questions.....I regret I am very much an amatuer at this :)

thanks again

cheers

Kevin

Harry King

unread,
Nov 7, 2016, 1:06:54 PM11/7/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

Can you please attach a copy of your model to another post? I'd like to see what caused the null pointer error.

By the way, you need to become a member before you can attach files to posts.

Harry

Harry King

unread,
Nov 7, 2016, 1:48:38 PM11/7/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Zoli,
 
seizequeuematch.cfg's sieze units will only consider the match values if I let the simentities accumulate(I changed the resource capacity from 10 to 1 for this) and even then, EntityGenerator1_1 is processed incorrectly. Is this a bug?

HK - It's not a bug. Both of your Seize objects are sending their entities to the same EntityDelay. The second EntityDelay is never used. See the attached model with this problem corrected.

(I would also like to ask whether its possible to write a conditional expression for the seize unit's match value which can return the default 'null' value if a condition is met?)

HK - As of release 2016-21, the expression system cannot return a null value. This is something that we have been thinking about, though.

Harry

seizequeuematch - HK.cfg

Zoli

unread,
Nov 7, 2016, 5:40:56 PM11/7/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Thank you again for your help!

kevin hughes

unread,
Nov 8, 2016, 3:24:49 AM11/8/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Hi Harry, I have just applied to join the group, when I am a member I will post the model

I think I understand my issue however: I thought the match expression in the SEIZE referenced the entity that would be passed in - as suggested by the hover help (this.obj.Attrib1). I think this is wrong as there is no obj

Harry King

unread,
Nov 8, 2016, 10:11:27 AM11/8/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

You are correct, the output obj for the Seize object is the most recent entity that was processed. It's hard to see why anyone would want to use an attribute of that entity to set the Match value for the next entity to be chosen. I'll revise the popup for the Match keyword to provide a better example. Thanks for the feedback.

Harry

Zoli

unread,
Nov 16, 2016, 10:48:52 AM11/16/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Harry,

I have also encountered a null pointer error using Seize components. I've attached the model. This is the log:
EXCEPTION AT TIME: 9559,876159 s

Error: null
com.jaamsim.input.ExpEvaluator$EntityResolver.resolve(ExpEvaluator.java:303)
com.jaamsim.input.ExpParser$ResolveOutput.evaluate(ExpParser.java:227)
com.jaamsim.input.ExpParser$IndexCollection.evaluate(ExpParser.java:262)
com.jaamsim.input.ExpParser$Assignment.evaluate(ExpParser.java:147)
com.jaamsim.input.ExpEvaluator.evaluateExpression(ExpEvaluator.java:364)
com.jaamsim.ProcessFlow.Assign.addEntity(Assign.java:59)
com.jaamsim.ProcessFlow.LinkedDevice.sendToNextComponent(LinkedDevice.java:140)
com.jaamsim.ProcessFlow.Seize.startProcessing(Seize.java:86)
com.jaamsim.ProcessFlow.Resource.notifySeizeObjects(Resource.java:198)
com.jaamsim.ProcessFlow.Release.releaseResources(Release.java:84)
com.jaamsim.ProcessFlow.Release.addEntity(Release.java:63)
com.jaamsim.ProcessFlow.LinkedDevice.sendToNextComponent(LinkedDevice.java:140)
com.jaamsim.ProcessFlow.Server.processStep(Server.java:76)
com.jaamsim.ProcessFlow.Device.endStep(Device.java:141)
com.jaamsim.ProcessFlow.Device$EndStepTarget.process(Device.java:121)

com.jaamsim.events.EventManager.executeTarget(EventManager.java:175)
com.jaamsim.events.EventManager.execute(EventManager.java:256)
com.jaamsim.events.Process.run(Process.java:101)

For me it seems that the error occurs when ExperimentGenerator_33 is seized by Block3Seize. This also happens when the Block3 line of components are removed and the simulation can only run without errors if the Block2 line is removed as well.

Zoli
nullpointer.cfg

Harry King

unread,
Nov 16, 2016, 2:22:03 PM11/16/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Zoli,

It's one of the Assign objects that is causing the error, not a Seize object.

We are looking into getting a more helpful error message instead of just a null pointer, but part of the problem is the complicated data structures you have created. For example, the Recipe attribute is assigned the following value in one your Assign objects:

{{1, 25, 0},{2, 1, 10[ml]},{2, 2, 3[ml]},{3, 2[h]},{4},{5}}

We are hoping to be able to restrict arrays to contain a single type of object and to restrict numerical entries to have the same unit. Your model would be easier to understand and to debug if you divided this information into separate attributes.

I'll get back to you later when we are able to figure out where the error is coming from.

Harry

Harry King

unread,
Nov 16, 2016, 5:49:30 PM11/16/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

As it turns out, the root cause is a bug in the Seize object after all. It occurs when multiple entities seize resources one after the other, at the same simulation time. The bug prevents the value for the Match keyword from being updated for each subsequent entity. I guess your model is the first one that relied on a new Match value for each entity.

The bug will be fixed in the next release (2016-22). I'll try to get this out for you as soon as possible, or early next week at the latest.

Harry

Zoli

unread,
Nov 20, 2016, 2:54:04 PM11/20/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Harry,

I tried to simplify both the data structures and the expressions in the model and the null pointer error doesn't occur now. The entities in a queue can stuck if matching is used and if [Queue].obj, the entity added last, is already left the queue. I solved this problem in the past by making the entities in the queue constantly reneging back to the queue. This way [Queue].obj almost always points to an entity in the queue. However this slows down the simulation in non real time mode. I tried to use an expression for renegeTime to only renege the entities if [Queue].obj is left the queue(by checking the attribute this.obj.QueueState) but it always takes the renegetime that corresponds to this.obj.QueueState==0. This also happened when I used the RenegeCondition input or an ExpressionEntity for this purpose. How can I solve this?

Thank you for your help in advance.
Zoli
RenegeTime expression.cfg

Harry King

unread,
Nov 20, 2016, 3:36:28 PM11/20/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,


The entities in a queue can stuck if matching is used and if [Queue].obj, the entity added last, is already left the queue. I solved this problem in the past by making the entities in the queue constantly reneging back to the queue. This way [Queue].obj almost always points to an entity in the queue.

HK - The only time when entity returned by [Queue].obj is not in the queue is when the queue is empty. I would test for that condition. Using reneging as a workaround doesn't seem like a good idea to me.
 
I tried to use an expression for renegeTime to only renege the entities if [Queue].obj is left the queue(by checking the attribute this.obj.QueueState)

HK - Once an entity has left the queue, it is no longer eligible to renege. I don't understand why you would want an entity to renege from the queue, only to be added back to the queue.

Can you describe to me the system you are trying to model? I may be able to help you simplify the logic if I understand the model's structure.

Harry

Harry King

unread,
Nov 21, 2016, 5:10:19 PM11/21/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

I think the problem is related to the way you are combining the BlockNThreshold objects with the BlockNSeize objects. There may be a subtle bug in JaamSim here, but I don't see why the thresholds are necessary in your model. The seem to be duplicating the logic of the Seize objects. How do you intend this to work?

Regarding the possible JaamSim bug, it would be nice to have a simpler example that got stuck in the same way.

Harry

Zoli

unread,
Nov 22, 2016, 5:41:46 AM11/22/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Harry,

I've attached a simplified model. The processing of the entities stop after Entity_30 leaves the Queue at 26.5 s. The Queue still show that the obj output is EntityGenerator1_30. Also, if the expression 'this.obj.State==[[NoQueue]]?0[s]:100[s]' is set for Queue1's RenegeTime, it will be evaluated as false, even when Entity_30 is at EntityDelay_3 with the state of NoQueue.

Regarding my original model:
A Block is a resource with space(=tubes) for 6 experiments. A state of a tube can be: free/clean, in use, and dirty. Also, a block can have a single temperature and gas setting. Currently nothing can change the Gas attribute of the blocks in the model, it can be only edited in the input editor.
While there are no tubes in use, the block can accept experiments with any kinds of temperature settings and with the same gas settings as the block has(with a single exception: in the special case where BlockNSeize.Gas==1, it can accept experiments of Experiment.Gas==0)
As long as there is at least one tube in use, the block will accept only experiments with the same temperature settings (and with the same gas settings as the block has).
When there are no tubes in use and there are at least one dirty tube, the block will stop accepting experiments until the operator cleaned the block and then all tubes become free again.

Zoli
seizequeuematch3.cfg

Harry King

unread,
Nov 23, 2016, 3:52:08 PM11/23/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

The basic problem with your model is that you are relying on a change in a Seize object's Match value to trigger it to check its queue for matches. Unfortunately, the Match keyword doesn't work that way in JaamSim or any other simulation package. The only times when the Seize object checks its queue is when a Release object releases a unit of its resource, when an entity is added to its queue, when one of its thresholds opens, or when one of its downtime objects finishes. If it were to monitor its Match value continuously, it would put a huge overhead on all models that use this object.

Harry


Zoli

unread,
Nov 23, 2016, 5:09:49 PM11/23/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Harry,

The block has space for 6 experiments. In the beginning, it can accept an experiment with any kind of temperature value. After the first experiment, it can only accept experiments with the same temperature values. So, if there are 3 experiments set to 20°C and 5 experiments with 30°C, then the block will either process the 3 experiments on 20°C or the 5 experiments on 30°C. This depends on the temperature value of the first experiment it receives.
I wanted to create the seize.match expression according to this. The seize component won't consider the matchvalues of the queue if the sieze.match input is empty. Once I use an expression for sieze.match it will return a matchvalue and therefore can only accept a specific experiment. Using an expression that can return a null value if a condition is met is not possible. Then I discovered that I could put [queue].obj.attrib in the expression of seize.match as a workaround. If there is a better way to solve this problem I will gladly implement it.

Zoli

Harry King

unread,
Nov 23, 2016, 5:23:52 PM11/23/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

Instead of [Queue].obj.Temp, I would use something like

'[Queue].QueueLength > 0 ? [Queue].QueueList(1).Temp : 0'

This expression would ensure that there is always an entity in the queue that satisfies the Match condition. It might be all you need to prevent the deadlock you are experiencing.

While you are working on the logic, I would put each expression for block temperature in an ExpressionEntity and use a Text object to display its value. This would make a key feature of your model visible to users as well as to yourself. Good graphics help a lot during testing and debugging.

Harry

Zoli

unread,
Nov 24, 2016, 5:58:23 PM11/24/16
to Jaamsim Users Discussion Group, klh...@gmail.com

Harry,


Some time ago I tried to use [Queue].QueueList(1) instead of [Queue].obj.Temp, but now that gases are used in the model, this gets more complicated. The blocks will have a gas value that is not possible to set with the first incoming experiment like the temperature. If a block has a gas setting of 2, and QueueList(1) has 1, QueueList(2) has 0 and QueueList(3) has 2, then the block would stuck instead of accepting QueueList(3) as its first experiment.


I will create a dashboard for monitoring some parameters of the model and I found the custom outputs very useful for debugging. I also redesigned the data structure of the recipe to anticipate the restriction of data types in arrays in new versions of JaamSim.


Zoli

Harry King

unread,
Nov 24, 2016, 6:25:17 PM11/24/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

I didn't explain what I meant very clearly. I'm suggesting that the input to each Seize object's Match keyword be as followings:

'[EntityDelayN].NumberInProgress == 0 ? ([QueueN].QueueLength > 0 ? [QueueN].QueueList(1).Temp : 0) : [EntityDelayN].obj.Temp'

This expression would choose the block's present temperature if it already contains an experiment. Otherwise, it would chose the temperature for the first experiment in the queue.

How does that sound?

Harry


Zoli

unread,
Nov 26, 2016, 2:55:50 PM11/26/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Harry,

In an earlier model, where the only match criterion was temperature and where the immeadiate next component was an EntityDelay(one for each sieze unit, not a common one for all three) I used a similar expression:
[EntityDelay2].NumberInProgress==0?[Queue1].obj.Temp:[EntityDelay2].obj.Temp
Now, with the use of gases, I thought a lot how I can use [BlockQueue].QueueList(X).GasTemp as a match criterion 'safely' so it would a) definitely find an experiment with a matching Gas attribute if there's any in the queue b) it won't cause an error if there isn't any or if the queue is empty.

Using the old expressions I tested my model and i corrected all my errors and moved on to implement the next feature, where the gases could be set by the operator. Unfortunately, after saving my perfectly working model, a very weird error occured.

When the file is opened, the log viewer shows a null pointer exception is occured:

Creating trace file
Configuration File Loaded
java.lang.NullPointerException
    at com.jaamsim.input.ExpEvaluator$EntityResolver.resolve(ExpEvaluator.java:303)
    at com.jaamsim.input.ExpParser$ResolveOutput.evaluate(ExpParser.java:227)
    at com.jaamsim.input.ExpParser$BinaryOp.evaluate(ExpParser.java:389)
    at com.jaamsim.input.ExpParser$BinaryOp.evaluate(ExpParser.java:389)
    at com.jaamsim.input.ExpParser$Conditional.evaluate(ExpParser.java:457)
    at com.jaamsim.input.ExpParser$Expression.evaluate(ExpParser.java:110)
    at com.jaamsim.input.ExpEvaluator.evaluateExpression(ExpEvaluator.java:364)
    at com.jaamsim.Samples.SampleExpression.getNextSample(SampleExpression.java:62)
    at com.jaamsim.BasicObjects.BooleanIndicator.updateGraphics(BooleanIndicator.java:80)
    at com.jaamsim.controllers.RenderManager.renderManagerLoop(RenderManager.java:363)
    at com.jaamsim.controllers.RenderManager.access$000(RenderManager.java:93)
    at com.jaamsim.controllers.RenderManager$1.run(RenderManager.java:185)
    at java.lang.Thread.run(Unknown Source)

Recoverable Exceptions from RenderManager:
ExpEvaluator.java:303 In: com.jaamsim.input.ExpEvaluator$EntityResolver.resolve 30 exceptions

Recoverable Exceptions from RenderManager:
ExpEvaluator.java:303 In: com.jaamsim.input.ExpEvaluator$EntityResolver.resolve 60 exceptions

Recoverable Exceptions from RenderManager:
ExpEvaluator.java:303 In: com.jaamsim.input.ExpEvaluator$EntityResolver.resolve 90 exceptions

If the model is started, an error message appear saying JaamSim has detected the following runtime error condition: java.lang.reflect.InvocationTargetException

The log:
EXCEPTION AT TIME: 0,000000 s
Error: java.lang.reflect.InvocationTargetException
com.jaamsim.input.OutputHandle.getValue(OutputHandle.java:209)
com.jaamsim.input.ExpEvaluator$CachedResolver.resolve(ExpEvaluator.java:254)
com.jaamsim.input.ExpParser$ResolveOutput.evaluate(ExpParser.java:227)
com.jaamsim.input.ExpParser$BinaryOpNoChecks.evaluate(ExpParser.java:437)
com.jaamsim.input.ExpParser$Conditional.evaluate(ExpParser.java:457)

com.jaamsim.input.ExpParser$Expression.evaluate(ExpParser.java:110)
com.jaamsim.input.ExpEvaluator.evaluateExpression(ExpEvaluator.java:364)
com.jaamsim.Samples.SampleExpression.getNextSample(SampleExpression.java:62)
com.jaamsim.ProcessFlow.LinkedService.getNextMatchValue(LinkedService.java:116)
com.jaamsim.ProcessFlow.Seize.startProcessing(Seize.java:78)
com.jaamsim.ProcessFlow.Device.startStep(Device.java:79)
com.jaamsim.ProcessFlow.Device.thresholdChanged(Device.java:344)
com.jaamsim.Thresholds.Threshold$ThresholdChangedTarget.process(Threshold.java:133)

com.jaamsim.events.EventManager.executeTarget(EventManager.java:175)
com.jaamsim.events.EventManager.execute(EventManager.java:256)
com.jaamsim.events.Process.run(Process.java:101)

If I 'remove' some of the newly added content, for example, change the Block(1-3)Threshold.OpenCondition from
[Block1Threshold_Copy].Open==0&&[Block1Threshold_Flush].Open==0

to
[Block1Threshold_Copy].Open==0,
then the si
mulation will be executed without any error messages. If I save the modified model and open it again, the same error message will appear when I attempt to start the simulation. I wasn't able to find the cause of this error nor any workarounds. I would like to ask for your help.

Zoli
InvocationTargetException.cfg

Harry King

unread,
Nov 26, 2016, 4:00:52 PM11/26/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Hi Kevin,

Thanks for reporting the null pointer error. We will fix the code to give a proper error message in the next release.

The root cause of the problem is the following custom output for BlockQueue:

{  NullPointerAvoider  this.obj.Parameter1Array(this.obj.SequenceCounter(this.obj.Currentproc))  }

Until the first entity is received, a queue's output obj is null, so all the entries of this.obj in the above definition are null. If you look in the Output Viewer, you can see that NullPointAvoider cannot be evaluated. The Output Viewer traps the error condition without causing any problems, but when this output is used in the input to the Match keyword for Block1Seize, it causes a run time error.

Harry

Harry King

unread,
Nov 26, 2016, 7:29:22 PM11/26/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Kevin,

The bug related to the Seize object, noted earlier on this thread, has been fixed in release 2016-22.

Harry

Zoli

unread,
Nov 27, 2016, 1:45:19 PM11/27/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Harry,

We were able to workaround by changing the BooleanIndicators' expression from:
[BlockQueue].obj.Gas==[Block1Seize].Gas||([BlockQueue].obj.Gas==0&&[Block1Seize].Gas==1)?1:0
to
[BlockQueue].QueueLength>0?([BlockQueue].obj.Gas==[Block1Seize].Gas||([BlockQueue].obj.Gas==0&&[Block1Seize].Gas==1)?1:0):0

I would like to add that while this problem persisted, the following error message was generated every time the cursor was moved in the View window:

Recoverable Exceptions from RenderManager:
ExpEvaluator.java:303 In: com.jaamsim.input.ExpEvaluator$EntityResolver.resolve 30 exceptions

I created the custom output NullPointerAvoider in order to avoid a null pointer error I caused by using [BlockQueue].obj.Parameter1Array([BlockQueue].obj.SequenceCounter([BlockQueue].obj.Currentproc))
in the Seize components' match expression.

Zoli

Harry King

unread,
Dec 18, 2016, 12:12:45 AM12/18/16
to Jaamsim Users Discussion Group, klh...@gmail.com
Zoli,

A new "notNull" function has been added to release 2016-23. See the release notes for more details.

Harry
Reply all
Reply to author
Forward
0 new messages