How to use the boolean selector

288 views
Skip to first unread message

Jean-Christophe Sapin

unread,
Jul 2, 2014, 4:11:20 PM7/2/14
to jaamsi...@googlegroups.com
Hello,

I would like to simulate bad parts in a batch. I generate entities with a random frequency, and for each entity generated, I would like to randomly set up a OK attributes (True or False). The proportion of OK or not OK is predefined.

I thought that the BooleanSelector could be the right object to do this, but I don't see how to use it, since there is no output, and I didn't see other objects that could use it  ?

If anybody can help me ?

Thank you

Harry King

unread,
Jul 4, 2014, 8:46:47 PM7/4/14
to jaamsi...@googlegroups.com
Jean-Christophe,

There is no easy way to assign a random value to an attribute with the present version of JaamSim. Our plan is to implement random sampling within expressions, so that an Assign object can be used. The input will look something like:

Assign1  AttributeAssignmentList  {  {  'this.obj.OK = [BooleanSelector1]'  }  }

I'll try to get this into the next release for you. In the meantime, you can use a Branch object to select randomly between two Assign objects.

Harry

Harry King

unread,
Jul 12, 2014, 8:44:24 PM7/12/14
to jaamsi...@googlegroups.com
Jean-Christophe,

We have added the output "Value" to the probability distributions in the latest release (2014-28). With this addition, you can use an Assign object to set an attribute to a randomly sampled value. For your model, the input would be:

Assign1  AttributeAssignmentList  {  {  'this.obj.OK = [BooleanSelector1].Value'  }  }

The probability distribution is sampled every time the Value output is evaluated. To keep model results stable, the probability distribution is not re-sampled when the Value output is displayed in the Output Viewer.

Harry

Jean-Christophe Sapin

unread,
Jul 21, 2014, 9:36:58 AM7/21/14
to jaamsi...@googlegroups.com
Hello Harry,

Thank you for this great improvement, but, it doesn't work with the BooleanSelector, since, there is no output Value for this object.

So I used the DiscreteDistribution, instead of BooleanSelector, to return 0 or 1, and it works.

I still don't understand how to use a BooleanSelector. Indeed, this object has no output, and it can't be used by a EntityGenerator.

Best regards

Harry King

unread,
Jul 22, 2014, 12:54:27 AM7/22/14
to jaamsi...@googlegroups.com
Jean-Christophe,

My mistake. Using DiscreteDistribution is the correct approach.

We haven't used the BooleanSelector object in any of our models, and it shows. It clearly needs modifications before it can be used. I'll look into this later this week. In the meantime, DiscreteDistribution does everything that BooleanSelector was intended to do.

Harry

Jerry L

unread,
Jan 5, 2015, 7:21:25 PM1/5/15
to jaamsi...@googlegroups.com

I came across this as well.  thanks for posting Jean-Christophe.
Reply all
Reply to author
Forward
0 new messages