what changes i need to make for better answer (fmincon)

Asked by kintali narendra on 17 May 2012
Latest activity Answered by Elizabeth on 30 Jul 2012
>> x0=[10;10;10;0.5;0.5];
>> options=optimset('Algorithm','interior-point');
>> [x,fval]=fmincon(@newfrac,x0,[],[],[],[],[0;0;0;0;0],[inf;inf;inf;0.9;0.9],@confun,options)
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
x =
    0.0000
    0.7587
    0.1891
    0.7928
    0.9000
fval =
-22.0702

i need to reduce my function value to zero.request u tell some changes in the commands i used.

[Information merged from duplicate question]

MAIN FUNCTION

function [f] = newfrac(x)
wcg=2.1; %gain cross over frequency
bb=4;
cc=60;
r = x(1) + (x(2)*(wcg^(-x(4)))*cos(90*x(4)*(pi/180)))+ (x(3)*(wcg^(x(5)))*cos(90*x(5)*(pi/180)));
s = - x(2)*wcg^(-x(4))*sin(90*x(4)*pi/180)+ x(3)*wcg^(x(5))*sin(90*x(5)*pi/180);
fun1=bb/sqrt((cc*wcg)^2 +1);
fun2=sqrt((r)^2 + (s)^2);
f = 10*log10(fun1*fun2);
end

CONSTRAINTS PROGRAM-TO BE SATISFIED BY ABOVE FUNCTION

function [c, ceq] = confun(x)
wcg=2.1;
wt=10;
ws=0.01;
aa=2;
bb=4;
cc=60;
dd=80;
ff=0;
fipm=80; %phase margin
r = x(1) + ( x(2)*(wcg^(-x(4)))*cos(90*x(4)*(pi/180))  )+(x(3)*(wcg^(x(5)))*cos(90*x(5)*(pi/180)));
% pi/180 give degree value in radians
s = - x(2)*(wcg^(-x(4)))*sin(90*x(4)*(pi/180))+ x(3)*(wcg^(x(5)))*sin(90*x(5)*(pi/180));
ru = -x(2)*x(4)*(wcg^(-x(4)-1))*cos(90*x(4)*(pi/180))+ x(3)*x(5)*(wcg^(x(5)-1))*cos(90*x(5)*(pi/180));
su = -x(2)*x(4)*(wcg^(-x(4)-1))*sin(90*x(4)*(pi/180))+ x(3)*x(5)*(wcg^(x(5)-1))*sin(90*x(5)*(pi/180));
rt = x(1) + x(2)*(wt^((-x(4))))*cos(90*x(4)*(pi/180))+ x(3)*(wt^x(5))*cos(90*x(5)*(pi/180)); 
st = -x(2)*(wt^(-x(4)))*sin(90*x(4)*(pi/180))+x(3)*(wt^x(5))*sin(90*x(5)*(pi/180));
rs = x(1) + x(2)*(ws^(-x(4)))*cos(90*x(4)*(pi/180))+ x(3)*(ws^x(5))*cos(90*x(5)*(pi/180));
ss = -x(2)*(ws^(-x(4)))*sin(90*x(4)*(pi/180))+ x(3)*(ws^x(5))*sin(90*x(5)*(pi/180));
%1 equation(41)
c1 = (atan(s/r)*180/pi)-(atan(dd*wcg)*180/pi)-(wcg*ff)+180-fipm;
% 180/pi give radian value in degrees
%2 equation(42)
c21 = 1/(1+(s/r)^2);
c22 = (su*r-s*ru)/(r)^2;
c23 = dd/(1+(dd*wcg)^2);
ceq = [c1;c21*c22-c23-ff];
%3 equation(43)
c31 = aa*sqrt((rt^2) + (st^2));
c32 = sqrt((1+aa*rt)^2 + (dd*wt+aa*st)^2);
c3 = (10*log10(c31/c32))+20;
%4 equation(44)
c41 = sqrt((cc*ws)^2 +1);
c42 = sqrt((1+bb*rs)^2+(cc*ws+bb*ss)^2);
c4 = (10*log10(c41/c42))+20;
c=[c3;c4];
end

SIR THESE TWO ARE PROGRAMS I HAVE WRITTEN IN MATLAB,THE COMMANDS I USED ARE

