ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df1b2lp1.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include <fvar.hpp>
12 #include <admodel.h>
13 #include <df1b2fun.h>
14 #include <adrndeff.h>
15 #ifndef OPT_LIB
16  #include <cassert>
17  #include <climits>
18 #endif
19 void evaluate_function_gradient(double& f,const dvector& x,
21 double evaluate_function(const dvector& x,function_minimizer * pfmin);
22 void get_second_ders(int xs,int us,const init_df1b2vector y,dmatrix& Hess,
25 double calculate_laplace_approximation(const dvector& x,const dvector& u0,
26  const dmatrix& Hess,const dvector& _xadjoint,const dvector& _uadjoint,
27  const dmatrix& _Hessadjoint,function_minimizer * pmin);
28 
29 double calculate_importance_sample(const dvector& x,const dvector& u0,
30  const dmatrix& Hess,const dvector& _xadjoint,const dvector& _uadjoint,
31  const dmatrix& _Hessadjoint,function_minimizer * pmin);
32 
33 double calculate_importance_sample_funnel(const dvector& x,const dvector& u0,
34  const dmatrix& Hess,const dvector& _xadjoint,const dvector& _uadjoint,
35  const dmatrix& _Hessadjoint,function_minimizer * pmin);
36 
37 dmatrix choleski_decomp_positive(const dmatrix& M,double b);
38 
44  (const dvector& _x,const double& _f,function_minimizer * pfmin)
45 {
46  std::ostream& output_stream = get_output_stream();
47 
48  // for use when there is no separability
50  ADUNCONST(double,f)
51 
54  initial_params::reset(x); // get current x values into the model
56 
58  //int lmn_flag=0;
59 #ifdef DIAG_TIMER
60  if (ad_comm::time_flag)
61  {
62  if (ad_comm::ptm1)
63  {
64  ad_comm::ptm1->get_elapsed_time_and_reset();
65  }
66  if (ad_comm::ptm)
67  {
68  ad_comm::ptm->get_elapsed_time_and_reset();
69  }
70  }
71  if (ad_comm::time_flag)
72  {
73  if (ad_comm::ptm)
74  {
75  double time=ad_comm::ptm->get_elapsed_time();
77  {
78  (*ad_comm::global_logfile) << " Time pos 0 "
79  << time << endl;
80  }
81  }
82  }
83 #endif
84  double maxg=1.e+200;
85  //double maxg_save;
86  dvector uhat_old(1,usize);
87  if (inner_maxfn>0)
88  {
89  if (!inner_lmnflag)
90  {
91  if (!ADqd_flag)
92  {
93  uhat=get_uhat_quasi_newton(x,pfmin);
94  maxg=fabs(fmc1.gmax);
95  //double f_from_1=fmc1.fbest;
96  }
97  else
98  uhat=get_uhat_quasi_newton_qd(x,pfmin);
99  }
100  else
101  {
102  uhat=get_uhat_lm_newton(x,pfmin);
103  }
104 #ifdef DIAG_TIMER
105  if (ad_comm::time_flag)
106  {
107  if (ad_comm::ptm)
108  {
109  double time=ad_comm::ptm->get_elapsed_time_and_reset();
111  {
112  (*ad_comm::global_logfile) << " Time in inner optimization "
113  << time << endl;
114  }
115  }
116  }
117 #endif
118  }
119 
120  for (int i=1;i<=xsize;i++)
121  {
122  y(i)=x(i);
123  }
124  for (int i=1;i<=usize;i++)
125  {
126  y(i+xsize)=uhat(i);
127  }
128 
129  int ierr=0;
130  int niters=0;
132  niters=num_nr_iters+1;
133  else
134  niters=num_nr_iters;
135 
136  int nv=0;
138  {
140  if (allocated(used_flags))
141  {
142  if (used_flags.indexmax() != nv)
143  {
144  used_flags.safe_deallocate();
145  }
146  }
147  if (!allocated(used_flags))
148  {
149  used_flags.safe_allocate(1,nv);
150  }
151  }
152 
153  for(int ii=1;ii<=niters;ii++)
154  {
156  {
157  check_pool_size();
158  }
159  {
160  // test newton raphson
161  Hess.initialize();
162  output_stream << "Newton raphson " << ii << endl;
163  pmin->inner_opt_flag=1;
165  pmin->inner_opt_flag=0;
166 
168  {
170  evaluate_function_quiet(uhat,pfmin);
174  }
175 
176  if (ii==1)
177  {
178  /*
179  double diff = fabs(re_objective_function_value::fun_without_pen
180  - objective_function_value::fun_without_pen);
181  if (diff>1.e-7)
182  {
183  cout << "there is a difference in the the user_functions "
184  << setprecision(15) << re_objective_function_value::fun_without_pen
185  << " from autodif we have "
186  << setprecision(15) << objective_function_value::fun_without_pen
187  << " diff = "
188  << diff << endl;
189  //ad_exit(1);
190  }
191  */
192  }
193 
194 #ifdef DIAG_TIMER
195  if (ad_comm::time_flag)
196  {
197  if (ad_comm::ptm)
198  {
199  double time=ad_comm::ptm->get_elapsed_time_and_reset();
201  {
202  (*ad_comm::global_logfile) << " Time in newton-raphson " << ii
203  << " " << time << endl;
204  }
205  }
206  }
207 #endif
208  dvector step;
209 #ifdef DIAG
210  int print_hess_in_newton_raphson_flag=0;
211  if (print_hess_in_newton_raphson_flag)
212  {
213  output_stream << norm2(Hess-trans(Hess)) << endl;
215  {
216  (*ad_comm::global_logfile) << setprecision(4) << setscientific()
217  << setw(12) << sort(eigenvalues(Hess)) << endl;
218  (*ad_comm::global_logfile) << setprecision(4) << setscientific()
219  << setw(12) << Hess << endl;
220  }
221  }
222 #endif
223 
224 #if defined(USE_ATLAS)
226  {
227  step=-atlas_solve_spd(Hess,grad,ierr);
228  }
229  else
230  {
231  dmatrix A=choleski_decomp_positive(Hess,ierr);
232  if (!ierr)
233  {
234  step=-solve(Hess,grad);
235  //step=-solve(A*trans(A),grad);
236  }
237  }
238  if (ierr)
239  {
240  f1b2gradlist->reset();
247  break;
248  }
249 #else
250  //step=-solve(Hess,grad);
251  int ierror=0;
252  int icount=0;
253  int trust_update_flag=0;
254  do
255  {
256  icount++;
257  if (saddlepointflag==1 || saddlepointflag==2)
258  {
259  step=choleski_solve_neghess_error(Hess,grad,ierror);
260  }
261  else
262  {
263  step=-choleski_solve_error(Hess,grad,ierror);
264  }
265  if (ierror==1)
266  {
267  trust_update_flag=1;
268  uhat_old=uhat;
269  dvector vv=sort(eigenvalues(Hess));
270  // matrix is not positive definite
271  // do minimization
272  dvector s(grad.indexmin(),grad.indexmax());
273  double lambda=0.01;
274  if (saddlepointflag==2) // max not min
275  {
276  const dmatrix & cmHess=-Hess;
277  const dvector & cmgrad = -grad;
278  dmatrix & mHess = (dmatrix &) (cmHess);
279  dvector & mgrad = (dvector &) (cmgrad);
280  step=local_minimization(s,mHess,mgrad,lambda);
281  }
282  else
283  {
284  step=local_minimization(s,Hess,grad,lambda);
285  }
287  uhat+=step;
288  }
289  for (int i=1;i<=usize;i++)
290  {
291  y(i+xsize)=uhat(i);
292  }
293 
294  f1b2gradlist->reset();
301 
303 
305  {
307  evaluate_function_quiet(uhat,pfmin);
311  }
312  }
313  else if (trust_update_flag==1)
314  {
315  cout << "Found positive definite Hessian with trust region method"
316  << endl;
317  }
318  }
319  while (ierror==1 && icount<100);
320  if (ierror==1)
321  {
322  cerr << "Can't make a positive definite Hessian" << endl;
323  ad_exit(1);
324  }
325 #endif
326 
327 #ifdef DIAG_TIMER
328  if (ad_comm::time_flag)
329  {
330  if (ad_comm::ptm)
331  {
332  double time=ad_comm::ptm->get_elapsed_time_and_reset();
334  {
335  (*ad_comm::global_logfile) << " time_in solve " << ii << " "
336  << time << endl;
337  }
338  }
339  }
340 #endif
341  f1b2gradlist->reset();
348 
349  if (trust_update_flag==0)
350  {
351  uhat_old=uhat;
353  uhat+=step;
354  }
355  }
356 
357  double maxg_old=maxg;
358  pmin->inner_opt_flag=1;
359  maxg=fabs(evaluate_function(uhat,pfmin));
360  if (maxg>maxg_old)
361  {
363  uhat=uhat_old;
364  }
365  evaluate_function(uhat,pfmin);
366  break;
367  }
368  if (maxg < 1.e-13)
369  {
370  break;
371  }
372  }
373  for (int i=1;i<=usize;i++)
374  {
375  y(i+xsize)=uhat(i);
376  }
377  }
378 
379  if (num_nr_iters<=0)
380  {
381  evaluate_function(uhat,pfmin);
382  }
383 
384  for (int i=1;i<=usize;i++)
385  {
386  y(i+xsize)=uhat(i);
387  }
388 #ifdef DIAG_TIMER
389  if (ad_comm::time_flag)
390  {
391  if (ad_comm::ptm)
392  {
393  double time=ad_comm::ptm->get_elapsed_time_and_reset();
395  {
396  (*ad_comm::global_logfile) << " Time in reset and evaluate function"
397  << time << endl;
398  }
399  }
400  }
401 #endif
402  pmin->inner_opt_flag=0;
403 
404 
405  if (saddlepointflag==2)
406  {
407  dvector localx(1,xsize+usize);
408  for (int i=1;i<=xsize+usize;i++)
409  {
410  localx(i)=value(y(i));
411  }
414  /*int nnn=*/initial_params::nvarcalc();
415  evaluate_function_gradient(f,localx,pfmin,xadjoint,uadjoint);
416  pmin->inner_opt_flag=1;
417  get_second_ders(xsize,usize,y,Hess,Dux,f1b2gradlist,pfmin,this);
418  pmin->inner_opt_flag=0;
419  xadjoint -= solve(Hess,uadjoint)*Dux;
420  f1b2gradlist->reset();
427  }
428  else // don't need this for minimax calculations
429  {
430  get_second_ders(xsize,usize,y,Hess,Dux,f1b2gradlist,pfmin,this);
431  //int sgn=0;
432 
433 #ifdef DIAG_TIMER
434  if (ad_comm::time_flag)
435  {
436  if (ad_comm::ptm)
437  {
438  double time=ad_comm::ptm->get_elapsed_time_and_reset();
440  {
441  (*ad_comm::global_logfile) << " Time in dget second ders "
442  << time << endl;
443  }
444  }
445  }
446 #endif
447  if (!ierr)
448  {
449  if (num_importance_samples==0)
450  {
451  //cout << "Hess " << endl << Hess << endl;
452  f=calculate_laplace_approximation(x,uhat,Hess,xadjoint,uadjoint,
453  Hessadjoint,pfmin);
454  }
455  else
456  {
457  if (isfunnel_flag==0)
458  {
459  f=calculate_importance_sample(x,uhat,Hess,xadjoint,uadjoint,
460  Hessadjoint,pfmin);
461  }
462  else
463  {
464  f=calculate_importance_sample_funnel(x,uhat,Hess,xadjoint,uadjoint,
465  Hessadjoint,pfmin);
466  }
467  }
468  }
469  else
470  {
471  f=1.e+30;
472  }
473 #ifdef DIAG_TIMER
474  if (ad_comm::time_flag)
475  {
476  if (ad_comm::ptm)
477  {
478  double time=ad_comm::ptm->get_elapsed_time_and_reset();
480  {
481  (*ad_comm::global_logfile) <<
482  " Time in calculate laplace approximation " << time << endl;
483  }
484  }
485  }
486 #endif
487  for (int ip=num_der_blocks;ip>=1;ip--)
488  {
489  df1b2variable::minder=minder(ip);
490  df1b2variable::maxder=maxder(ip);
491  int mind=y(1).minder;
492  int jmin=max(mind,xsize+1);
493  int jmax=min(y(1).maxder,xsize+usize);
494  for (int i=1;i<=usize;i++)
495  {
496  for (int j=jmin;j<=jmax;j++)
497  {
498  //Hess(i,j-xsize)=y(i+xsize).u_bar[j-mind];
499  y(i+xsize).get_u_bar_tilde()[j-mind]=Hessadjoint(i,j-xsize);
500  }
501  }
502 
504  {
505  for (int j=1;j<=xsize+usize;j++)
506  {
507  *y(j).get_u_tilde()=0;
508  }
509  Hess.initialize();
511  pfmin->user_function();
512  }
513  else
514  {
515  if (ip<num_der_blocks)
516  {
517  f1b2gradlist->reset();
518  set_u_dot(ip);
520  (*re_objective_function_value::pobjfun)=0;
521  df1b2variable pen=0.0;
522  df1b2variable zz=0.0;
523 
525  pfmin->user_function();
526 
529 
530  (*re_objective_function_value::pobjfun)+=pen;
531  (*re_objective_function_value::pobjfun)+=zz;
532 
536  df1b2_gradcalc1();
537  }
538 
539  for (int i=1;i<=usize;i++)
540  {
541  for (int j=jmin;j<=jmax;j++)
542  {
543  //Hess(i,j-xsize)=y(i+xsize).u_bar[j-mind];
544  y(i+xsize).get_u_bar_tilde()[j-mind]=Hessadjoint(i,j-xsize);
545  }
546  }
547 
548  //int mind=y(1).minder;
550  df1b2_gradcalc1();
551 
553  df1b2_gradcalc1();
554 
555  f1b2gradlist->reset();
562  }
563 #ifdef DIAG_TIMER
564  if (ad_comm::time_flag)
565  {
566  if (ad_comm::ptm)
567  {
568  double time=ad_comm::ptm->get_elapsed_time_and_reset();
570  {
571  (*ad_comm::global_logfile) << " time for 3rd derivatives "
572  << time << endl;
573  }
574  }
575  }
576 #endif
577  dvector dtmp(1,xsize);
578  for (int i=1;i<=xsize;i++)
579  {
580  dtmp(i)=*y(i).get_u_tilde();
581  }
583  {
584 #ifndef OPT_LIB
585  assert(nvar <= INT_MAX);
586 #endif
587  dvector scale(1,(int)nvar); // need to get scale from somewhere
588  /*int check=*/initial_params::stddev_scale(scale,x);
589  dvector sscale=scale(1,Dux(1).indexmax());
590  for (int i=1;i<=usize;i++)
591  {
592  Dux(i)=elem_prod(Dux(i),sscale);
593  }
594  dtmp=elem_prod(dtmp,sscale);
595  }
596 
597  for (int i=1;i<=xsize;i++)
598  {
599  xadjoint(i)+=dtmp(i);
600  }
601  for (int i=1;i<=usize;i++)
602  uadjoint(i)+=*y(xsize+i).get_u_tilde();
603  }
604  // *****************************************************************
605  // new stuff to deal with quadraticprior
606  // *****************************************************************
607 
608  int xstuff=3;
610  {
613  block_diagonal_flag=0;
614 #ifndef OPT_LIB
615  assert(nvar <= INT_MAX);
616 #endif
617  dvector scale1(1,(int)nvar); // need to get scale from somewhere
619  /*int check=*/initial_params::stddev_scale(scale1,x);
620 
625  dvector scale(1,(int)nvar); // need to get scale from somewhere
626  /*check=*/initial_params::stddev_scale(scale,x);
627  dvector sscale=scale(1,Dux(1).indexmax());
628 
629  for (int i=1;i<=usize;i++)
630  {
631  Dux(i)=elem_div(Dux(i),sscale);
632  }
633 
634  if (xstuff>1)
635  {
637  }
641 
642  for (int i=1;i<=usize;i++)
643  {
644  Dux(i)=elem_prod(Dux(i),sscale);
645  }
646  //local_dtemp=elem_prod(local_dtemp,sscale);
647 
648  if (xstuff>2)
649  {
650  dvector tmp=evaluate_function_with_quadprior(x,usize,pfmin);
651  for (int i=1;i<=xsize;i++)
652  {
653  xadjoint(i)+=tmp(i);
654  }
655  }
656 
657  if (xstuff>2)
658  {
660  }
661  }
662 
663  // *****************************************************************
664  // new stuff to deal with quadraticprior
665  // *****************************************************************
666 #ifdef DIAG_TIMER
667  if (ad_comm::ptm)
668  {
669  /*double time=*/ad_comm::ptm->get_elapsed_time_and_reset();
670  }
671 #endif
672 
673  #if defined(USE_ATLAS)
675  {
676  //xadjoint -= uadjoint*atlas_solve_spd_trans(Hess,Dux);
677  xadjoint -= atlas_solve_spd_trans(Hess,uadjoint)*Dux;
678  }
679  else
680  {
681  //xadjoint -= uadjoint*solve(Hess,Dux);
682  xadjoint -= solve(Hess,uadjoint)*Dux;
683  }
684  #else
685  //xadjoint -= uadjoint*solve(Hess,Dux);
686  xadjoint -= solve(Hess,uadjoint)*Dux;
687  #endif
688 
689 #ifdef DIAG_TIMER
690  if (ad_comm::ptm)
691  {
692  double time=ad_comm::ptm->get_elapsed_time_and_reset();
694  {
695  (*ad_comm::global_logfile) << " Time in second solve "
696  << time << endl;
697  }
698  }
699  if (ad_comm::ptm1)
700  {
701  double time=ad_comm::ptm1->get_elapsed_time_and_reset();
703  {
704  (*ad_comm::global_logfile) << " Total time in function evaluation "
705  << time << endl << endl;
706  }
707  }
708 #endif
709  }
710  return xadjoint;
711 }
712 
719 {
720 #ifdef DIAG_TIMER
721  if (ad_comm::time_flag)
722  {
723  if (ad_comm::ptm)
724  {
725  (*ad_comm::global_logfile) << " Starting Newton-Raphson "
726  << endl;
727  }
728  }
729 #endif
730  for (int ip=1;ip<=num_der_blocks;ip++)
731  {
732  df1b2variable::minder=minder(ip);
733  df1b2variable::maxder=maxder(ip);
734 
735  set_u_dot(ip);
736 
737  // do we need to reallocate memory for df1b2variables?
738  check_for_need_to_reallocate(ip);
740  //cout << re_objective_function_value::pobjfun << endl;
741  //cout << re_objective_function_value::pobjfun->ptr << endl;
742  (*re_objective_function_value::pobjfun)=0;
743  df1b2variable pen=0.0;
744  df1b2variable zz=0.0;
746  //cout << setprecision(15) << y << endl;
748  {
749  Hess.initialize();
750  grad.initialize();
751  }
752 
753 #ifdef DIAG_TIMER
754  double time1 = 0;
755  if (ad_comm::time_flag)
756  {
757  if (ad_comm::ptm)
758  {
759  time1 = ad_comm::ptm->get_elapsed_time();
760  }
761  }
762 #endif
763  pfmin->user_function();
764 #ifdef DIAG_TIMER
765  if (ad_comm::time_flag)
766  {
767  if (ad_comm::ptm)
768  {
770  {
771  double time=ad_comm::ptm->get_elapsed_time();
772  (*ad_comm::global_logfile) <<
773  " Time in user_function() " << ip << " " << time-time1
774  << endl;
775  }
776  }
777  }
778 #endif
781 
782  (*re_objective_function_value::pobjfun)+=pen;
783  (*re_objective_function_value::pobjfun)+=zz;
784 
785  //cout << setprecision(15) << *re_objective_function_value::pobjfun << endl;
786  //cout << setprecision(15) << pen << endl;
788  {
792  df1b2_gradcalc1();
793  int mind=y(1).minder;
794  int jmin=max(mind,xsize+1);
795  int jmax=min(y(1).maxder,xsize+usize);
796  for (int i=1;i<=usize;i++)
797  for (int j=jmin;j<=jmax;j++)
798  Hess(i,j-xsize)=y(i+xsize).u_bar[j-mind];
799  /*
800  {
801  ofstream ofs("hessreport");
802  ofs << setw(6) << Hess << endl << endl;
803  ofs << setw(10) << setfixed() << setprecision(3) << choleski_decomp(Hess) << endl << endl;
804  ofs << setw(10) << setfixed() << setprecision(3) << inv(Hess) << endl << endl;
805  ofs << setw(10) << setfixed() << setprecision(3) << choleski_decomp(inv(Hess)) << endl << endl;
806  }
807  */
808  // ****************************************************************
809  // ****************************************************************
810  // ****************************************************************
811  // temporary shit
812  /*
813  for (i=1;i<=usize;i++)
814  {
815  for (j=jmin;j<=jmax;j++)
816  {
817  //Hess(i,j-xsize)=y(i+xsize).u_bar[j-mind];
818  y(i+xsize).get_u_bar_tilde()[j-mind]=Hessadjoint(i,j-xsize);
819  }
820  }
821  cout << Hess << endl;
822  df1b2variable::passnumber=2;
823  df1b2_gradcalc1();
824 
825  df1b2variable::passnumber=3;
826  df1b2_gradcalc1();
827  */
828  // ****************************************************************
829  // ****************************************************************
830  // ****************************************************************
831  // ****************************************************************
832  for (int j=jmin;j<=jmax;j++)
833  grad(j-xsize)= re_objective_function_value::pobjfun->u_dot[j-mind];
834  }
835  if (ip<num_der_blocks)
836  f1b2gradlist->reset();
837  }
838 
839 
840  // just to match master pvm routine
841 #ifdef DIAG_TIMER
842  if (ad_comm::time_flag)
843  {
844  if (ad_comm::ptm)
845  {
846  /*double time=*/ad_comm::ptm->get_elapsed_time();
847  }
848  }
849 #endif
850 }
851 
857 {
858  int mmin=y.indexmin();
859  int mmax=y.indexmax();
860 
861  for (int i=mmin;i<=mmax;i++)
862  {
863  y(i).set_u_dot();
864  }
865 }
866 
872 {
873  unsigned int num_active_parameters = nvar;
874  f1b2gradlist->reset();
875 
876  adpool * tmppool=df1b2variable::pool;
877  if (tmppool)
878  {
879  //cout << tmppool << endl;
880  // check if current pool is the right size
881  if (tmppool->nvar != num_active_parameters)
882  {
883  // check sizes of other pools
884  int found_pool_flag=0;
885  for (int i=0;i<df1b2variable::adpool_counter;i++)
886  {
887  if (df1b2variable::adpool_vector[i]->nvar == num_active_parameters)
888  {
889  adpool * tmp = df1b2variable::pool;
890  //cout << "Old Depth = " << df1b2variable::pool->depth_check()
891  // << " " << df1b2variable::pool << " ";
893  //cout << "Depth = " << df1b2variable::pool->depth_check()
894  // << " " << df1b2variable::pool << endl;
897  found_pool_flag=1;
898  break;
899  }
900  }
901  if (!found_pool_flag)
902  {
903  if (df1b2variable::adpool_counter>=df1b2variable::adpool_vectorsize)
904  {
905  cerr << "Need to increase adpool_vectorsize" << endl;
906  ad_exit(1);
907  }
912  //df1b2variable::adpool_counter++;
915  if (!df1b2variable::pool)
916  {
917  cerr << "Memory allocation error" << endl;
918  ad_exit(1);
919  }
920  }
921  }
922  }
923  else
924  {
926  if (!df1b2variable::pool)
927  {
928  cerr << "Memory allocation error" << endl;
929  ad_exit(1);
930  }
931  }
932  df1b2variable::nvar = num_active_parameters;
934 }
static int straight_through_flag
Definition: admodel.h:839
static adpool * pool
Definition: df1b2fun.h:273
void initialize(void)
Description not yet available.
Definition: df1b2f14.cpp:155
static void reset(const init_df1b2vector &, const df1b2variable &)
Description not yet available.
Definition: df1b2f15.cpp:51
static void set_yes_derivatives(void)
Definition: df1b2fun.h:761
df1b2_gradlist * f1b2gradlist
Definition: df1b2glo.cpp:49
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).
Definition: d3arr2a.cpp:92
void set_dependent_variable(const df1b2variable &_x)
Description not yet available.
Definition: df1b2fn2.cpp:699
static adpool * adpool_vector[]
Definition: df1b2fun.h:282
int indexmax(void) const
Definition: df1b2fun.h:389
static void set_no_derivatives(void)
Definition: df1b2fun.h:760
Description not yet available.
Definition: adrndeff.h:182
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.
Definition: df1b2imp.cpp:23
static void set_NO_DERIVATIVES(void)
Disable accumulation of derivative information.
Definition: gradstrc.cpp:641
Description not yet available.
static void set_active_random_effects(void)
Definition: model.cpp:267
static ofstream * global_logfile
Definition: fvar.hpp:8858
void check_pool_size(void)
Description not yet available.
Definition: df1b2lp1.cpp:871
dvector atlas_solve_spd(const dmatrix &M, const dvector &x)
static void get_Lxu_contribution(dmatrix &)
Definition: fquadpri.cpp:249
dvector eigenvalues(const banded_symmetric_dmatrix &_SS)
Description not yet available.
Definition: dmat28.cpp:411
dmatrix trans(const dmatrix &m1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat2.cpp:13
#define x
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_a59.cpp:13
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
Vector of double precision numbers.
Definition: dvector.h:50
int ADqd_flag
Definition: model.cpp:28
dvector choleski_solve_neghess_error(dmatrix M, dvector &v, int &ierror)
Description not yet available.
Definition: dmat37.cpp:216
static int separable_flag
Definition: df1b2fun.h:1351
static void get_cgradient_contribution(dvector, int)
Description not yet available.
Definition: quadpri.cpp:558
static unsigned int nvar_vector[]
Definition: df1b2fun.h:288
static void set_blocksize(void)
Description not yet available.
Definition: df1b2fn2.cpp:89
static int passnumber
Definition: df1b2fun.h:289
static re_objective_function_value * pobjfun
Definition: df1b2fun.h:1693
d3_array elem_div(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements division of a(i, j, k) / b(i, j, k).
Definition: d3arr2a.cpp:112
dvector evaluate_function_with_quadprior(const dvector &x, int usize, function_minimizer *pfmin)
Description not yet available.
Definition: quadpri.cpp:45
static void get_cHessian_contribution_from_vHessian(dmatrix, int)
Description not yet available.
Definition: quadpri.cpp:668
exitptr ad_exit
Definition: gradstrc.cpp:53
df1_two_variable fabs(const df1_two_variable &x)
Definition: df12fun.cpp:891
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.
Definition: df1b2lap.cpp:1476
void initialize(void)
Description not yet available.
Definition: df1b2f10.cpp:171
Description not yet available.
Definition: df1b2fun.h:745
static dvariable reset(const dvar_vector &x)
Definition: model.cpp:345
static const int adpool_vectorsize
Definition: df1b2fun.h:278
static int maxder
Definition: df1b2fun.h:292
Description not yet available.
Definition: df1b2fun.h:266
static int nvarcalc()
Definition: model.cpp:152
void set_u_dot(int i)
Description not yet available.
Definition: df1b2lp1.cpp:856
Description not yet available.
Definition: adpool.h:59
fixed_smartlist nlist
Definition: df1b2fun.h:754
void initialize(void)
Description not yet available.
Definition: df1b2f13.cpp:158
double evaluate_function(const dvector &x, function_minimizer *pfmin)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: df1b2lap.cpp:2026
dvector solve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
Definition: dmat34.cpp:46
prescientific setscientific(void)
Description not yet available.
Definition: admanip.cpp:80
static int print_hess_and_exit_flag
Definition: fvar.hpp:8838
static laplace_approximation_calculator * lapprox
Definition: df1b2fnl.h:61
dmatrix sort(const dmatrix &m, int column, int NSTACK)
Description not yet available.
Definition: dmsort.cpp:17
dvector default_calculations(const dvector &_x, const double &_f, function_minimizer *pfmin)
Description not yet available.
Definition: df1b2lp1.cpp:44
dmatrix atlas_solve_spd_trans(const dmatrix &M, const dmatrix &x)
prnstream & endl(prnstream &)
test_smartlist list
Definition: df1b2fun.h:753
static void set_active_only_random_effects(void)
Definition: model.cpp:251
#define min(a, b)
Definition: cbivnorm.cpp:188
fixed_smartlist2 nlist3
Definition: df1b2fun.h:758
double calculate_importance_sample_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.
Definition: df1b2impf.cpp:23
fixed_smartlist2 nlist2
Definition: df1b2fun.h:756
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Description not yet available.
#define M
Definition: rngen.cpp:57
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
void evaluate_function_gradient(double &f, const dvector &x, function_minimizer *pfmin, dvector &xadjoint, dvector &uadjoint)
Description not yet available.
Definition: df1b2lap.cpp:2166
std::ostream & get_output_stream()
Definition: adglobl.cpp:45
void get_newton_raphson_info(int xs, int us, const init_df1b2vector _y, dmatrix &Hess, dvector &grad, df1b2_gradlist *f1b2gradlist, function_minimizer *pfmin)
Description not yet available.
Definition: df1b2lap.cpp:1924
test_smartlist list3
Definition: df1b2fun.h:757
Description not yet available.
Definition: df1b2fun.h:373
static unsigned int nvar
Definition: df1b2fun.h:290
static int minder
Definition: df1b2fun.h:291
double evaluate_function_quiet(const dvector &x, function_minimizer *pfmin)
Description not yet available.
Definition: df1b2lap.cpp:2137
static int set_index(void)
Definition: df1b2f15.cpp:90
dvector choleski_solve_error(dmatrix M, dvector &v, int &ierror)
Description not yet available.
Definition: dmat37.cpp:198
Description not yet available.
Description not yet available.
Definition: admodel.h:1850
static void increment_adpool_counter(void)
Description not yet available.
Definition: df1b2glo.cpp:24
static void set_YES_DERIVATIVES(void)
Enable accumulation of derivative information.
Definition: gradstrc.cpp:650
void get_newton_raphson_info(function_minimizer *pmin)
Description not yet available.
Definition: df1b2lp1.cpp:718
virtual void user_function()
Definition: xmodelm4.cpp:43
void get_second_ders(int xs, int us, const init_df1b2vector y, dmatrix &Hess, dmatrix &Dux, df1b2_gradlist *f1b2gradlist, function_minimizer *pfmin)
static void get_cHessian_contribution(dmatrix, int)
Description not yet available.
Definition: quadpri.cpp:591
static int get_num_quadratic_prior(void)
Definition: df1b2fun.h:1967
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
static int no_atlas_flag
Definition: fvar.hpp:8840
static int stddev_scale(const dvector &d, const dvector &x)
Definition: model.cpp:202
#define max(a, b)
Definition: cbivnorm.cpp:189
static int adpool_counter
Definition: df1b2fun.h:279
int indexmin(void) const
Definition: df1b2fun.h:388
static int get_num_quadratic_prior(void)
Definition: df1b2fun.h:1916
static double fun_without_pen
Definition: df1b2fun.h:1694
void reset(void)
Description not yet available.
Definition: df1b2fn2.cpp:581
static int first_hessian_flag
Definition: admodel.h:1855
test_smartlist list2
Definition: df1b2fun.h:755
double * u_dot
Definition: df1b2fun.h:196
dmatrix choleski_decomp_positive(const dmatrix &MM, double bound)
Description not yet available.
Definition: dmat35.cpp:33
void df1b2_gradcalc1(void)
Description not yet available.
Definition: df1b2fun.cpp:145
static void set_inactive_only_random_effects(void)
Definition: model.cpp:259
unsigned int nvar
Definition: adpool.h:77
static int separable_calculation_type
Definition: df1b2fun.h:1352
static int in_qp_calculations
Definition: df1b2fun.h:1909