Filter löschen
Filter löschen

Is there a way to generate unique random number in Simevents?

3 Ansichten (letzte 30 Tage)
Ho Jung Kim
Ho Jung Kim am 25 Jul. 2022
Beantwortet: Brahmadev am 14 Sep. 2023
I am currently working with Queueing Network model using Simevents. Each server has service time, and I am using rand and randn to generate random service time for each server (for ex, -1 * 0.22 * log(1 - rand()) + 0.13 or 0.3+0.1*randn). I realized that most of the entity's service time are the same. I have tried generating seed, but it's still the same service time. I have followed
these two documents, but the result are the same (I also used rng('shuffle'), but still doesn't work)
Is there a way to generate unique random number using rand() and randn() other than the methods I used in simevents? Thank you.

Antworten (1)

Brahmadev
Brahmadev am 14 Sep. 2023
Hi,
I understand that you would like to generate random numbers using Entity Generator. The following code as the "Intergeneration time action" should give different results on each simulation.
% coder.extrinsic is used to make sure that all interactions with the
% random number generator (RNG) and rand() are executed outside of Simulink
coder.extrinsic("rng");
rng('shuffle');
coder.extrinsic("rand");
% You need to explicitly mention the type for the variable that is receiving values
% from a function declared as coder.extrinsic. If not, MATLAB will return value of type mxArray.
newValue = double(0);
newValue = rand();
disp(newValue);
dt = -1*0.22*log(1-rand()) + 0.13 ; % Values generated at random service time
Hope this helps!

Kategorien

Mehr zu Discrete-Event Simulation finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by