Simulink Design Optimization - Problem with Custom Requirement function

16 views (last 30 days)
HI All,
I have a Simulink model and my aim is to minimize the following
cost_function = rms(Signal_A) + 0.5 rms(Signal_B)
In order to do so I created the following function ( and stored in the current folder with the name my_rms.m)
function objective = my_rms(Signal_A,Signal_B)
objective = rms(Signal_A)+0.5*rms(Signal_B);
end
Therefore I start the Simulink Design Optimization.
Step1. I create a parameters set where model parameters, max and min are specified.
Step2. I create 2 new "Requirement Source": one for Signal_A and one for Signal_B.
Step3. I create a new Time Domain Custom Requirement (using the followings)
  1. Name: Minimize_Response
  2. Specify Function "Type": Minimize the fucntion output
  3. Specify Function "Function": @my_rms
  4. Select Signals and System to Bound: I tick the 2 signals I have previously specified (Signal_A and Signal_B)
At this point I start the optimization and the following error messages come up (see attached picture). The description
Error1 : The function handle passed to the optimize command encountered an error when evaluated with a parameter vector.
Error2: Evaluating the custom requirement 'Minimize_Response' threw an error. The error stack contains a more detailed description of the cause.
Error3: Undefined function 'conj' for input arguments of type 'struct'.
I am almost sure that step 1 and 2 are right as I followed a webseminar on the Mathworks website in doing them, so very likely something in the step 3 is wrong
Can anyone help me with that?
Thanks in advance
G

Answers (1)

Arkadiy Turevskiy
Arkadiy Turevskiy on 1 Apr 2014
The problem is how you defined your objective function. You need to follow a prescribed template.
If you create a new custom objective function, and look at the comments, you will see this:
% The |data| input argument is a structure with fields containing the
% design variable values chosen by the optimizer as well as fields for any
% logged signals required by this requirement.
So, you cannot just assume that the function gets Signal_A and Signal_B as input arguments. No, it gets the structure "data" from which you need to extract signals of interest.
The best way to do it is to follow the shipping example:
Simulink Design Optimization > Response Optimization > Optimize Model Response > Design Optimization to Meet Custom Signal Requirements (GUI)
To see custom cost function used in this example, type
edit sldo_model1_minimize_energy
You will see: (PlantActuator is signal name)
t = data.Nominal.PlantActuator.Time;
y = data.Nominal.PlantActuator.Data;
%Compute a first order approximation to the |PlantActuator| signal energy
objective = sum( (y.^2).*t );
So you need to do something similar.

Community Treasure Hunt

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

Start Hunting!