ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mod_hess.cpp
Go to the documentation of this file.
1 
5 #include <df1b2fun.h>
6 #include <admodel.h>
7 //#include <parallel.h>
8 
9 void hess_calcreport(int i,int nvar);
10 void hess_errorreport(void);
11 void set_labels_for_hess(int);
12 
13 // estimate the matrix of second derivatives
14 void ad_update_hess_stats_report(int i,int nvar);
15 
17  const std::chrono::time_point<std::chrono::system_clock>& from,
18  const std::chrono::time_point<std::chrono::system_clock>& to);
19 
22 {
24  if (random_effects_flag && lapprox != 0)
25  {
27  {
29  }
32  {
34  }
35  }
36 #if defined(USE_ADPVM)
37  else if (ad_comm::pvm_manager)
38  {
39  switch (ad_comm::pvm_manager->mode)
40  {
41  case 1: // master
43  break;
44  case 2: // slave
46  break;
47  default:
48  cerr << "Error: Illegal value for pvm_manager->mode." << endl;
49  ad_exit(1);
50  }
51  cout << "finished hess routine" << endl;
52  }
53 #endif
54  else
55  {
57  }
59 }
60 
62 {
63  int nvar=initial_params::nvarcalc(); // get the number of active parameters
64  //if (adjm_ptr) set_labels_for_hess(nvar);
65  independent_variables x(1,nvar);
66  initial_params::xinit(x); // get the initial values into the x vector
67  double f = 0.0;
68  double delta=1.e-5;
69  dvector g1(1,nvar);
70  dvector g2(1,nvar);
71  dvector gbest(1,nvar);
72  dvector hess(1,nvar);
73  dvector hess1(1,nvar);
74  dvector hess2(1,nvar);
75  double eps=.1;
76  double eps2=eps*eps;
78  gbest.fill_seqadd(1.e+50,0.);
79 
80  adstring tmpstring="admodel.hes";
81  if (ad_comm::wd_flag)
82  tmpstring = ad_comm::adprogram_name + ".hes";
83  uostream ofs((char*)tmpstring);
84 
85  std::chrono::time_point<std::chrono::system_clock> from_start;
87  {
88  from_start = std::chrono::system_clock::now();
89 
90  cout << "Calculating Hessian";
91  if (nvar >= 10) cout << " (" << nvar << " variables)";
92  cout << ": ";
93  cout.flush();
94  }
95 
96  ofs << nvar;
97  {
98  {
99  dvariable vf=0.0;
104  f = value(vf);
105  gradcalc(nvar, g1);
106  }
107  double sdelta1;
108  double sdelta2;
110  const int num = nvar / 5;
111  int index = num + (nvar % 5);
112  for (int i=1;i<=nvar;i++)
113  {
114  hess_calcreport(i,nvar);
115 
117  {
118  if (nvar >= 10)
119  {
120  if (i == index)
121  {
122  if (percentage > defaults::percentage) cout << ", ";
123  cout << percentage << "%";
124  percentage += 20;
125  index += num;
126  }
127  }
128  else
129  {
130  if (i > 1) cout << ", ";
131  cout << i;
132  }
133  cout.flush();
134  }
135 
136  double xsave=x(i);
137  sdelta1=x(i)+delta;
138  sdelta1-=x(i);
139  x(i)=xsave+sdelta1;
140  dvariable vf=0.0;
145  f = value(vf);
146  gradcalc(nvar, g1);
147 
148  sdelta2=x(i)-delta;
149  sdelta2-=x(i);
150  x(i)=xsave+sdelta2;
151  vf=0.0;
156  f = value(vf);
157  gradcalc(nvar, g2);
158  x(i)=xsave;
159  hess1=(g1-g2)/(sdelta1-sdelta2);
160 
161  sdelta1=x(i)+eps*delta;
162  sdelta1-=x(i);
163  x(i)=xsave+sdelta1;
164  vf=0.0;
169  f = value(vf);
170  gradcalc(nvar, g1);
171 
172  x(i)=xsave-eps*delta;
173  sdelta2=x(i)-eps*delta;
174  sdelta2-=x(i);
175  x(i)=xsave+sdelta2;
176  vf=0.0;
181  f = value(vf);
182  gradcalc(nvar, g2);
183  x(i)=xsave;
184 
185  hess2=(g1-g2)/(sdelta1-sdelta2);
186 
187  hess=(eps2*hess1-hess2) /(eps2-1.);
188 
189  ofs << hess;
190  //if (adjm_ptr) ad_update_hess_stats_report(nvar,i);
191 
192  }
193 
195  {
196  print_elapsed_time(from_start, std::chrono::system_clock::now());
197  }
198 
201  dvector tscale(1,nvar); // need to get scale from somewhere
202  /*int check=*/initial_params::stddev_scale(tscale,x);
203  ofs << tscale;
204  // Write the MLE (bounded space) to file to be read in later by hybrid
205  // methods. This is needed b/c the covar needs to be rescaled and the MLE
206  // is needed for that.
207  // Added by Cole; 4/2017
208  ofs << -987; // unique flag to check for later
209  dvector mle(1,nvar);
211  ofs << mle;
212  }
213 }
214 
216  const dvector& g, dvector& fg)
217 {
218  int nvar=initial_params::nvarcalc(); // get the number of active parameters
219  independent_variables x(1,nvar);
220  initial_params::xinit(x); // get the initial values into the x vector
221  double f = 0.0;
222  double delta=1.e-6;
223  dvector g1(1,nvar);
224  dvector g2(1,nvar);
225  dvector gbest(1,nvar);
226  dvector hess(1,nvar);
227  dvector hess1(1,nvar);
228  dvector hess2(1,nvar);
229  //double eps=.1;
231  gbest.fill_seqadd(1.e+50,0.);
232  uostream ofs("admodel.hes");
233  //ofstream ofs5("tmphess");
234  double lambda=fg*g/norm2(g);
235  cout << fg-lambda*g << endl;
236  cout << norm(fg-lambda*g) << " " << fg*g/(norm(g)*norm(fg)) << endl;
237  ofs << nvar;
238  {
239  {
240  dvariable vf=0.0;
245  vf-=lambda*likeprof_params::likeprofptr[iprof]->variable();
246  f = value(vf);
247  gradcalc(nvar, g1);
248  }
249  double sdelta1;
250  double sdelta2;
251 
252  for (int i=1;i<=nvar;i++)
253  {
254  hess_calcreport(i,nvar);
255 
256  double xsave=x(i);
257  sdelta1=x(i)+delta;
258  sdelta1-=x(i);
259  x(i)=xsave+sdelta1;
260  dvariable vf=0.0;
265  vf-=lambda*likeprof_params::likeprofptr[iprof]->variable();
266  f = value(vf);
267  gradcalc(nvar, g1);
268 
269  sdelta2=x(i)-delta;
270  sdelta2-=x(i);
271  x(i)=xsave+sdelta2;
272  vf=0.0;
277  vf-=lambda*likeprof_params::likeprofptr[iprof]->variable();
278  f = value(vf);
279  gradcalc(nvar, g2);
280  x(i)=xsave;
281  hess1=(g1-g2)/(sdelta1-sdelta2);
282  /*
283  sdelta1=x(i)+eps*delta;
284  sdelta1-=x(i);
285  x(i)=xsave+sdelta1;
286  vf=0.0;
287  vf=initial_params::reset(dvar_vector(x));
288  *objective_function_value::pobjfun=0.0;
289  pre_userfunction();
290  vf+=*objective_function_value::pobjfun;
291  vf-=lambda*likeprof_params::likeprofptr[iprof]->variable();
292  f=value(vf);
293  gradcalc(nvar,g1);
294 
295  x(i)=xsave-eps*delta;
296  sdelta2=x(i)-eps*delta;
297  sdelta2-=x(i);
298  x(i)=xsave+sdelta2;
299  vf=0.0;
300  vf=0.0;
301  vf=initial_params::reset(dvar_vector(x));
302  *objective_function_value::pobjfun=0.0;
303  pre_userfunction();
304  vf+=*objective_function_value::pobjfun;
305  vf-=lambda*likeprof_params::likeprofptr[iprof]->variable();
306  f=value(vf);
307  gradcalc(nvar,g2);
308  x(i)=xsave;
309 
310  double eps2=eps*eps;
311  hess2=(g1-g2)/(sdelta1-sdelta2);
312  hess=(eps2*hess1-hess2) /(eps2-1.);
313  */
314  hess=hess1;
315  ofs << hess;
316  }
317  }
319 }
320 /*
321 void function_minimizer::hess_routine_and_constraint(int iprof)
322 {
323  int nvar=initial_params::nvarcalc(); // get the number of active parameters
324  independent_variables x(1,nvar);
325  initial_params::xinit(x); // get the initial values into the x vector
326  double f;
327  double delta=1.e-6;
328  dvector g1(1,nvar);
329  dvector g2(1,nvar);
330  dvector gbest(1,nvar);
331  dvector hess(1,nvar);
332  dvector hess1(1,nvar);
333  dvector hess2(1,nvar);
334  double eps=.1;
335  gradient_structure::set_YES_DERIVATIVES();
336  gbest.fill_seqadd(1.e+50,0.);
337  std::ostream& output_stream = get_output_stream();
338  uostream ofs("admodel.hes");
339  //ofstream ofs5("tmphess");
340  ofs << nvar;
341  {
342  {
343  dvariable vf=0.0;
344  vf=initial_params::reset(dvar_vector(x));
345  *objective_function_value::pobjfun=0.0;
346  pre_userfunction();
347  vf+=*objective_function_value::pobjfun;
348  f=value(vf);
349  gradcalc(nvar,g1);
350  }
351  for (int i=1;i<=nvar;i++)
352  {
353  output_stream << "Estimating row " << i << " out of " << nvar
354  << " for hessian" << endl;
355 
356  double f=0.0;
357  double xsave=x(i);
358  double sdelta1=x(i)+delta;
359  sdelta1-=x(i);
360  x(i)=xsave+sdelta1;
361  dvariable vf=0.0;
362  vf=initial_params::reset(dvar_vector(x));
363  *objective_function_value::pobjfun=0.0;
364  pre_userfunction();
365  vf+=*objective_function_value::pobjfun;
366  f=value(vf);
367  gradcalc(nvar,g1);
368 
369  double sdelta2=x(i)-delta;
370  sdelta2-=x(i);
371  x(i)=xsave+sdelta2;
372  vf=0.0;
373  vf=initial_params::reset(dvar_vector(x));
374  *objective_function_value::pobjfun=0.0;
375  pre_userfunction();
376  vf+=*objective_function_value::pobjfun;
377  f=value(vf);
378  gradcalc(nvar,g2);
379  x(i)=xsave;
380  hess1=(g1-g2)/(sdelta1-sdelta2);
381 
382  sdelta1=x(i)+eps*delta;
383  sdelta1-=x(i);
384  x(i)=xsave+sdelta1;
385  vf=0.0;
386  vf=initial_params::reset(dvar_vector(x));
387  *objective_function_value::pobjfun=0.0;
388  pre_userfunction();
389  vf+=*objective_function_value::pobjfun;
390  f=value(vf);
391  gradcalc(nvar,g1);
392 
393  x(i)=xsave-eps*delta;
394  sdelta2=x(i)-eps*delta;
395  sdelta2-=x(i);
396  x(i)=xsave+sdelta2;
397  vf=0.0;
398  vf=0.0;
399  vf=initial_params::reset(dvar_vector(x));
400  *objective_function_value::pobjfun=0.0;
401  pre_userfunction();
402  vf+=*objective_function_value::pobjfun;
403  f=value(vf);
404  gradcalc(nvar,g2);
405  x(i)=xsave;
406 
407  double eps2=eps*eps;
408  hess2=(g1-g2)/(sdelta1-sdelta2);
409  hess=(eps2*hess1-hess2) /(eps2-1.);
410  ofs << hess;
411  }
412  // do the hessian for the constraint function
413  uostream cofs("constrnt.hes");
414  cofs << nvar;
415  for (i=1;i<=nvar;i++)
416  {
417  output_stream << "Estimating row " << i << " out of " << nvar
418  << " for hessian" << endl;
419 
420  double f=0.0;
421  double xsave=x(i);
422  sdelta1=x(i)+delta;
423  sdelta1-=x(i);
424  x(i)=xsave+sdelta1;
425  dvariable vf=0.0;
426  vf=initial_params::reset(dvar_vector(x));
427  *objective_function_value::pobjfun=0.0;
428  pre_userfunction();
429  vf=likeprof_params::likeprofptr[iprof]->variable();
430  f=value(vf);
431  gradcalc(nvar,g1);
432 
433  sdelta2=x(i)-delta;
434  sdelta2-=x(i);
435  x(i)=xsave+sdelta2;
436  vf=0.0;
437  vf=initial_params::reset(dvar_vector(x));
438  *objective_function_value::pobjfun=0.0;
439  pre_userfunction();
440  vf=likeprof_params::likeprofptr[iprof]->variable();
441  f=value(vf);
442  gradcalc(nvar,g2);
443  x(i)=xsave;
444  hess1=(g1-g2)/(sdelta1-sdelta2);
445 
446  sdelta1=x(i)+eps*delta;
447  sdelta1-=x(i);
448  x(i)=xsave+sdelta1;
449  vf=0.0;
450  vf=initial_params::reset(dvar_vector(x));
451  *objective_function_value::pobjfun=0.0;
452  pre_userfunction();
453  vf=likeprof_params::likeprofptr[iprof]->variable();
454  f=value(vf);
455  gradcalc(nvar,g1);
456 
457  x(i)=xsave-eps*delta;
458  sdelta2=x(i)-eps*delta;
459  sdelta2-=x(i);
460  x(i)=xsave+sdelta2;
461  vf=0.0;
462  vf=initial_params::reset(dvar_vector(x));
463  *objective_function_value::pobjfun=0.0;
464  pre_userfunction();
465  vf=likeprof_params::likeprofptr[iprof]->variable();
466  f=value(vf);
467  gradcalc(nvar,g2);
468  x(i)=xsave;
469 
470  double eps2=eps*eps;
471  hess2=(g1-g2)/(sdelta1-sdelta2);
472  hess=(eps2*hess1-hess2) /(eps2-1.);
473  cofs << hess;
474  }
475  }
476  gradient_structure::set_NO_DERIVATIVES();
477 }
478 */
479 
480 void print_elapsed_time(
481  const std::chrono::time_point<std::chrono::system_clock>& from,
482  const std::chrono::time_point<std::chrono::system_clock>& to);
483 
489 {
491  dvector ggg(1,1);
492  gradcalc(0,ggg);
496  {
498  }
499  int nvar=initial_params::nvarcalc(); // get the number of active parameters
500  int ndvar=stddev_params::num_stddev_calc();
501  int ndvarcals=stddev_params::num_stddev_params;
502  std::chrono::time_point<std::chrono::system_clock> from_start;
503  if (function_minimizer::output_flag == 1 && ndvarcals > 0)
504  {
505  from_start = std::chrono::system_clock::now();
506 
507  cout << "Differentiating " << ndvarcals << " derived quantities: ";
508  cout.flush();
509  }
510  independent_variables x(1,nvar);
511  initial_params::xinit(x); // get the initial values into the x vector
512  //double f;
513  //double delta=1.e-7;
514  adstring tmpstring="admodel.dep";
515  if (ad_comm::wd_flag)
516  tmpstring = ad_comm::adprogram_name + ".dep";
517  ofstream ofs((char*)tmpstring);
518  if (lapprox)
519  {
521  }
522 
523  dvariable vf;
528 
529  ofs << nvar << " " << ndvar << endl;
530  int i;
532  const int num = ndvarcals / 5;
533  int index = num + (ndvarcals % 5);
534  for (i=0;i<ndvarcals;i++)
535  {
537  {
538  if (ndvarcals >= 10)
539  {
540  if ((i + 1) == index)
541  {
542  if (percentage > defaults::percentage) cout << ", ";
543  cout << percentage << "%";
544  percentage += 20;
545  index += num;
546  }
547  } else {
548  if (i > 0) cout << ", ";
549  cout << i + 1;
550  }
551  cout.flush();
552  }
554  }
556  for (i=0;i<ndvarcals;i++)
557  {
558  ofs << stddev_params::stddevptr[i]->label() << " ";
559  ofs << stddev_params::stddevptr[i]->size_count() << endl;
560  }
561  if (lapprox)
562  {
564  }
566  if (function_minimizer::output_flag == 1 && ndvarcals > 0)
567  {
568  print_elapsed_time(from_start, std::chrono::system_clock::now());
569  }
570 }
575 {
577  int nvar=initial_params::nvarcalc(); // get the number of active parameters
578  independent_variables x(1,nvar);
579 
580  std::chrono::time_point<std::chrono::system_clock> from_start;
582  {
583  from_start = std::chrono::system_clock::now();
584 
585  cout << "Inverting Hessian";
586  if (nvar >= 10) cout << " (" << nvar << " variables)";
587  cout << ": ";
588  cout.flush();
589  }
590 
591  initial_params::xinit(x); // get the initial values into the x vector
592  //double f;
593  dmatrix hess(1,nvar,1,nvar);
594  uistream ifs("admodel.hes");
595  int file_nvar = 0;
596  ifs >> file_nvar;
597  if (nvar != file_nvar)
598  {
599  cerr << "Number of active variables in file mod_hess.rpt is wrong"
600  << endl;
601  }
602 
603  for (int i = 1;i <= nvar; i++)
604  {
605  ifs >> hess(i);
606  if (!ifs)
607  {
608  cerr << "Error reading line " << i << " of the hessian"
609  << " in routine hess_inv()" << endl;
610  ad_exit(1);
611  }
612  }
613 
614  _hessian.allocate(1, nvar, 1, nvar);
615  _hessian = hess;
616 
617  int hybflag = 0;
618  ifs >> hybflag;
619  dvector sscale(1,nvar);
620  ifs >> sscale;
621  if (!ifs)
622  {
623  cerr << "Error reading sscale"
624  << " in routine hess_inv()" << endl;
625  }
626 
627  double maxerr=0.0;
629  const int num = nvar / 5;
630  int index = num + (nvar % 5);
631  for (int i = 1;i <= nvar; i++)
632  {
633  for (int j=1;j<i;j++)
634  {
635  double tmp=(hess(i,j)+hess(j,i))/2.;
636  double tmp1=fabs(hess(i,j)-hess(j,i));
637  tmp1/=(1.e-4+fabs(hess(i,j))+fabs(hess(j,i)));
638  if (tmp1>maxerr) maxerr=tmp1;
639  hess(i,j)=tmp;
640  hess(j,i)=tmp;
641  }
643  {
644  if(nvar >= 10)
645  {
646  if (i == index)
647  {
648  if (percentage > defaults::percentage) cout << ", ";
649  cout << percentage << "%";
650  cout.flush();
651  percentage += 20;
652  index += num;
653  }
654  }
655  else
656  {
657  if (i > 1) cout << ", ";
658  cout << i;
659  cout.flush();
660  }
661  }
662  }
663  /*
664  if (maxerr>1.e-2)
665  {
666  cerr << "warning -- hessian aprroximation is poor" << endl;
667  }
668  */
669 
670  for (int i = 1;i <= nvar; i++)
671  {
672  int zero_switch=0;
673  for (int j=1;j<=nvar;j++)
674  {
675  if (hess(i,j)!=0.0)
676  {
677  zero_switch=1;
678  }
679  }
680  if (!zero_switch)
681  {
682  // If any values in the ith row are exactly zero it's
683  // probably a floating parameter, but this is caught below
684  // too when checking for invalid variances..?
686  {
687  cout << "\n Warning: Parameter " << i << " appears to have identically 0 derivative.. check model\n";
688  cout.flush();
689  }
690  std::ostream& output_stream = get_output_stream();
691  output_stream << " Hessian is 0 in row " << i
692  << "\n This means that the derivative if probably identically 0 for this parameter."
693  << endl;
694  }
695  }
696 
697  int ssggnn;
698  ln_det(hess,ssggnn);
699  int on1=0;
700  {
701  ofstream ofs3((char*)(ad_comm::adprogram_name + adstring(".eva")));
702  {
703  dvector se=eigenvalues(hess);
704  ofs3 << setshowpoint() << setw(14) << setprecision(10)
705  << "unsorted:\t" << se << endl;
706  se=sort(se);
707  ofs3 << setshowpoint() << setw(14) << setprecision(10)
708  << "sorted:\t" << se << endl;
709  if (se(se.indexmin())<=0.0)
710  {
712  std::ostream& output_stream = get_output_stream();
713  output_stream << "Warning -- Hessian does not appear to be positive definite"
714  << endl;
715  }
716  }
717  ivector negflags(0,hess.indexmax());
718  int num_negflags=0;
719  {
720  int on = option_match(ad_comm::argc,ad_comm::argv,"-eigvec");
722  if (on > -1 || on1 >-1 )
723  {
724  ofs3 << setshowpoint() << setw(14) << setprecision(10)
725  << eigenvalues(hess) << endl;
726  dmatrix ev=trans(eigenvectors(hess));
727  ofs3 << setshowpoint() << setw(14) << setprecision(10)
728  << ev << endl;
729  for (int i=1;i<=ev.indexmax();i++)
730  {
731  double lam=ev(i)*hess*ev(i);
732  ofs3 << setshowpoint() << setw(14) << setprecision(10)
733  << lam << " " << ev(i)*ev(i) << endl;
734  if (lam<0.0)
735  {
736  num_negflags++;
737  negflags(num_negflags)=i;
738  }
739  }
740  if ( (on1>-1) && (num_negflags>0)) // we will try to get away from
741  { // saddle point
743  spminflag=1;
744  if(negdirections)
745  {
746  delete negdirections;
747  }
748  negdirections = new dmatrix(1,num_negflags);
749  for (int i=1;i<=num_negflags;i++)
750  {
751  (*negdirections)(i)=ev(negflags(i));
752  }
753  }
754  int on2 = option_match(ad_comm::argc,ad_comm::argv,"-cross");
755  if (on2>-1)
756  { // saddle point
757  dmatrix cross(1,ev.indexmax(),1,ev.indexmax());
758  for (int i = 1;i <= ev.indexmax(); i++)
759  {
760  for (int j=1;j<=ev.indexmax();j++)
761  {
762  cross(i,j)=ev(i)*ev(j);
763  }
764  }
765  ofs3 << endl << " e(i)*e(j) ";
766  ofs3 << endl << cross << endl;
767  }
768  }
769  }
770 
771  if (spminflag==0)
772  {
773  if (num_negflags==0)
774  {
775  hess=inv(hess);
776  _hessian_inverse.allocate(1,nvar,1,nvar);
777  _hessian_inverse = hess;
778 
779  int on=0;
780  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-eigvec"))>-1)
781  {
782  int i;
783  ofs3 << "choleski decomp of correlation" << endl;
784  dmatrix ch=choleski_decomp(hess);
785  for (i=1;i<=ch.indexmax();i++)
786  ofs3 << ch(i)/norm(ch(i)) << endl;
787  ofs3 << "parameterization of choleski decomnp of correlation" << endl;
788  for (i=1;i<=ch.indexmax();i++)
789  {
790  dvector tmp=ch(i)/norm(ch(i));
791  ofs3 << tmp(1,i)/tmp(i) << endl;
792  }
793  }
794  }
795  }
796  }
797  if (spminflag==0)
798  {
799  if (on1<0)
800  {
801  for (int i = 1;i <= nvar; i++)
802  {
803  // hess is the covariance matrix b/c inverted above
804  if (hess(i,i) <= 0.0)
805  {
807 
808  cerr << "\n\n Error: Estimated variance of parameter " << i << " is "<< hess(i,i) << ", failed to invert Hessian.\n"
809  << " No uncertainty estimates available. Fix model structure and reoptimize.\n";
810 
811  return false;
812  }
813  }
814  }
815  {
816  adstring tmpstring="admodel.cov";
817  if (ad_comm::wd_flag)
818  tmpstring = ad_comm::adprogram_name + ".cov";
819  uostream ofs((char*)tmpstring);
820  ofs << nvar << hess;
822  ofs << sscale;
823  }
824  }
826  {
827  print_elapsed_time(from_start, std::chrono::system_clock::now());
828  }
829  return true;
830 }
831 void hess_calcreport(int i,int nvar)
832 {
833  std::ostream& output_stream = get_output_stream();
834  output_stream << "Estimating row " << i << " out of " << nvar << " for hessian"
835  << endl;
836 }
838 {
839  std::ostream& output_stream = get_output_stream();
840  output_stream << "Hessian does not appear to be positive definite." << endl;
841 }
static likeprof_params * likeprofptr[500]
Definition: admodel.h:2257
bool hess_inv()
Symmetrize and invert the hessian.
Definition: mod_hess.cpp:574
laplace_approximation_calculator * lapprox
Definition: admodel.h:1862
static adpvm_manager * pvm_manager
Definition: fvar.hpp:8849
void ad_update_hess_stats_report(int i, int nvar)
const int percentage
Definition: fvar.hpp:9506
dmatrix _hessian_inverse
Definition: admodel.h:2199
void jacobcalc(int nvar, const dmatrix &jac)
Description not yet available.
Definition: jacobclc.cpp:75
static void set_NO_DERIVATIVES(void)
Disable accumulation of derivative information.
Definition: gradstrc.cpp:641
void hess_calcreport(int i, int nvar)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: mod_hess.cpp:831
void allocate(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat0.cpp:8
dmatrix trans(const dmatrix &m1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat2.cpp:13
dvector eigenvalues(const banded_symmetric_dmatrix &_SS)
Description not yet available.
Definition: dmat28.cpp:411
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
static char ** argv
Definition: fvar.hpp:8866
void hess_routine_and_constraint(int iprof, const dvector &g, dvector &fg)
Definition: mod_hess.cpp:215
void fill_seqadd(double, double)
Fills dvector elements with values starting from base and incremented by offset.
Definition: cranfill.cpp:58
void print_elapsed_time(const std::chrono::time_point< std::chrono::system_clock > &from, const std::chrono::time_point< std::chrono::system_clock > &to)
Definition: mod_sd.cpp:94
df1_two_variable fabs(const df1_two_variable &x)
Definition: df12fun.cpp:891
exitptr ad_exit
Definition: gradstrc.cpp:53
static dvariable reset(const dvar_vector &x)
Definition: model.cpp:345
ADMB variable vector.
Definition: fvar.hpp:2172
static void restore_start_phase(void)
Definition: model.cpp:275
static adstring adprogram_name
Definition: fvar.hpp:8860
static int num_stddev_calc(void)
Definition: model2.cpp:51
double norm(const d3_array &a)
Return computed norm value of a.
Definition: d3arr2a.cpp:190
virtual dvariable variable(void)=0
void gradcalc(int nvar, const dvector &g)
Definition: sgradclc.cpp:77
df1_one_matrix choleski_decomp(const df1_one_matrix &MM)
Definition: df11fun.cpp:606
static int nvarcalc()
Definition: model.cpp:152
dmatrix _hessian
Definition: admodel.h:2198
virtual unsigned int size_count() const =0
void set_labels_for_hess(int)
virtual const char * label()=0
dmatrix sort(const dmatrix &m, int column, int NSTACK)
Description not yet available.
Definition: dmsort.cpp:17
prnstream & endl(prnstream &)
dmatrix eigenvectors(const banded_symmetric_dmatrix &_SS, const dvector &_e)
Description not yet available.
Definition: dmat28.cpp:442
Description not yet available.
Definition: fvar.hpp:1937
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
Description not yet available.
Definition: fvar.hpp:3398
static int argc
Definition: fvar.hpp:8863
preshowpoint setshowpoint(void)
Description not yet available.
Definition: admanip.cpp:38
virtual void set_dependent_variables(void)=0
static objective_function_value * pobjfun
Definition: admodel.h:2394
Description not yet available.
static void xinit(const dvector &x)
Definition: model.cpp:226
static _THREAD gradient_structure * _instance
static void set_inactive_random_effects(void)
Definition: model.cpp:288
Description not yet available.
Definition: fvar.hpp:2819
double norm2(const d3_array &a)
Return sum of squared elements in a.
Definition: d3arr2a.cpp:167
static void copy_all_values(const dvector &x, const int &ii)
Definition: model3.cpp:9
double ln_det(const dmatrix &m1, int &sgn)
Compute log determinant of a constant matrix.
Definition: dmat3.cpp:536
int option_match(int argc, char *argv[], const char *string)
Checks if the program has been invoked with a particular command line argument (&quot;string&quot;).
Definition: optmatch.cpp:25
dmatrix * negdirections
Definition: admodel.h:1858
int indexmax() const
Definition: fvar.hpp:2921
std::ostream & get_output_stream()
Definition: adglobl.cpp:45
static bool in_hessian_phase
Definition: admodel.h:845
void hess_routine_slave(void)
static int Hybrid_bounded_flag
static stddev_params * stddevptr[150]
Definition: admodel.h:2215
double eps
Definition: ftweak.cpp:13
Description not yet available.
void reset_gradient_stack(void)
Rewind buffer.
Definition: sgradclc.cpp:367
static void set_YES_DERIVATIVES(void)
Enable accumulation of derivative information.
Definition: gradstrc.cpp:650
Description not yet available.
Definition: fvar.hpp:3516
static int output_flag
Definition: admodel.h:1972
static int negative_eigenvalue_flag
Definition: admodel.h:1859
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
static int stddev_scale(const dvector &d, const dvector &x)
Definition: model.cpp:202
void pre_userfunction(void)
Definition: model7.cpp:586
void depvars_routine(void)
Calculate the derivatives of dependent variables with respect to the independent variables.
Definition: mod_hess.cpp:488
void hess_routine_random_effects(void)
Description not yet available.
Definition: mod_rhes.cpp:99
void hess_routine_noparallel(void)
Definition: mod_hess.cpp:61
static unsigned int wd_flag
Definition: fvar.hpp:8864
void hess_errorreport(void)
Definition: mod_hess.cpp:837
static int alternative_user_function_flag
Definition: adrndeff.h:199
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
df1_one_variable inv(const df1_one_variable &x)
Definition: df11fun.cpp:384
void hess_routine_master(void)
static void set_inactive_only_random_effects(void)
Definition: model.cpp:259
static int random_effects_flag
Definition: admodel.h:1857
void hess_routine(void)
Definition: mod_hess.cpp:21
static int num_stddev_params
Definition: admodel.h:2219