From: Zlatko on
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.
From: Amanda Galtman on

"Zlatko " <zdz(a)it-innovation.soton.ac.uk> wrote in message
news:i2iq92$8dp$1(a)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


From: Amanda Galtman on

"Amanda Galtman" <agaltman(a)mathworks.com> wrote in message
news:i2jv6g$hji$1(a)fred.mathworks.com...
>
> "Zlatko " <zdz(a)it-innovation.soton.ac.uk> wrote in message
> news:i2iq92$8dp$1(a)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.