Multiple Assignments per Entity

432 views
Skip to first unread message

Chris K

unread,
Feb 9, 2016, 10:48:07 AM2/9/16
to Jaamsim Users Discussion Group
Hello,

Is there a way to have two consecutive assign blocks that assign information to an entity based on what the first block is? When I try this I first get an error that my entity does not have the second attribute then if I try to add a second attribute after my first it errors again saying "Expected an input with 2 or 3 value(s), received SO 00 dm 0. Value will be cleared"

I want to give my product code (Either a string or a 2 digit number that does not increase in simple sequence 00 01 02 03 05 09 14 15.. 73). Based on this product code I want to give it a subcode (4 possibilities - each product has a different ratio) then based on that subcode give the entity a length from a distribution.

Let me know what options I have or examples if this is possible.

Thanks,

Chris

Harry King

unread,
Feb 9, 2016, 3:29:05 PM2/9/16
to Jaamsim Users Discussion Group, karam...@gmail.com
Chris,

An Assign block can only change the value of an attribute that already exists. It cannot add a new attribute to an object. Also, an attribute can only have a numeric value (with or without a unit), not a String or an object.

For your model, I would define three attributes: Code, SubCode and Length, and then assign values to them using one or more Assign objects. The rules for matching SubCode with Code can be built into the expressions in your Assign objects. The probability distribution for Length can be sampled within the expression on the right-hand-side of the AttributeAssignmentList entry.

You can attach your model to another post if you need help with the details.

Harry

Chris Karamanos

unread,
Feb 10, 2016, 1:30:27 PM2/10/16
to Jaamsim Users Discussion Group, karam...@gmail.com
Hi Harry,

Thanks for the quick response. Right now I cannot post the test file I am using - (I'm guessing I need to be a member of the group?). I have two back to back assign blocks the first being:

{ this.obj.Prod=[GoodsDistribution].Value }

This distribution has values 0 1 2 3 5 and probabilities .5, .2, .15, .1, .05

What does the assign expression for an attribute named "Type" have to be such that each of those specific values of "Prod" could have their own new set of values? What about a range, continuous & discontinuous?

So lets say:

0 will need its own group of values {20 , 26 , 32}
1 and 5 will share a group of values {26, 32}
2-3 will share a new group of values {6, 32}

In other words:
If Prod.Value = 0 Then Type=DiscreteDistribution(20[.2],26[.1],32[.7])

Would it be easier to do that by first doing a discrete distribution on the Type then based on the type it got assign it a random discrete product code?

*Can these distributions be changed based on needs later in the model while it is running? (Override)

The next steps are:

Assign an average length to each type of each product (Will need to know both). This Length is for both the processing time through a number of servers and the number of units it produces.

Determine the Type so that a duplicate block can determine how many to make

Hopefully what I am asking makes sense. Basically I need to know how to assign a specific value based on another specific value.

Thanks,

Chris

Harry King

unread,
Feb 10, 2016, 8:08:03 PM2/10/16
to Jaamsim Users Discussion Group, karam...@gmail.com
Chris,

The best way to build your expression would be to use the choose function:

'this.obj.Type = choose( this.obj.Prod+1, DiscreteDistribution0.Value, DiscreteDistribution15.Value, DiscreteDistribution23.Value, DiscreteDistribution23.Value, -1, DiscreteDistribution15.Value )'

Note that I have added 1 to this.obj.Prod so that the first choice is index = 1. Also, Type = 4 is undefined, so I have returned -1 for that entry. You can place the two expressions -- one for this.obj.Prod and the other for this.obj.Type -- in a single Assign object. The assigns statements are performed in the sequence in which they are entered.

The inputs to each distribution must be constants. If you want to use a different set of distributions at a later time in the simulation run you can use a Branch object to direct the entities to separate Assign objects. Note that you cannot edit the inputs to the distributions without restarting the simulation run.

You can use another choose function when you select the Length based on the Prod and/or Type values.

Harry

Chris Karamanos

unread,
Feb 11, 2016, 1:54:56 PM2/11/16
to Jaamsim Users Discussion Group, karam...@gmail.com
For anyone interested this is what I have done here:

Created an entity
Assigned it attributes Product and Type with varying numbers of Type per product
Branched into specific products, assigned a length(product quantity) based on the type
Did a calculation to multiply the Length (didn't actually use this)
Based on the Type number, created that many Duplicates of each Entity (+ 1 for the original)
Recorded sum and average of the lengths



Testing Assign.cfg

Harry King

unread,
Feb 12, 2016, 2:26:02 PM2/12/16
to Jaamsim Users Discussion Group, karam...@gmail.com
Chris,

The assignments for Prod, Type, and Length look okay to me, however, I'm a bit confused by the steps following DupBranch where you duplicate the incoming entities and subject them to various length delays. Can you explain what that part of the model is intended to represent?

Harry

Chris Karamanos

unread,
Feb 16, 2016, 8:57:39 AM2/16/16
to Jaamsim Users Discussion Group, karam...@gmail.com
I did that as a visual verification that the correct number of entities were going through the model. It was merely to show the entities unstacked when they are on EntityDelay1 and the EndPath. If I didn't do something like this, it would appear as though one entity goes through the system when there are really 6,11,16 there.
Reply all
Reply to author
Forward
0 new messages