>> f_obj=@(x)newfrac(x)^2;
>> x0=[10;10;10;0.5;0.5];
>> options=optimset('Algorithm','interior-point');
>> [x,fval]=fmincon(f_obj,x0,[],[],[],[],[0;0;0;0;0],[inf;inf;inf;0.9;0.9],@confun,options)
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
x =
      1.2403
      3.0557
      0.4837
      0.4822
      0.9000
fval =
    104.6186
>> [x,fval]=fmincon(@newfrac,x0,[],[],[],[],[0;0;0;0;0],[inf;inf;inf;0.9;0.9],@confun,options)
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
x =
      0.0000
      0.7587
      0.1891
      0.7928
      0.9000
fval =
    -22.0702

0 Comments

kintali narendra

Products

2 Answers

Answer by Sargondjani on 17 May 2012

-22 is better than 0, so the solution fmincon found is better than what you want... why would you want 0 if the optimum (lowest possible value) is -22???

if you dont want the minimum but find the zero of the funciton, than you should use 'fsolve'

16 Comments

Sean de Wolski on 18 May 2012

And if you aren't giving it a good initial guess it will find the first local minimum it encounters. What do you have for confun? Have you updated this to change for Sargondjani's comments?

If you can't make a good guess on an initial value and want a global minimum GA() might be a better approach.

kintali narendra on 19 May 2012

sir, my aim is to find parameters of 'robust fractional PID controller' the main functions is derived from 'gain margin condition' and constraints are 'phase margin condition','robustness to variation in the gain of the plant' , 'high frequency noise rejection' ,'output disturbance rejection'.............my program is written for mathematical equations derived by imagining plant is first order transfer function with delay. .

Sargondjani on 19 May 2012

this doesnt mean anything to me... all i know is that matlab seems to do the optimization properly, so first you need to find out what you want the optimizer to do, and maybe change the initial guess.

and do you know if the problem is well-behaved?? if it is not, you should try loads of initial guess...

Sargondjani
Answer by Elizabeth on 30 Jul 2012
Edited by Elizabeth on 30 Jul 2012

Hello sir, I obtained what I assume to be the correct result for your program:

Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the default value of the function tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
x =
    0.3348
    2.5203
    0.5623
    0.5791
    0.8251
fval =
  1.5559e-013

I obtained this result my manipulating the logarithm function in you objective function. You can now write it as follows:

function [f] = newfrac(x)
wcg=2.1; %gain cross over frequency
bb=4;
cc=60;
r = x(1) + (x(2)*(wcg^(-x(4)))*cos(90*x(4)*(pi/180)))+ (x(3)*(wcg^(x(5)))*cos(90*x(5)*(pi/180)));
s = - x(2)*wcg^(-x(4))*sin(90*x(4)*pi/180)+ x(3)*wcg^(x(5))*sin(90*x(5)*pi/180);
fun1=bb/sqrt((cc*wcg)^2 +1);
fun2=sqrt((r)^2 + (s)^2);      
fun_x=fun1*fun2;
origf=10*log10(fun_x); 
f= 10^origf;
end

PROOF: ****************************************************************

===> For purposes of our discussion, Let:

    x = fun_x = fun1*fun2
    b = 10 (our base of the log)
    k = 10 (the constant)
    y= origf (the original expression for the objective function)

===> Therefore, the original function f that you had can be written as

    y=k*logb(x) (EQ1)

===> By the properties of logarithmic functions, then

     y= b^[klogb(x)]=x (EQ2)

===> Meanwhile, the following theorem must hold true

    y=k*logb(x) if and only if b^y=x EQ(3)

===> Using EQs (1-3) and substitution, one can see--

     y=k*logb(x)=b^[klogb(x)]

===> Or, in other words,

    y=origf=10*log10(fun_x) EQ(4)
    iff y=10^[10*log10(fun_x)=f (EQ5)

===> and so, we note EQ(4) is equivalent to EQ(5), but EQ(4) is ill-conditioned in comparison to EQ(5). ***************************************************** In conclusion, the only issue I think you need to correct is to rewrite your objective function in the form of EQ(5)

0 Comments

Elizabeth

Contact us