Set Pack>NumberOfEntities using entity object attributes

75 views
Skip to first unread message

Nauzad Tantra

unread,
Feb 25, 2025, 4:25:33 AMFeb 25
to JaamSim Users Discussion Group
I am relatively new to JaamSim and am experimenting around with the software.

I tried to dynamically set the number of entities to be packed based on attributes ("qty") set in the SimEntity object.

Setting the formula in Pack>NumberOfEntities to this.obj.qty results in an error. The workaround I have found is to set it as "notNull(this.obj)?this.obj.qty:1". However, the first entity always goes through in a pack of 1 (or whatever is set in the else part of the formula). The following entities go through correctly.

I have also tried setting the Pack>NumberOfEntities using an Assign object after the server, but this throws an error too.

How can I set the NumberOfEntities in Pack using object attributes?

Kind regards,
Nauzad
PackTest.cfg

Cristiano Silva

unread,
Feb 25, 2025, 4:29:23 PMFeb 25
to Nauzad Tantra, JaamSim Users Discussion Group

Atenciosamente,
Cristiano Luís Turbino de França e Silva
==============================
                      GNU / Linux
    ,                ,       /       .-.
   /                  \     /      (e e)
  ((__-^^-,-^^-__))   /     _.`V'._
    `-_---' `---_-'      /    //~~W~~\\
  <__|o ` 'o|__>   /    //,           ,\\
        \   `  /       /    // |            | \\
         ):  :(      /      \) |            | (/
        :o_o:    /           \           /
          "-"    /              `w -  w'


--
You received this message because you are subscribed to the Google Groups "JaamSim Users Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jaamsim-user...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/jaamsim-users/16a5b2c4-012c-4c81-b5c1-669d0471bb05n%40googlegroups.com.

john.b...@arup.com

unread,
Feb 26, 2025, 5:00:26 AMFeb 26
to JaamSim Users Discussion Group
Attached is a model which uses Pack and, via a toggle button, uses either the old, non-dynamic batch size, or the new dynamic (recalculated) batch size function. I suspect that using the recalculate function will be the approach you'll need. 
Pack with new RECALCULATE input.cfg

Cristiano Silva

unread,
Feb 26, 2025, 7:20:23 AMFeb 26
to john.b...@arup.com, JaamSim Users Discussion Group
Excellent. Thank you! ;)

Atenciosamente,
Cristiano Luís Turbino de França e Silva
==============================
                      GNU / Linux
    ,                ,       /       .-.
   /                  \     /      (e e)
  ((__-^^-,-^^-__))   /     _.`V'._
    `-_---' `---_-'      /    //~~W~~\\
  <__|o ` 'o|__>   /    //,           ,\\
        \   `  /       /    // |            | \\
         ):  :(      /      \) |            | (/
        :o_o:    /           \           /
          "-"    /              `w -  w'

--
You received this message because you are subscribed to the Google Groups "JaamSim Users Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jaamsim-user...@googlegroups.com.

Nauzad Tantra

unread,
Feb 26, 2025, 6:42:44 PMFeb 26
to JaamSim Users Discussion Group
Hi @John,
Could you please explain your model in a little more detail. I dont know how the values are being set and how the entities are directed from the queue to the packaging container directly (I thought they would have to go through the Pack element).

Kind regards,
Nauzad

john.b...@arup.com

unread,
Feb 27, 2025, 3:11:53 AMFeb 27
to JaamSim Users Discussion Group
There are four EntityGenerators which create SimEntities (Red, Green, Blue, and Yellow). Each EntityGenerator has its own maximum number of Entities to generate and appearance times for those Entities.

All the Entities flow along a conveyor with a fixed transit time and enter Queue 1.

Queue1 uses this.obj.Type as the match condition. Type is defined in the AttributeDefintionList of the Entity. Each Entity defines a Type which is "Red", "Green", etc. This is ultimately used in Pack1 and Pack2 to try to pack a given number of similar Entities (i.e. all Red, all Green, etc).

Pack1 uses Queue1 as its "feeder" and seeks to pack batches of 100 Entities of the same type (colour) into a Container.

Entities that enter Queue1 are given a RenegeTime, that is a time at which they will leave Qeueue1 and, in this instance, be sent via an assign block (Assign1) which keeps count of how many Entities (of each colour) pass through. The Entities then go via another EntityConveyor to Queue2. The idea being that I want to make batches of 100 Entities of the same colour, but at some point, if there are insufficient of a colour to make a full batch of 100, I want to create a batch with whatever number remains. For this there is a second pack object, Pack2, which has Queue2 as its "feeder".

Pack2 behaves much the same as Pack1 but with two important differences. The NumberOfEntities (to pack) is defined as: [Assign1].Count([Queue2].NextItemType). And Pack1's Recalculate setting (look in Pack1's Options tab) can be set to be True or False. If set to be True, then the intended behaviour is achieved, and any leftover Entities (fewer than 100 of a given colour) are then packed into a container which holds Entities of the same colour.

From your question I think the difference in understanding is that I send Entities directly to the Queues, rather than to the Pack objects. You could try both methods to see whether you get the same outcome. 

Hope this adds the extra information you need to understand the "what/how/why"" of the model.

Regards

John

Nauzad Tantra

unread,
Feb 27, 2025, 5:39:57 PMFeb 27
to JaamSim Users Discussion Group
Thank you for the explanation John. I've got it working now.

Kind regards,
Nauzad

Nauzad Tantra

unread,
Sep 28, 2025, 10:08:16 PMSep 28
to JaamSim Users Discussion Group
Hi John,
Would you have any ideas on how you could set a different "NumberOfEntities" value for each color of entity received (i.e. if I wanted the red entities to be packed in lots of 25, or green to be in packs of 10). Can this also be achieved if I refer to the attribute values of the entities.

Nauzad
Reply all
Reply to author
Forward
0 new messages