Objective function
Introduction
In the field Objective function to optimize, an operation to apply on the objective function must be choosed, it can be defined on the available short list of Predefined Operation, or with a custom function defined with Compose.
The table bellow section summarizes all the predefined operations.
Predefined Operations
Function | Formula |
---|---|
Design responses (global optimization of the arguments) | |
Average of responses (AVG) | |
Average of absolute value of responses (AVGABS) | |
Maximum of responses (MAX) | |
Maximum of absolute responses (MAXABS) | |
Minimu of responses (MIN) | |
Minimum of absolute responses (MINABS) | |
Root mean square value of responses (RMS) | |
Square root of sum of squares of responses (RSS) | |
Sum of square responses (SSQ) | |
Sum of responses (SUM) | |
Sum of absolute value of responses (SUMABS) |
Compose function
A custom operation on the quantities may also be defined with a Compose function, this function must return a scalar value. An example of this function is given below:
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Objective function %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
function [rresp, dresp, udata] = Obj_Func(iparam, rparam, nparam, iresp, rresp, dresp, nresp, isens, udata)
% iparam - vector of ints
% rparam - vector of doubles
% nparam - size of input vector
% iresp - vector of ints
% rresp - output parameter (vector of ints)
% dresp - output parameter (matrix of MxN dimension)
% nresp - size of output vector
% isens - sensitivity flag
% udata - userdata
Torque = rparam(1:nparam); % This variable contains all the values of the reponses for all the time steps,
% In this function, it contains the torque for each time step over an electrical period
Tr = mean(Torque) % Custom function based on the response previouly defined in Flux, computation of the torque ripple
rresp(1) = Tr % The mean value of the torque is used as an objective function
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Constraint function %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Lower and upper bounds of the constraint function are setted Flux
function [rresp, dresp, udata] = Cons(iparam, rparam, nparam, iresp, rresp, dresp, nresp, isens, udata)
% iparam - vector of ints
% rparam - vector of doubles
% nparam - size of input vector
% iresp - vector of ints
% rresp - output parameter (vector of ints)
% dresp - output parameter (matrix of MxN dimension)
% nresp - size of output vector
% isens - sensitivity flag
% udata - userdata
Torque = rparam(1:nparam); % This variable contains all the values of the reponses for all the time steps,
% In this function, it contains the torque for each time step over an electrical period
Tr = ( ( max(Torque) - min(Torque) ) / mean(Torque) ) *100 % Custom function based on the response previouly defined in Flux, computation of the torque ripple rate
rresp(1) = Tr
end
The OML file must be in the same folder as the .FLU project.