ADMB Documentation  11.1.2274
 All Classes Files Functions Variables Typedefs Friends Defines
minim.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: minim.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <fvar.hpp>
00012 
00020 double fmm::minimize(const independent_variables & x,
00021   double (*pf)(const dvar_vector&))
00022 {
00023   int nvar=x.size();
00024   double f;
00025   dvector g(1,nvar);
00026 #ifndef SAFE_INITIALIZE
00027   g.initialize();
00028 #endif
00029   {
00030     gradient_structure gs;
00031     while (ireturn >= 0)
00032     {
00033       fmin(f,x,g);
00034       if(ireturn > 0)
00035       {
00036         {
00037           f=(*pf)(x);
00038         }
00039         gradcalc(nvar,g);
00040       }
00041     }
00042   }
00043   return(f);
00044 }