forum.alglib.net
http://forum.alglib.net/

minlm unexpected terminationtype
http://forum.alglib.net/viewtopic.php?f=2&t=738
Page 1 of 1

Author:  hebi [ Tue Nov 27, 2012 3:32 pm ]
Post subject:  minlm unexpected terminationtype

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

Author:  Sergey.Bochkanov [ Tue Nov 27, 2012 5:43 pm ]
Post subject:  Re: minlm unexpected terminationtype

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

Author:  hebi [ Wed Nov 28, 2012 7:54 am ]
Post subject:  Re: minlm unexpected terminationtype

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!

Author:  Sergey.Bochkanov [ Wed Nov 28, 2012 10:14 am ]
Post subject:  Re: minlm unexpected terminationtype

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.

Author:  hebi [ Wed Nov 28, 2012 10:47 am ]
Post subject:  Re: minlm unexpected terminationtype

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

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/