forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 2:08 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Levenberg Marquardt Code
PostPosted: Fri Mar 02, 2012 8:20 pm 
Offline

Joined: Tue Oct 25, 2011 6:06 pm
Posts: 5
In the LM optimizer, I sometimes hit max iterations when one direction hessian is huge, although the hessian is fairly constant and in theory it should converge much quicker. After a bit debug I found that it is due to the fact that damping factor lambda v is set to a too large number, and this number is carried on to next generation, therefore essentially it is doing a steepest descent back and forth along the shallow valley. Then I put in code to reset lambda v to small number every time a hessian is calculated, (not including secant), and it works. I can't think of any significant side effect (besides the fact it will take several attempts to increase lambda to a high level if indeed needed) of this change and would like to get a confirmation in this forum, or if this is wrong, please shed some light on the topic:)


Top
 Profile  
 
 Post subject: Re: Levenberg Marquardt Code
PostPosted: Sat Mar 03, 2012 11:12 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Two questions:
1. did you set scale of the variables with MinLMSetScale() call?
2. can you post your code, in particular - function being optimized and initial guess?

Significant downside of your approach is that iteration cost can increase - every time you increase lambda, additional Cholesky decomposition is needed. Algorithm should be able to automatically decrease lambda when needed - that's why I want to study your problem in more details.


Top
 Profile  
 
 Post subject: Re: Levenberg Marquardt Code
PostPosted: Tue Mar 06, 2012 11:55 pm 
Offline

Joined: Tue Oct 25, 2011 6:06 pm
Posts: 5
1. Yes I did set scales but it is hard for me to know the shape ahead of time so the best I can do is to set them more or less equal, at least not orders or magnitude apart.

2. A very simple example is the following parabola:
errorValues[0] = x;
errorValues[1] = 1000*y;
obviously this is only a dumb example because scaling can help, but let's assume we don't know that since in real world that's what I am facing. Initial value is x=1, y=1. The path the optimizer takes is to reduce y to almost zero and then start to bounce in the valley.

Here is what I added to alglib.minlm.minlmiteration(minlmstate state) function:
Code:
        lbl_5:
            state.needfi = false;
            state.repnfunc = state.repnfunc+1;
            state.repnjac = state.repnjac+1;
           
            //
            // New model
            //
            state.modelage = 0;

            // the following are added
            state.lambdav = double.PositiveInfinity;
            double factor = 0.01;
            for (i = 0; i < n - 1; i++)
            {
              double tmpLambdav = factor * Math.Abs(state.quadraticmodel[i, i]) * Math.Sqrt(state.s[i]);
              if (tmpLambdav > double.Epsilon)
                state.lambdav = Math.Min(state.lambdav, tmpLambdav);
            }
            if (double.IsInfinity(state.lambdav))
              state.lambdav = 1;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group