Controller Tuning : NMinimize of Mathematica versus ga command of Matlab​
​Authors: Housam Binous and Ahmed Bellagi

MATLAB code given below uses genetic algorithms for PI controller tuning
MATHEMATICA code below uses NMINIMIZE to fetch best PI controller parameters
In[]:=
Gc[KP_?NumericQ,TAUI_?NumericQ]:=KP+TAUI/s;​​GT=1/(s+1)/(s+2)/(s+3)
Out[]=
1
(1+s)(2+s)(3+s)
In[]:=
G[KP_?NumericQ,TAUI_?NumericQ]:=GTGc[KP,TAUI]/(1+GTGc[KP,TAUI])
In[]:=
y[KP_?NumericQ,TAUI_?NumericQ]:=InverseLaplaceTransform[1/sG[KP,TAUI],s,t]//Chop;
ISE CRITERIA
In[]:=
f1[KP_?NumericQ,TAUI_?NumericQ]:=Re[Quiet@NIntegrate[(1-y[KP,TAUI])^2,{t,0,100}]//Chop];(*IAE*)
In[]:=
NMinimize[f1[KP,TAUI],{KP,TAUI},MaxIterations->10]
Out[]=
{0.696163,{KP20.2936,TAUI5.69175}}
OUTPUT FOR MATLAB code
IAE CRITERIA
In[]:=
f2[KP_?NumericQ,TAUI_?NumericQ]:=Re[Quiet@NIntegrate[Abs[1-y[KP,TAUI]],{t,0,100}]//Chop];(*IAE*)
In[]:=
NMinimize[f2[KP,TAUI],{KP,TAUI},MaxIterations->10]
Out[]=
{1.28738,{KP11.8884,TAUI5.97855}}
OUTPUT FOR MATLAB code
ITAE CRITERIA
f3[KP_?NumericQ,TAUI_?NumericQ]:=Re[Quiet@NIntegrate[tAbs[1-y[KP,TAUI]],{t,0,100}]//Chop];(*IAE*)
In[]:=
NMinimize[f3[KP,TAUI],{KP,TAUI},MaxIterations->10]
Out[]=
{1.52359,{KP7.21523,TAUI4.9157}}
OUTPUT FOR MATLAB code