From: Nils on
Hello everyone,

I'm performing parameter estimation using Simulink on a model containing the following blocks:
- Input, output ports
- Sums
- Gains (containing estimated parameters)
- 1/s
- Abs
- Switch (containing estimated parameters)
- Fcn (containing estimated parameters)
- A subsystem containing nothing more than above mentioned blocks.

The following simulation configuration is being used:
- Simulation option is 'Accelerator' in both the system and subsystem block.
- Under simulation/'configuration parameters'/Optimization/'Accelerating simulations'/'compiler optimization level' is set to 'Optimizations on (faster runs)'
- Under simulation/'configuration parameters'/'Real-Time Workshop':
Language is set to C.
Compiler Optimization Level is set to 'Optimizations on'

The simulations themselves go really fast and smooth, however, at each iteration the model itself is initialized and the MATLAB command window says

'### Building the Accelerator target for model: model1
### Successfully built the Accelerator target for model: model1'

This does just mean that the model is recompiled at each iteration, right? My question is then, why? Is it due to the fact that some of the estimated parameters are in the switch and Fcn blocks? Can the repeated rebuilding be avoided in some way?

Under
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/brc69t5-1.html
my case doesn't seem to appear so rebuilds shouldn't be necessary. Howevery, on that page it also says
'Run-time parameters are collected within an rtp structure either by user specification via a simset option or through automatic collection during the compile phase. Changes to the Run-time parameters are supported if they are passed directly to sim. However, if they are passed graphically via the block diagram or programmatically via the set_param command, then a rebuild may be necessary. All other parameter changes may necessitate a rebuild.'
I'm not sure how to interpret that.

Any suggestions are more than welcome!
From: Alec Stothert on
Hi

It's probably the estimated parameter in the Fcn block thats causing the
model to recompile; from the Fcn block help "...You cannot tune this
expression during simulation in Normal or Accelerator mode".

To confirm this I created a simple model with a switch (parameter Kswitch)
and Fcn block (parameter Kfcn) and varied the value of Kfcn manually which
caused the model to recompile. Varying Kswitch did not cause the model to
recompile. Depending on your model you could do a similar experiment, run
the model, then vary the estimated parameters one-by-one rerunning the model
each time to see which causes the model to recompile.

-Alec


"Nils " <do_not_use(a)gmail.com> wrote in message
news:hp1mge$6ch$1(a)fred.mathworks.com...
> Hello everyone,
>
> I'm performing parameter estimation using Simulink on a model containing
> the following blocks: - Input, output ports - Sums - Gains (containing
> estimated parameters) - 1/s
> - Abs
> - Switch (containing estimated parameters)
> - Fcn (containing estimated parameters)
> - A subsystem containing nothing more than above mentioned blocks.
>
> The following simulation configuration is being used:
> - Simulation option is 'Accelerator' in both the system and subsystem
> block.
> - Under simulation/'configuration parameters'/Optimization/'Accelerating
> simulations'/'compiler optimization level' is set to 'Optimizations on
> (faster runs)'
> - Under simulation/'configuration parameters'/'Real-Time Workshop':
> Language is set to C.
> Compiler Optimization Level is set to 'Optimizations on'
>
> The simulations themselves go really fast and smooth, however, at each
> iteration the model itself is initialized and the MATLAB command window
> says
> '### Building the Accelerator target for model: model1
> ### Successfully built the Accelerator target for model: model1'
>
> This does just mean that the model is recompiled at each iteration, right?
> My question is then, why? Is it due to the fact that some of the estimated
> parameters are in the switch and Fcn blocks? Can the repeated rebuilding
> be avoided in some way?
>
> Under
> http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/brc69t5-1.html
> my case doesn't seem to appear so rebuilds shouldn't be necessary.
> Howevery, on that page it also says
> 'Run-time parameters are collected within an rtp structure either by user
> specification via a simset option or through automatic collection during
> the compile phase. Changes to the Run-time parameters are supported if
> they are passed directly to sim. However, if they are passed graphically
> via the block diagram or programmatically via the set_param command, then
> a rebuild may be necessary. All other parameter changes may necessitate a
> rebuild.'
> I'm not sure how to interpret that.
>
> Any suggestions are more than welcome!
>


From: Nils on
Ah, ok! That makes sense. Thanks for the help!

Another thing though.... would it matter if I rewrote the Fcn with the help of blocks instead? All the blocks I would need are
sum
multiply
exponential
sign

In that case the estimated parameters would appear only as gains... but they got through mathematical functions so I'm not sure if it still would compile.
From: Nils on
Update: I undertook converting it to a system of blocks and it works indeed!

This virtually decimates the estimation time from before. It almost feels like upgrading from my (dear old) mbp to a 8 core machine.

Again, thank you so much!!!