32 #if defined(USE_ADPVM)
111 for (i=1;i<=xsize;i++)
115 for (i=1;i<=usize;i++)
125 double bestf=do_one_feval(xx,pfmin);
128 cout <<
"input Delta" <<
endl;
130 cout <<
"input lambda" <<
endl;
133 int max_iteration=10;
143 get_complete_hessian(H,g,pfmin);
164 cout <<
"initial fun value - " << double(0.5)*xx*(H*xx)+xx*g;
165 double truef=do_one_feval(xx,pfmin);
166 cout <<
"real function value = " << truef <<
endl;
173 dvector xret=lincg(xx,g,H,tol,Delta,pfmin,truef,estdiff,
174 truediff,bestf,iflag,inner_iter,maxfn);
175 cout <<
" norm(g) = " <<
norm(g)
176 <<
" norm(H*xret+g) = " <<
norm(H*xret+g)
177 <<
" norm(H*xret-g) = " <<
norm(H*xret-g)
178 <<
" inner_iter = " << inner_iter <<
endl;
200 while(outer_iter<=max_iteration);
214 if (ad_comm::time_flag)
218 (*ad_comm::global_logfile) <<
" Starting Newton-Raphson "
223 for (ip=1;ip<=num_der_blocks;ip++)
231 check_for_need_to_reallocate(ip);
235 (*re_objective_function_value::pobjfun)=double(0.0);
237 #if defined(USE_DDOUBLE)
241 #define double dd_real
256 if (ad_comm::time_flag)
260 time1=ad_comm::ptm->get_elapsed_time();
266 if (ad_comm::time_flag)
272 double time=ad_comm::ptm->get_elapsed_time();
273 (*ad_comm::global_logfile) <<
" Time in user_function() "
274 << ip <<
" " << time-time1 <<
endl;
282 (*re_objective_function_value::pobjfun)+=pen;
283 (*re_objective_function_value::pobjfun)+=zz;
293 int mind=y(1).minder;
294 int jmin=
max(mind,1);
295 int jmax=
min(y(1).maxder,xsize+usize);
296 for (i=1;i<=xsize+usize;i++)
297 for (j=jmin;j<=jmax;j++)
298 H(i,j)=y(i).u_bar[j-mind];
324 for (j=jmin;j<=jmax;j++)
327 if (ip<num_der_blocks)
334 if (ad_comm::time_flag)
338 ad_comm::ptm->get_elapsed_time();
535 cout << nvar <<
" " << nvar1 <<
endl;
624 #if defined(USE_ADPVM)
631 double& truef,
double& estdiff,
double& truediff,
double& bestf,
632 int& iflag,
int& inner_iter,
int maxfn)
652 alpha(k)=(r(k)*H*r(k))/
norm2(w);
653 r(k+1)=r(k)-alpha(k)*(H*p(k));
654 beta(k)=(r(k+1)*H*r(k+1))/(r(k)*H*r(k));
655 p(k+1)=r(k)+
beta(k)*p(k);
656 x(k+1)=
x(k)+alpha(k)*p(k);
void initialize(void)
Description not yet available.
static void reset(const init_df1b2vector &, const df1b2variable &)
Description not yet available.
virtual void AD_uf_inner()
static void set_yes_derivatives(void)
df1b2_gradlist * f1b2gradlist
void set_dependent_variable(const df1b2variable &_x)
Description not yet available.
static void set_no_derivatives(void)
Description not yet available.
double calculate_importance_sample(const dvector &x, const dvector &u0, const dmatrix &Hess, const dvector &_xadjoint, const dvector &_uadjoint, const dmatrix &_Hessadjoint, function_minimizer *pmin)
Description not yet available.
static void set_NO_DERIVATIVES(void)
Disable accumulation of derivative information.
void test_trust_region_method(function_minimizer *pmin)
Description not yet available.
static void set_active_random_effects(void)
static ofstream * global_logfile
void get_complete_hessian(dmatrix &H, function_minimizer *pfmin)
double do_one_feval(const dvector &x, function_minimizer *pfmin)
Description not yet available.
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Vector of double precision numbers.
static int separable_flag
static re_objective_function_value * pobjfun
double calculate_laplace_approximation(const dvector &x, const dvector &u0, const dmatrix &Hess, const dvector &_xadjoint, const dvector &_uadjoint, const dmatrix &_Hessadjoint, function_minimizer *pmin)
Description not yet available.
void initialize(void)
Description not yet available.
Description not yet available.
static dvariable reset(const dvar_vector &x)
double norm(const d3_array &a)
Return computed norm value of a.
Description not yet available.
void initialize(void)
Description not yet available.
double evaluate_function(const dvector &x, function_minimizer *pfmin)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
prnstream & endl(prnstream &)
int indexmax() const
Get maximum valid index.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static objective_function_value * pobjfun
Description not yet available.
dvariable beta(const prevariable &a, const prevariable &b)
Beta density function.
static int nvarcalc_all(void)
Description not yet available.
Description not yet available.
double norm2(const d3_array &a)
Return sum of squared elements in a.
Description not yet available.
dvector lincg(dvector &x, dvector &c, dmatrix &H, double tol, double Delta, function_minimizer *pfmin, double &truef, double &e, double &f, double &fbest, int &iflag, int &iter, int maxfn)
Description not yet available.
Description not yet available.
Description not yet available.
static void set_YES_DERIVATIVES(void)
Enable accumulation of derivative information.
virtual void user_function()
void get_second_ders(int xs, int us, const init_df1b2vector y, dmatrix &Hess, dmatrix &Dux, df1b2_gradlist *f1b2gradlist, function_minimizer *pfmin)
dvector value(const df1_one_vector &v)
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static double fun_without_pen
void reset(void)
Description not yet available.
Fundamental data type for reverse mode automatic differentiation.
dmatrix choleski_decomp_positive(const dmatrix &MM, double bound)
Description not yet available.
void df1b2_gradcalc1(void)
Description not yet available.
static void set_inactive_only_random_effects(void)