12 using std::istringstream;
27 const std::chrono::time_point<std::chrono::system_clock>& from,
28 const std::chrono::time_point<std::chrono::system_clock>& to);
38 int minsave=
M.indexmin();
44 #ifndef SAFE_INITIALIZE
63 for (j=i-bw+1;j<=i-1;j++)
68 for (k=i-bw+1;k<=j-1;k++)
77 for (k=i-bw+1;k<=i-1;k++)
101 #if defined(USE_ADPVM)
113 cerr <<
"Illegal value for mode" <<
endl;
141 if (debug) cout<<
endl<<
"Starting hess_routine_noparallel_random_effects(). nvar = "<<nvar<<
endl;
169 g1=(*lapprox)(
x,f,
this);
181 ofstream ofs((
char*)(tmpstring));
182 ofs <<
" value std.dev" <<
endl;
188 for (i=mmin;i<=mmax;i++)
196 for (j=jmin;j<=jmax;j++)
201 << setw(14) << u(ii++) <<
" " << d(j) <<
endl;;
211 ofstream ofs((
char*)(tmpstring));
212 ofs <<
" value std.dev" <<
endl;
226 for (i=mmin;i<=mmax;i++)
234 << setw(14) << u(i) <<
" " << d <<
endl;;
243 ofstream ofs((
char*)(tmpstring));
244 ofs <<
" value std.dev" <<
endl;
256 for (
int i=mmin;i<=mmax;i++)
259 << setw(14) << u(i) <<
" " <<
sqrt(m(i,i)) <<
endl;;
288 for (
int i=mmin;i<=mmax;i++)
294 << setw(14) << u(i) <<
" " <<
sqrt(
w(i)) <<
endl;;
305 cerr <<
"Error writing to file " << tmpstring <<
endl;
312 cerr <<
"Error writing to file " << tmpstring <<
endl;
323 output_stream << i <<
" " << j <<
endl;
332 cerr <<
"Usage -hpts option needs non-negative integer -- ignored.\n";
346 cerr <<
"Usage -hsize option needs number -- ignored" <<
endl;
355 cerr <<
"Usage -hsize option needs positive number -- ignored.\n";
366 double sdelta=1.0+delta;
369 std::chrono::time_point<std::chrono::system_clock> from_start;
372 from_start = std::chrono::system_clock::now();
374 cout <<
"Calculating Hessian";
375 if (nvar >= 10) cout <<
" (" << nvar <<
" variables)";
382 int index = num + (nvar % 5);
387 for (
int i=1;i<=nvar;i++)
389 output_stream <<
"Estimating row " << i <<
" out of " << nvar
390 <<
" for hessian" <<
endl;
400 cout << percentage <<
"%";
407 if (i > 1) cout <<
", ";
413 for (
int j=-npts;j<=npts;j++)
420 g1=(*lapprox)(
x,f,
this);
422 uos << i << j << sdelta << g1;
426 uos << i << j << sdelta << g0;
441 dmatrix tmp(-npts,npts,1,nvar);
447 for (i=1;i<=nvar;i++)
449 for (
int j=-npts;j<=npts;j++)
451 uis >> iind(j) >> jind(j) >> sd >> tmp(j);
453 hess(i)=(v*tmp).shift(1);
466 for (i=1;i<=nvar;i++)
468 for (
int j=1;j<=nvar;j++)
470 shess(i,j)=(hess(i,j)-hess(j,i))/
471 (1.e-3+
sfabs(hess(i,j))+
fabs(hess(j,i)));
472 if (shess(i,j)>maxerr) maxerr=shess(i,j);
475 ofstream ofs1(
"hesscheck");
476 ofs1 <<
"maxerr = " << maxerr << endl <<
endl;
477 ofs1 << setw(10) << hess << endl <<
endl;
478 ofs1 << setw(10) << shess <<
endl;
491 cout<<
"admodel.hes:"<<
endl;
494 cout<<gradient_structure::Hybrid_bounded_flag<<
endl;
498 cout<<
"end of hess_routine_noparallel_random_effects()"<<endl<<
endl;
550 #if defined(USE_ADPVM)
570 (*lapprox)(
x,f,
this);
575 for (
int i=1;i<=nvar;i++)
582 (*lapprox)(
x,f,
this);
587 (*lapprox)(
x,f,
this);
590 sdelta1=
x(i)+eps*delta;
593 (*lapprox)(
x,f,
this);
595 x(i)=xsave-eps*delta;
596 sdelta2=
x(i)-eps*delta;
599 (*lapprox)(
x,f,
this);
607 #endif // #if defined(USE_ADPVM)
Description not yet available.
laplace_approximation_calculator * lapprox
dcompressed_triplet * sparse_triplet2
static adpvm_manager * pvm_manager
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).
void hess_routine_slave_random_effects(void)
Description not yet available.
Description not yet available.
dvector get_solution_vector(int npts)
Description not yet available.
dvector diagonal(const dmatrix &matrix)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
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.
constexpr const int percentage_number
int indexmin() const
Get minimum valid index.
void fill_seqadd(double, double)
Fills dvector elements with values starting from base and incremented by offset.
hs_symbolic * sparse_symbolic2
void print_elapsed_time(const std::chrono::time_point< std::chrono::system_clock > &from, const std::chrono::time_point< std::chrono::system_clock > &to)
df1_two_variable fabs(const df1_two_variable &x)
void initialize(void)
Description not yet available.
static dvariable reset(const dvar_vector &x)
static adstring adprogram_name
void gradcalc(int nvar, const dvector &g)
int atoi(adstring &s)
Returns a integer converted from input s.
df1_one_matrix choleski_decomp(const df1_one_matrix &MM)
banded_symmetric_dmatrix * bHess
double sfabs(const double v1)
Description not yet available.
dvector solve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
prescientific setscientific(void)
Description not yet available.
prnstream & endl(prnstream &)
Description not yet available.
Array of integers(int) with indexes from index_min to indexmax.
dvector solve_trans(const lower_triangular_dmatrix &M, const dvector &y)
Description not yet available.
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
banded_lower_triangular_dmatrix quiet_choleski_decomp(const banded_symmetric_dmatrix &_M, int &ierr)
Description not yet available.
Description not yet available.
int indexmax() const
Get maximum valid index.
Description not yet available.
static void xinit(const dvector &x)
Description not yet available.
Description not yet available.
Description not yet available.
void shift(int)
Description not yet available.
void initialize(void)
Initialze all elements of dvector to zero.
dvector & shift(int min)
Shift valid range of subscripts.
static void copy_all_values(const dvector &x, const int &ii)
int option_match(int argc, char *argv[], const char *string)
Checks if the program has been invoked with a particular command line argument ("string").
std::ostream & get_output_stream()
void initialize(void)
Description not yet available.
void hess_routine_noparallel_random_effects(void)
Description not yet available.
static int Hybrid_bounded_flag
Description not yet available.
d3_array * block_diagonal_hessian
Description not yet available.
static void set_YES_DERIVATIVES(void)
Enable accumulation of derivative information.
void get_inverse_sparse_hessian(dcompressed_triplet &st, hs_symbolic &S, uostream &ofs1, ofstream &ofs, int usize, int xsize, dvector &u)
Description not yet available.
static int stddev_scale(const dvector &d, const dvector &x)
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void hess_routine_random_effects(void)
Description not yet available.
static unsigned int wd_flag
static int first_hessian_flag
df1_one_variable inv(const df1_one_variable &x)
static void set_inactive_only_random_effects(void)