ADMB Documentation  11.2.2828
 All Classes Files Functions Variables Typedefs Friends Defines
f1b2lapqd.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: f1b2lapqd.cpp 2268 2014-08-28 23:42:48Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #  include <admodel.h>
00012 #  include <df1b2fun.h>
00013 #  include <adrndeff.h>
00014 #include <cassert>
00015 
00016 //dvariable AD_uf_inner(const dvector& x,const dvar_vector& u);
00017 void get_second_ders(int xs,int us,const init_df1b2vector y,dmatrix& Hess,
00018   dmatrix& Dux, df1b2_gradlist * f1b2gradlist,function_minimizer * pfmin);
00019 double calculate_laplace_approximation(const dvector& x,const dvector& u0,
00020   const dmatrix& Hess,const dvector& _xadjoint,const dvector& _uadjoint,
00021   const dmatrix& _Hessadjoint,function_minimizer * pmin);
00022 
00027 dvector laplace_approximation_calculator::get_uhat_quasi_newton_qd
00028   (const dvector& x,function_minimizer * pfmin)
00029 {
00030   dvector g(1,usize);
00031   independent_variables u(1,usize);
00032   fmc1.itn=0;
00033   fmc1.crit=1.e-9;
00034   fmc1.ifn=0;
00035   fmc1.ireturn=0;
00036   initial_params::xinit(u);    // get the initial values into the
00037   u.initialize();
00038 
00039   ofstream * tmpfile= ad_comm::global_savefile;
00040   ad_comm::global_savefile=new ofstream("catageqd.ppp");
00041   if (ad_comm::global_savefile)
00042   {
00043     for (int i=0;i<initial_params::num_initial_params;i++)
00044     {
00045        (initial_params::varsptr[i])->save_value();
00046     }
00047     delete ad_comm::global_savefile;
00048     ad_comm::global_savefile=tmpfile;
00049   }
00050 
00051   int ret = system(" catageqd -nox -nohess -crit 1.e-10 -ainp catageqd.ppp ");
00052   assert(ret == 0);
00053 
00054   uistream ifs("uval.dat");
00055 
00056   ifs >> u;
00057 
00058   return u;
00059 }
00060 
00061 /*
00062 For no laplace
00063 dvector laplace_approximation_calculator::get_uhat_quasi_newton_qd
00064   (const dvector& x,function_minimizer * pfmin)
00065 {
00066   dvector u(1,1)
00067   return u;
00068 }
00069 */