forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 6:02 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  [ 5 posts ] 
Author Message
 Post subject: minlm unexpected terminationtype
PostPosted: Tue Nov 27, 2012 3:32 pm 
Offline

Joined: Tue Nov 27, 2012 3:10 pm
Posts: 3
Hello there,

I'm new to alglib and first of all want to thank for this great piece of code :-)
But I have a problem when running the LM minimization. I am running the minimization with epsG and maxit values. The Rest of the eps-values are set to zero. So I expect a terminationtype either of 4 or 5. But instead I am getting terminationtype 2, which is corresponding to epsX. Also, the result is not very good yet so it looks like the termination was too early. Could anyone explain me why I am getting this terminationtype and what I can do to improve the results?

Regards,
Hebi


Top
 Profile  
 
 Post subject: Re: minlm unexpected terminationtype
PostPosted: Tue Nov 27, 2012 5:43 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Unexpected termination type can occur when algorithm performs step which is exactly zero - in this case multiple stopping criteria are satisfied simultaneously (gradient=step=delta_F=0).

One of the possible reasons is that you've incorrectly calculated analytic gradient - error in one of its components can stop algorithm almost immediately. Of course, bugs in algorithm are possible too.

I recommend you to:
1. use minlmsetgradientcheck to check correctness of gradient
2. in case no errors is reported, post your code at this topic, so I will be able to study it and understand why algorithm stops early


Top
 Profile  
 
 Post subject: Re: minlm unexpected terminationtype
PostPosted: Wed Nov 28, 2012 7:54 am 
Offline

Joined: Tue Nov 27, 2012 3:10 pm
Posts: 3
Thanks for the quick reply!
I don't provide an analytic gradient function at all. I am just using minlmcreatev like in the minlm_d_v example. Is a gradient needed in my case?
I want to fit a superellipsoid into a set of 3d points. The ellipsoid has 11 parameters (3x position, 3x orientation, 3x size, 2x shape parameter) So I basically do this in my fvec-function:

Kind of pseudo-code
Code:
myfunc(const real_1d_array &x, real_1d_array &fi, void* ptr) {
  Points* points = (Points*) ptr;
  transform(points, x[0], ..., x[5]);

  for each p in points {
    tmpx = p.x / x[6];
    F1 = pow(tmpx * tmpx, 1.0/x[10]);
    tmpy = p.y / x[7];
    F2 = pow(tmpy * tmpy, 1.0/x[10]);
    tmpz = p.z / x[8];
    F3 = pow(tmpz * tmpz, 1.0/x[9]);
    FA = pow(F1 + F2, x[10]/x[9]);
    double F = pow(FA + F3, x[9]);
    fi[i] = sqrt(x[6]*x[7]*x[8]) * (F - 1);
  }
}


I already checked fi[i] for contating infinity, nan or the like, but it does not. The Equation is taken from this aged paper.

Thanks!


Top
 Profile  
 
 Post subject: Re: minlm unexpected terminationtype
PostPosted: Wed Nov 28, 2012 10:14 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Maybe you should add some constraints on your parameters? Something like x[i]>=eps>0.

You divide by x[6], x[7], x[8], x[9] and x[10], so you may have problems when algorithm tries to step to x[i]<0. Sqrt(x[6]*x[7]*x[8]) is another possible source of numerical difficulties.

BTW, can you post full code here? I will try to debug LM algorithm and understand why it stalls on your problem. In any case, it is interesting to debug algorithm one more time on real-life problem.


Top
 Profile  
 
 Post subject: Re: minlm unexpected terminationtype
PostPosted: Wed Nov 28, 2012 10:47 am 
Offline

Joined: Tue Nov 27, 2012 3:10 pm
Posts: 3
Sorry, I forogt to mention that I actually do set upper and lower boundaries. Especially x[9] and x[10] may not be smaller than 0.01 because if it is too small pow returns infinity.
The problem with full code is that I am having some other bigger dependencies. So I would have to extract a minimal code from it being independent from any other library. That would take me some time. I'll work on that at the weekend...

EDIT: lower bound for x[6], x[7] and x[8] is 0.001


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 16 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