# 目的関数

## 概要

Objective function to optimize欄では、目的関数に適用する演算を選択する必要があります。これは、提供されるPredefined Operationの簡単なリストで定義するか、Composeで定義されたカスタム関数で定義できます。

## 事前定義された演算

Sum of squares of responses（SSQ）

## Compose関数

%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 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

パラメータrparamrrpesp(1)と、関数の名前を変更してはなりません。

OMLファイルは.FLUプロジェクトと同じフォルダー内に配置する必要があります。