How to assign entity to specific attributes using an output switch and attributes?

10 views (last 30 days)
I am trying to assign a probability to each attribute to determine whether a number should be assigned to an entity or not. For example, I would like the entity to travel through Out 1 50% of the time, Out 2 25%, Out 3 10%, Out 4 15%. How would I do this?

Answers (1)

Gautham Sholingar
Gautham Sholingar on 17 Aug 2017
There are a couple of things to note here:
1) The set of blocks being used in your screenshot refer to the old library blocks for simevents. You can access the new library by typing in the MATLAB command window:
>> simevents
2) The new library has blocks such as 'Entity Generator' and 'Entity Output Switch' which can be used to achieve the desired behavior. The attached model pathSwitching_17a.slx shows you an example of how you can choose which entity to output at different probabilities/rates.
The 'Entity generator' block has an attribute called 'Path' which is sent with every entity generated by this block.
This attribute is set to a specific value (1,2,3 or 4) in the Generate action section of the Event actions associated with the 'Entity Generator' block. This MATLAB code in the Generate action section creates a random number and using the probabilties of the generated random numbers sets the attribute 'Path' to a specific value as shown below.
The Entity Output Switch block connected to this 'Entity Generator' is configured to use the attribute Path as the switching criterion. For example if Path is set to 2, the entity is sent through the second channel.
The outputs of this switch have been connected with terminator blocks set to monitor the number of events which reach each of them. You will note that when simulated for 10000 time steps the display blocks show the number of times the entities reached the terminator with the probabilties as you desired.
This will be a good starting point to resolve your issue. Attached model: pathSwitching_17a.slx (note this model is in R2017a)

Categories

Find more on Discrete-Event Simulation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!