forum.alglib.net

ALGLIB forum
It is currently Sat Apr 27, 2024 6:16 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  [ 3 posts ] 
Author Message
 Post subject: Getting Results from CG optimisation
PostPosted: Sat Jan 21, 2012 7:09 pm 
Offline

Joined: Sat Jan 21, 2012 7:00 pm
Posts: 3
I am having great trouble getting results from the mincgresults() function. The code is as follows:
Code:
   alglib::real_1d_array lambdaJout;
   lambdaJout.setlength(lenJ);
   for (int i = 0; i < lenJ; i++) {
      lambdaJout[i] = 0.0;
   }
   
   alglib::mincgcreatef(lambdaJguess, diffstep, cgstate);
   alglib::mincgsetcond(cgstate, epsg, epsf, epsx, maxits);
   alglib::mincgsetscale(cgstate, lambdascale);
   alglib::mincgsetprecscale(cgstate);
   alglib:mincgoptimize(cgstate, CG_opt, NULL, ptr);
   mincgresults(cgstate, lambdaJout, cgrep);

   printf("cg rep termination = %i\n", int(cgrep.terminationtype));
   
   FILE* lambdaoptout = fopen("lambdaopt.txt", "w");
   for (int i = 0; i < lenJ; i++) {
      fprintf(lambdaoptout, "%i %e\n", i, lambdaJout[i]);
   }
   fclose(lambdaoptout);


It seems that no matter what I try to do with mincgresults, I cannot get anything but zeros in the print statement.

The code runs, and the cg rep termination result is 1, but lambdaJout never seems to change. I can post more of the code if needed, and would very much appreciate an help people can offer.

Thanks.


Top
 Profile  
 
 Post subject: Re: Getting Results from CG optimisation
PostPosted: Mon Jan 23, 2012 5:55 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
Please, post all code which works with ALGLIB: a) initialization of lambdaJguess, diffstep and other parameters, b) CG_opt() function, c) everything else which can influence results. I will help you with this issue, but I need more info :)


Top
 Profile  
 
 Post subject: Re: Getting Results from CG optimisation
PostPosted: Tue Jan 24, 2012 5:54 pm 
Offline

Joined: Sat Jan 21, 2012 7:00 pm
Posts: 3
Dear Sergey,

I have found that my error comes from having very badly miscalculated the scaling. Have fixed this, and now get results.

Thank you for your response, and for creating the library.


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

All times are UTC


Who is online

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