forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 8:24 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: Stopping criterion for Conjugate Gradient method
PostPosted: Sun Dec 13, 2015 2:52 am 
Offline

Joined: Sun Dec 13, 2015 2:48 am
Posts: 6
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!


Top
 Profile  
 
 Post subject: Re: Stopping criterion for Conjugate Gradient method
PostPosted: Sun Dec 13, 2015 6:35 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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().


Top
 Profile  
 
 Post subject: Re: Stopping criterion for Conjugate Gradient method
PostPosted: Tue Dec 15, 2015 4:27 am 
Offline

Joined: Sun Dec 13, 2015 2:48 am
Posts: 6
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?
}


Top
 Profile  
 
 Post subject: Re: Stopping criterion for Conjugate Gradient method
PostPosted: Wed Dec 16, 2015 1:46 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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().


Top
 Profile  
 
 Post subject: Re: Stopping criterion for Conjugate Gradient method
PostPosted: Mon Dec 21, 2015 5:25 pm 
Offline

Joined: Sun Dec 13, 2015 2:48 am
Posts: 6
Sorry for the late reply. I was traveling recently.

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


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 30 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group