Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
SimEvents randomising generator block seed in an model executable

Subject: SimEvents randomising generator block seed in an model executable

From: Zlatko

Date: 26 Jul, 2010 02:01:06

Message: 1 of 3

Hi,

I have a SimEvents model which is to be compiled to .exe, using the Real-Time Workshop (RTW) tool, that is to be used for Monte-Carlo simulations. I cannot work out how to make the seeds of the Event-Based Random Number Generators change at each execution of the compiled model.

What I did is to set the seeds to mod(ceil(cputime*99999),2^32), but the expression is evaluated on model compilation and the result is inserted as a constant seed. The same thing happens on using rsimgetrtp() when extracting the model tunable parameters structure and as a result the checksums of the compiled model and the parameter structure don't match and the model throws and error on attempt to be executed.

I tried to set the seeds as tunable parameters but they are not reflected in the tunable parameters structure obtained by rsimgetrtp().

One other thing I could not work out how to do for the compiled model is how to change the simulation stop time.

Any ideas?
Thanks in advance.


Zlatko.

Subject: SimEvents randomising generator block seed in an model executable

From: Amanda Galtman

Date: 26 Jul, 2010 12:31:12

Message: 2 of 3


"Zlatko " <zdz@it-innovation.soton.ac.uk> wrote in message
news:i2iq92$8dp$1@fred.mathworks.com...
> Hi,
> I have a SimEvents model which is to be compiled to .exe, using the Real-Time
> Workshop (RTW) tool, that is to be used for Monte-Carlo simulations. I cannot
> work out how to make the seeds of the Event-Based Random Number Generators
> change at each execution of the compiled model.
> What I did is to set the seeds to mod(ceil(cputime*99999),2^32), but the
> expression is evaluated on model compilation and the result is inserted as a
> constant seed. The same thing happens on using rsimgetrtp() when extracting
> the model tunable parameters structure and as a result the checksums of the
> compiled model and the parameter structure don't match and the model throws
> and error on attempt to be executed.
> I tried to set the seeds as tunable parameters but they are not reflected in
> the tunable parameters structure obtained by rsimgetrtp().
>
> One other thing I could not work out how to do for the compiled model is how
> to change the simulation stop time.
>
> Any ideas?
> Thanks in advance.
>
>
> Zlatko.

Hi Zlatko,

Check out the following example in the SimEvents documentation:

Example: Computing an Ensemble Average Using Rapid Simulation
http://www.mathworks.com/access/helpdesk/help/toolbox/simevents/ug/br7v3l1-1.html

In step 2, the example sets the seed parameters in the Event-Based Random Number
block dialog boxes to the names of variables in the MATLAB workspace. Then in
step 3, the example defines a set of seed values and uses them when calling
rsimsetrtpparam.


As for changing the simulation stop time, see this topic in the Real-Time
Workshop documentation:

Overriding a Model Simulation Stop Time
http://www.mathworks.com/access/helpdesk/help/toolbox/rtw/ug/f14007.html#f6726


Hope this helps,
Amanda

Subject: SimEvents randomising generator block seed in an model executable

From: Amanda Galtman

Date: 26 Jul, 2010 12:32:42

Message: 3 of 3


"Amanda Galtman" <agaltman@mathworks.com> wrote in message
news:i2jv6g$hji$1@fred.mathworks.com...
>
> "Zlatko " <zdz@it-innovation.soton.ac.uk> wrote in message
> news:i2iq92$8dp$1@fred.mathworks.com...
>> Hi,
>> I have a SimEvents model which is to be compiled to .exe, using the Real-Time
>> Workshop (RTW) tool, that is to be used for Monte-Carlo simulations. I cannot
>> work out how to make the seeds of the Event-Based Random Number Generators
>> change at each execution of the compiled model.
>> What I did is to set the seeds to mod(ceil(cputime*99999),2^32), but the
>> expression is evaluated on model compilation and the result is inserted as a
>> constant seed. The same thing happens on using rsimgetrtp() when extracting
>> the model tunable parameters structure and as a result the checksums of the
>> compiled model and the parameter structure don't match and the model throws
>> and error on attempt to be executed.
>> I tried to set the seeds as tunable parameters but they are not reflected in
>> the tunable parameters structure obtained by rsimgetrtp().
>>
>> One other thing I could not work out how to do for the compiled model is how
>> to change the simulation stop time.
>>
>> Any ideas?
>> Thanks in advance.
>>
>>
>> Zlatko.
>
> Hi Zlatko,
>
> Check out the following example in the SimEvents documentation:
>
> Example: Computing an Ensemble Average Using Rapid Simulation
> http://www.mathworks.com/access/helpdesk/help/toolbox/simevents/ug/br7v3l1-1.html
>
> In step 2, the example sets the seed parameters in the Event-Based Random
> Number block dialog boxes to the names of variables in the MATLAB workspace.
> Then in step 3, the example defines a set of seed values and uses them when
> calling rsimsetrtpparam.
>
>
> As for changing the simulation stop time, see this topic in the Real-Time
> Workshop documentation:
>
> Overriding a Model Simulation Stop Time
> http://www.mathworks.com/access/helpdesk/help/toolbox/rtw/ug/f14007.html#f6726
>
>
> Hope this helps,
> Amanda
>
>

Oops, I said step 3 above when I should have said step 4.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us