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

Stopping criterion for Conjugate Gradient method
http://forum.alglib.net/viewtopic.php?f=2&t=3445
Page 1 of 1

Author:  lonelygleaner [ Sun Dec 13, 2015 2:52 am ]
Post subject:  Stopping criterion for Conjugate Gradient method

Hello!

I have a question towards the stopping criterion of CG.

So we could set epsg, epsf, epsx and as long as one of them is satisfied, like |v| < epsg, the solver stops. How can I do something like, the optimization must satisfy two of them, like both epsg and epsf, NOT either of them, to stop?

Thanks!

Author:  Sergey.Bochkanov [ Sun Dec 13, 2015 6:35 pm ]
Post subject:  Re: Stopping criterion for Conjugate Gradient method

Hello!

It is not possible to do out of the box. However, you can check any conditions you want from your callback and call mincgrequesttermination() if you decided to stop. You will have to track algorithm iterations in order to do so. It should be done by calling mincgsetxrep() AND by defining rep() callback which is passed to mincgoptimize().

Author:  lonelygleaner [ Tue Dec 15, 2015 4:27 am ]
Post subject:  Re: Stopping criterion for Conjugate Gradient method

Thanks for your reply! I really appreciate your help :)

I'm afraid that I have some further questions:

1. Is there any way to get the real step size, i.e. the value compared to epsx?

P.S. The values that are used to compare to epsf and epsg are relatively easy to get from the program.

2. Since there is no example code about tracking each iteration. It would be great if you take a quick look at the pseudo codes for rep():

Use epsf and epsx as criteria (This is also the reason why I would like to know how to get step size to compare)

void rep(const real_1d_array &x, double function, void *ptr)
{
if ( ( ( difference of function values) < epsf ) AND ( real step size < epsx) )
call mincgrequesttermination() // is it the right place to call this function here?
}

Author:  Sergey.Bochkanov [ Wed Dec 16, 2015 1:46 pm ]
Post subject:  Re: Stopping criterion for Conjugate Gradient method

1. To get step size you should: a) define rep() callback, b) store each subsequent point reported by optimizer, c) calculate step as difference between last two points reported

2. this feature is less documented, you are right. I can't send you a snippet of code now (working from remote location, no access to compiler to verify code). However, you got key points right.

And, yes - it is right place for miccgrequesttermination().

Author:  lonelygleaner [ Mon Dec 21, 2015 5:25 pm ]
Post subject:  Re: Stopping criterion for Conjugate Gradient method

Sorry for the late reply. I was traveling recently.

Thanks a million for the help! I really enjoy the tool you developed!!

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