Multiplying Maps

17 views
Skip to first unread message

Geoffrey Tian

unread,
Jul 11, 2026, 12:43:44 AM (13 days ago) Jul 11
to JaamSim Users Discussion Group
Hello,
I am trying to work through a scenario, where an entity can order "sets" of items, but I cannot figure out how to multiply the demand by the sets ordered. I am working with the following example as attached, but I have written an explanation below:

Entity "Order" with the following properties:
* Set (String)
* Sets Ordered (Number)
* Demand (ArrayList)

Stored on the Assign object we have the following attributes:
{ SetBOMs  '{"SetA"={"Steel"=5,"Copper"=10},"SetB"={"Steel"=10,"Bronze"=20}}' }
{ AllSets  '{"SetA", "SetB"}' }

The assign block that the Order Entity passes through assigns in the order:
Set (1 - "SetA" | 2 - "SetB")
SetsOrdered (random number 1-5)
Demand (this.SetBOMs(this.obj.Set))

However, I cannot figure out any way to multiply each entry in Demand by SetsOrdered - any method using a lambda function only returns a map, and not an ArrayList. 
My question is if it is even possible to implement this behavior with ArrayLists- if not the other option would be to store demands as a 2D matrix, or two separate properties (like DemandQty and DemandPart). 

Any insight is appreciated.

SetsExample.cfg

Ben Randall

unread,
Jul 11, 2026, 2:02:45 AM (13 days ago) Jul 11
to Geoffrey Tian, JaamSim Users Discussion Group
Hi Geoffrey

Question: have you tried the map function (page 75 of the user guide under higher order function)?

map(|x|(x*this.SetsOrdered), 
this.SetBOMs(this.obj.Set))

Seems like it would work, though I’m just on my phone and not able to try it. I don’t usually use keys in my arrays so I’m not sure if that has some effect.

Regards,
BR

--
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/ced937c9-4c98-4fe9-9051-9b5e927b3e25n%40googlegroups.com.

Geoffrey Tian

unread,
Jul 11, 2026, 7:57:09 AM (13 days ago) Jul 11
to JaamSim Users Discussion Group
Hello Ben,

Thank you for your response.
The issue with the map function is that it only returns an array, and not an ArrayList, so we lose the keyed structure.
Screenshot 2026-07-11 065552.png
Reply all
Reply to author
Forward
0 new messages