[ADMB Users] sorted minimizer display?
Ian Taylor - NOAA Federal
ian.taylor at noaa.gov
Tue Aug 20 11:25:50 PDT 2013
I don't see that I was conflating things nor that it's too complicated
(though Dave would surely know better).
As noted in the Redmine Issue<http://www.admb-project.org/redmine/issues/109>,
the file fmm_disp.cpp<http://admb-project.org/documentation/api/fmm__disp_8cpp_source.html>is
what currently displays the gradient values during the minimization
process. If this is not the ideal time to calculate gradient values, then
we've been looking at the wrong numbers all along. If it is indeed the
right time, one option would be to revise fmm_disp.cpp to display them in
an alternative order as John suggests. Another (or parallel) option would
be to add a section to fmm_disp.cpp to write the same values to a file
which could be sorted in any order. Presumably writing to a file would slow
things down slightly, so you would want it as an option, not the default
behavior.
Currently you can redirect all the command window text to a file and then
parse this file to get the gradient info. However, the 3-column format for
the gradients makes this slightly more tedious than it has to be.
-Ian
On Tue, Aug 20, 2013 at 8:27 AM, dave fournier <davef at otter-rsch.com> wrote:
>
> Well this is a bit complicated because there are various loops where the
> function and
> gradient are calculated and various function minimizers. What I would do
> is to
> compile my code with debug info and but a breakpoint in the userfunction.
> Then
> a stack trace will find where you are. In my case df1b2qnm.cpp around
> line 185.
> the loop looks like
>
>
>
> while (fmc.ireturn>=0)
> {
> fmc.fmin(f,x,g);
> if (fmc.ireturn>0)
> {
> dvariable vf=0.0;
> vf=initial_params::reset(dvar_**vector(x));
> *objective_function_value::**pobjfun=0.0;
> pre_userfunction();
> vf+=*objective_function_value:**:pobjfun;
> f=value(vf);
> gradcalc(nvar,g);
> }
> }
>
> To make it simple lets print out every function evaluation.
>
> ofstream ofs("stuff");
>
> while (fmc.ireturn>=0)
> {
> fmc.fmin(f,x,g);
> if (fmc.ireturn>0)
> {
> dvariable vf=0.0;
> vf=initial_params::reset(dvar_**vector(x));
> *objective_function_value::**pobjfun=0.0;
> pre_userfunction();
> vf+=*objective_function_value:**:pobjfun;
> f=value(vf);
> gradcalc(nvar,g);
>
> printstuff(f,x,g,ofs);
> }
> }
>
> void printstuff(double f,const dvector& x,const dvector& g,const ofstream&
> ofs)
> {
> int n=g.indexmax();
> dmatrix TS(1,2,1,n);
>
> TS(1).fill_seqadd(1,1);
> TS(2)=fabs(g);
>
> dmatrix S=trans(TS);
>
> S=sort(S,2);
>
> ivector index=ivector(column(S,1)); // can use index to print out
> what you want
>
> for (int i=n;i>=n;i--)
> {
> ofs << x(ind(i)) << " " << g(ind(i)) << endl;
> }
>
> This is probably in decreasing order
>
>
>
>
>
>
>
> ______________________________**_________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/**mailman/listinfo/users<http://lists.admb-project.org/mailman/listinfo/users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20130820/de9ca4a1/attachment.html>
More information about the Users
mailing list