[ADMB Users] sorted minimizer display?

dave fournier davef at otter-rsch.com
Tue Aug 20 11:40:54 PDT 2013


On 13-08-20 11:25 AM, Ian Taylor - NOAA Federal wrote:

What's wrong with you people!  I was just trying to illustrate a few 
ideas about printing out
the variables sorted by gradient magnitude. The function minimizer only 
prints out the values
at an iteration.  If you want to see the values for each function 
evaluation you need to do
something a bit different.  What I posted is a simple way to do this. 
Obviously it needs a bit of dressing up.

If you don't like my ideas you are certainly welcome to do something 
else (assuming you ever get the time
of course).




> 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 
> <mailto: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 <mailto:Users at admb-project.org>
>     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/68b51027/attachment.html>


More information about the Users mailing list