Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fminsearch with 7 parameters

Subject: Fminsearch with 7 parameters

From: Saad

Date: 4 Aug, 2011 10:27:11

Message: 1 of 7

Dear all,

I am using fminsearch to minimize a function with 7 parameters..the function is very long. Fminsearch doesnt converge, each time it iterates the value of the function doesnt change (it doesnt minimize). Any ideas where the problem is?

Thanks a lot

Saad

Subject: Fminsearch with 7 parameters

From: Steven_Lord

Date: 4 Aug, 2011 13:14:11

Message: 2 of 7



"Saad " <saad.badaoui07@imperial.ac.uk> wrote in message
news:j1ds5v$45a$1@newscl01ah.mathworks.com...
> Dear all,
>
> I am using fminsearch to minimize a function with 7 parameters..the
> function is very long. Fminsearch doesnt converge, each time it iterates
> the value of the function doesnt change (it doesnt minimize). Any ideas
> where the problem is?

Insufficient information.

What is the function you're trying to minimize?
Do you use ROUND, CEIL, FIX, or FLOOR in your function?
What does FMINSEARCH say when it finishes trying to minimize your function?

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Fminsearch with 7 parameters

From: Matt J

Date: 4 Aug, 2011 13:25:27

Message: 3 of 7

"Saad " <saad.badaoui07@imperial.ac.uk> wrote in message <j1ds5v$45a$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I am using fminsearch to minimize a function with 7 parameters..the function is very long. Fminsearch doesnt converge, each time it iterates the value of the function doesnt change (it doesnt minimize). Any ideas where the problem is?
======================

In addition to the questions Steve raised, be advised that FMINSEARCH may not converge. There is no theory guaranteeing convergence of that particular algorithm for more than 1 variable, and increasing the number of variables tends to diminish your chances.

Subject: Fminsearch with 7 parameters

From: Saad

Date: 6 Aug, 2011 10:31:10

Message: 4 of 7

"Matt J" wrote in message <j1e6k7$7lm$1@newscl01ah.mathworks.com>...
> "Saad " <saad.badaoui07@imperial.ac.uk> wrote in message <j1ds5v$45a$1@newscl01ah.mathworks.com>...
> > Dear all,
> >
> > I am using fminsearch to minimize a function with 7 parameters..the function is very long. Fminsearch doesnt converge, each time it iterates the value of the function doesnt change (it doesnt minimize). Any ideas where the problem is?
> ======================
>
> In addition to the questions Steve raised, be advised that FMINSEARCH may not converge. There is no theory guaranteeing convergence of that particular algorithm for more than 1 variable, and increasing the number of variables tends to diminish your chances.


Hi Steve

Thanks for your reply. I actually simplified my function to see if the problem is coming from my function or the algorithm. Here is the function:


function Yield_Final = bond3(def_ind)


 %%%constant%%%%
f_b=0.01;
f_gb=0.02;
K=(1+ f_b + f_gb);

phi=sqrt(2*sig^2*K + beta^2);

k=(beta + phi)/( beta-phi);
t=0;
dt=1/360;
T=50;
%%%%Loop%%%%%

  summm3=0;

for i=5:5:50
    
    
a1_a(1,i+1)=((1-k)/(1-k*exp(phi*((i+1)./5-t))))^(2*alpha/(sig^2)) * exp(alpha*(beta+ phi)*((i+1)./5-t)*(1/sig^2));

a2_a(1,i+1)=((phi-beta)/(sig^2*K))+ (2*phi/(sig^2*K*(k*exp(phi*((i+1)./5-t))-1)));

def(1,i+1)=a1_a(1,i+1-t)* exp(-a2_a(1,i-t)*def_ind*K);

 summm3= summm3+ def(1,i+1)


end

    Yield_Final=summm3;
    
I would like to minimize this function with respect to the parameter "def_ind" but my function doesnt minimize. IS it because of the loop? my function is the sum of "def".... but the parameters is inside the loop and i dont understand why the function doesnt change value when fimisearch algorithm runs..Please any help or suggestion would very welcomed thanks a lot

S

Subject: Fminsearch with 7 parameters

From: Matt J

Date: 6 Aug, 2011 15:47:11

Message: 5 of 7

