How to do probalistic routing in Simulink/Simevents?

1 回表示 (過去 30 日間)
Nat
Nat 2012 年 7 月 5 日
回答済み: Marco Fanti 2019 年 1 月 16 日
I'm looking for a way to take a single input, and then based on statistics, route that signal to different blocks. For example, signal A has a 70% chance of going to Block 1, and a 30% chance of going to Block 2. So when running the model many times, sometimes the signal will take one route and sometimes another. How can I do this? Is there a way to associate probabilities with lines/branches? Thanks so much, N

回答 (2 件)

Albert Yam
Albert Yam 2012 年 7 月 5 日
Have you tried a Random Number block, with a switch.
  5 件のコメント
Nat
Nat 2012 年 7 月 6 日
Got it! I will use the set attribute block with a RN generator in simevents. Then when it's time for routing, I will use the Output Switch which will route the entity based on the attribute.
Sebastian Stankiewicz
Sebastian Stankiewicz 2017 年 8 月 7 日
Could you possibly send an example of how you did this? How could you control the probability of an event using the RN generator? Also, how did you route the entity based on the attribute?

サインインしてコメントする。


Marco Fanti
Marco Fanti 2019 年 1 月 16 日
get a probability vector, like
D= [1 0.2 ; 2 0,5 ; 3 0,3];
the first column contains the port you wanna send the entity to, the second one the probability
sort it so to have the greatest probability at the bottom and call it with a different name like
Ds= [1 0.2 ; 3 0.3 ; 2 0.5];
now set the output switch as swtich from attribute
in in a block that preceeds the outputswitch type in this code as event action
rnum=rand();
for i=1:size(Ds,1)
if rnum<=sum(Ds(1:i,2))
entity.Type=Ds(i,1);
break
end
end

カテゴリ

Help Center および File ExchangeDiscrete-Event Simulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by