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

조회 수: 8 (최근 30일)
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?

답변 (1개)

Gautham Sholingar
Gautham Sholingar 2017년 8월 17일
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)


Help CenterFile Exchange에서 Discrete-Event Simulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by