"Saad " <saad.badaoui07@imperial.ac.uk> wrote in message <j1j55e$a4a$1@newscl01ah.mathworks.com>...
>
> %%%%Loop%%%%%
>
> summm3=0;
>
> for i=5:5:50
>
>
> a1_a(1,i+1)=((1-k)/(1-k*exp(phi*((i+1)./5-t))))^(2*alpha/(sig^2)) * exp(alpha*(beta+ phi)*((i+1)./5-t)*(1/sig^2));
>
> a2_a(1,i+1)=((phi-beta)/(sig^2*K))+ (2*phi/(sig^2*K*(k*exp(phi*((i+1)./5-t))-1)));
>
> def(1,i+1)=a1_a(1,i+1-t)* exp(-a2_a(1,i-t)*def_ind*K);
>
> summm3= summm3+ def(1,i+1)
>
>
> end
>
> Yield_Final=summm3;
>
> I would like to minimize this function with respect to the parameter "def_ind" but my function doesnt minimize. IS it because of the loop? my function is the sum of "def".... but the parameters is inside the loop and i dont understand why the function doesnt change value when fimisearch algorithm runs..Please any help or suggestion would very welcomed thanks a lot
============================

The reason the value doesn't change is because your function is a constant for all def_ind. This quantity in you loop

 exp(-a2_a(1,i-t)*def_ind*K)

is the only quantity affected by the unknown variable def_ind and it always evaluates to 1, because a2_a(1,i-t) is always zero.

Subject: Fminsearch with 7 parameters

From: Saad

Date: 6 Aug, 2011 23:26:10

Message: 6 of 7

"Matt J" wrote in message <j1jnlv$ic$1@newscl01ah.mathworks.com>...
> "Saad " <saad.badaoui07@imperial.ac.uk> wrote in message <j1j55e$a4a$1@newscl01ah.mathworks.com>...
> >
> > %%%%Loop%%%%%
> >
> > summm3=0;
> >
> > for i=5:5:50
> >
> >
> > a1_a(1,i+1)=((1-k)/(1-k*exp(phi*((i+1)./5-t))))^(2*alpha/(sig^2)) * exp(alpha*(beta+ phi)*((i+1)./5-t)*(1/sig^2));
> >
> > a2_a(1,i+1)=((phi-beta)/(sig^2*K))+ (2*phi/(sig^2*K*(k*exp(phi*((i+1)./5-t))-1)));
> >
> > def(1,i+1)=a1_a(1,i+1-t)* exp(-a2_a(1,i-t)*def_ind*K);
> >
> > summm3= summm3+ def(1,i+1)
> >
> >
> > end
> >
> > Yield_Final=summm3;
> >
> > I would like to minimize this function with respect to the parameter "def_ind" but my function doesnt minimize. IS it because of the loop? my function is the sum of "def".... but the parameters is inside the loop and i dont understand why the function doesnt change value when fimisearch algorithm runs..Please any help or suggestion would very welcomed thanks a lot
> ============================
>
> The reason the value doesn't change is because your function is a constant for all def_ind. This quantity in you loop
>
> exp(-a2_a(1,i-t)*def_ind*K)
>
> is the only quantity affected by the unknown variable def_ind and it always evaluates to 1, because a2_a(1,i-t) is always zero.


Hi Steve

Thanks a lot for your help on this. You are right. It seems that the value of exp(-a2_a(1,i-t)*def_ind*K) stays around one and that the value of a1_a tend to zero. I am basically replicating the result of a paper...Iam pretty sure that there is a way to minimize this function by changing def_ind. Do you think that playing around with the values of the parameters would help? or rewriting the function in a way that could help the minimization? Thank you for your advice on this....Best Regards

S

Subject: Fminsearch with 7 parameters

From: Matt J

Date: 6 Aug, 2011 23:39:10

Message: 7 of 7

"Saad " <saad.badaoui07@imperial.ac.uk> wrote in message <j1kiii$e9a$1@newscl01ah.mathworks.com>...
>
>
> Thanks a lot for your help on this. You are right. It seems that the value of exp(-a2_a(1,i-t)*def_ind*K) stays around one and that the value of a1_a tend to zero.
==================

a1_a is always zero *exactly*.
This causes exp(-a2_a(1,i-t)*def_ind*K) to be *exactly* 1 all the time.




I am basically replicating the result of a paper...Iam pretty sure that there is a way to minimize this function by changing def_ind. Do you think that playing around with the values of the parameters would help? or rewriting the function in a way that could help the minimization? Thank you for your advice on this....Best Regards
=======================

You should rewrite the function, removing the bugs we have identified above.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us