# forum.alglib.net

ALGLIB forum
 It is currently Mon Aug 08, 2022 10:35 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.

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Stopping criterion for Conjugate Gradient methodPosted: Sun Dec 13, 2015 2:52 am

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

 Post subject: Re: Stopping criterion for Conjugate Gradient methodPosted: Sun Dec 13, 2015 6:35 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 878
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

 Post subject: Re: Stopping criterion for Conjugate Gradient methodPosted: Tue Dec 15, 2015 4:27 am

Joined: Sun Dec 13, 2015 2:48 am
Posts: 6

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

 Post subject: Re: Stopping criterion for Conjugate Gradient methodPosted: Wed Dec 16, 2015 1:46 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 878
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

 Post subject: Re: Stopping criterion for Conjugate Gradient methodPosted: Mon Dec 21, 2015 5:25 pm

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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for: