48 uhat=get_uhat_quasi_newton_block_diagonal(
x,pfmin);
50 uhat=get_uhat_quasi_newton_qd(
x,pfmin);
54 uhat=get_uhat_lm_newton(
x,pfmin);
58 scale.allocate(1,uhat.indexmax());
62 if (scale.indexmax() != uhat.indexmax())
65 scale.allocate(1,uhat.indexmax());
71 curv.allocate(1,uhat.indexmax());
75 if (curv.indexmax() != uhat.indexmax())
78 curv.allocate(1,uhat.indexmax());
82 if (sparse_hessian_flag==0)
84 for (
int i=1;i<=xsize;i++)
88 for (
int i=1;i<=usize;i++)
95 for (
int i=1;i<=xsize;i++)
99 for (
int i=1;i<=usize;i++)
101 value(y(i+xsize))=uhat(i);
106 for(
int ii=1;ii<=num_nr_iters;ii++)
114 pmin->inner_opt_flag=1;
115 step=get_newton_raphson_info_block_diagonal(pfmin);
116 output_stream <<
"max separable g " << std::scientific << setprecision(10) << max_separable_g
117 <<
"\nNewton raphson " << std::fixed << ii <<
endl;
121 pmin->inner_opt_flag=0;
124 if (sparse_hessian_flag==0)
126 for (
int i=1;i<=usize;i++)
133 for (
int i=1;i<=usize;i++)
135 value(y(i+xsize))=uhat(i);
141 xadjoint.initialize();
142 uadjoint.initialize();
143 block_diagonal_flag=2;
144 used_flags.initialize();
146 if (use_gauss_hermite>0)
151 block_diagonal_flag=6;
152 num_separable_calls=0;
156 block_diagonal_flag=2;
162 if (multi_random_effects==0)
165 uadjoint,Hessadjoint,pfmin);
170 uadjoint,Hessadjoint,pfmin);
172 int xmax=xadjoint.indexmax();
176 assert(nvar <= INT_MAX);
181 dvector sscale=dscale(1,xsize);
189 for (
int i=1;i<=num_separable_calls;i++)
191 ivector& re_list=(*block_diagonal_re_list)(i);
192 ivector& fe_list=(*block_diagonal_fe_list)(i);
193 dmatrix& Dux=(*block_diagonal_Dux)(i);
194 dmatrix& H=(*block_diagonal_hessian)(i);
195 xxx(re_list,fe_list);
199 for (
int j=1;j<=re_list.
indexmax();j++)
201 tmp(j)=uadjoint(re_list(j)-xmax);
210 for (
int j=1;j<=fe_list.indexmax();j++)
212 x_con(fe_list(j))+=xtmp(j);
227 block_diagonal_flag=3;
242 block_diagonal_flag=0;
245 else if (num_importance_samples>0)
250 block_diagonal_flag=6;
251 num_separable_calls=0;
255 block_diagonal_flag=2;
258 if (isfunnel_flag==0)
263 xadjoint,uadjoint,Hessadjoint,pfmin);
268 uhat,Hess,xadjoint,uadjoint,Hessadjoint,pfmin);
274 uadjoint,Hessadjoint,pfmin);
277 int xmax=xadjoint.indexmax();
281 assert(nvar <= INT_MAX);
286 dvector sscale=dscale(1,xsize);
294 for (
int i=1;i<=num_separable_calls;i++)
296 dmatrix& H=(*block_diagonal_hessian)(i);
299 ivector& re_list=(*block_diagonal_re_list)(i);
300 ivector& fe_list=(*block_diagonal_fe_list)(i);
301 dmatrix& Dux=(*block_diagonal_Dux)(i);
302 xxx(re_list,fe_list);
306 for (
int j=1;j<=re_list.
indexmax();j++)
308 tmp(j)=uadjoint(re_list(j)-xmax);
315 for (
int j=1;j<=fe_list.indexmax();j++)
317 x_con(fe_list(j))+=xtmp(j);
336 block_diagonal_flag=3;
351 block_diagonal_flag=0;
362 block_diagonal_flag=6;
363 allocate_block_diagonal_stuff();
364 num_separable_calls=0;
368 block_diagonal_flag=2;
372 if (saddlepointflag==2)
374 pmin->inner_opt_flag=0;
378 pmin->inner_opt_flag=1;
380 pmin->inner_opt_flag=0;
382 if (saddlepointflag!=2)
388 xadjoint=(*grad_x_u)(1,xsize)-(*grad_x);
391 if (saddlepointflag!=2 && pmin->multinomial_weights==0)
393 f-=usize*.91893853320467241;
397 block_diagonal_flag=0;
401 for (
int i=1;i<=xadjoint.indexmax();i++)
402 xadjoint(i)*=scale1(i);
419 if (used_flags.indexmax() != nv)
421 used_flags.safe_deallocate();
426 used_flags.safe_allocate(1,nv);
431 used_flags.initialize();
435 check_for_need_to_reallocate(ip);
440 (*re_objective_function_value::pobjfun)=0;
452 block_diagonal_flag=1;
456 block_diagonal_flag=0;
static int straight_through_flag
laplace_approximation_calculator * lapprox
static void reset(const init_df1b2vector &, const df1b2variable &)
Description not yet available.
static void set_yes_derivatives(void)
df1b2_gradlist * f1b2gradlist
d3_array elem_prod(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements product of a(i, j, k) * b(i, j, k).
static void set_no_derivatives(void)
Description not yet available.
dvector check_local_uadjoint2
static void set_NO_DERIVATIVES(void)
Disable accumulation of derivative information.
Description not yet available.
static int stddev_curvscale(const dvector &d, const dvector &x)
dvector check_local_uadjoint
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Vector of double precision numbers.
static int separable_flag
dvector get_newton_raphson_info_block_diagonal(function_minimizer *pmin)
Description not yet available.
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.
Description not yet available.
static dvariable reset(const dvar_vector &x)
dvector check_local_xadjoint2
Description not yet available.
dvector block_diagonal_calculations(const dvector &_x, const double &_f, function_minimizer *pfmin)
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.
dvector solve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
static laplace_approximation_calculator * lapprox
prnstream & endl(prnstream &)
Array of integers(int) with indexes from index_min to indexmax.
static void set_active_only_random_effects(void)
double calculate_importance_sample_block_diagonal_option_antithetical(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.
Description not yet available.
double do_gauss_hermite_block_diagonal_multi(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 pre_user_function(void)
Description not yet available.
Description not yet available.
void initialize(void)
Initialze all elements of dvector to zero.
static void xxx(ivector re_list, ivector fe_list)
std::ostream & get_output_stream()
dvector check_local_xadjoint
Description not yet available.
double do_gauss_hermite_block_diagonal(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 int set_index(void)
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)
double calculate_importance_sample_block_diagonal_funnel(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 int stddev_scale(const dvector &d, const dvector &x)
static int first_hessian_flag
double calculate_importance_sample_block_diagonal_option2(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_inactive_only_random_effects(void)