ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
xmodelm3.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  */
7 #include <sstream>
8 using std::istringstream;
9 
10 #include <admodel.h>
11 #include <df1b2fun.h>
12 #include <adrndeff.h>
13 #include<ctime>
14 
15 void check_java_flags(int& start_flag,int& quit_flag,int& der_flag,
16  int& next_flag);
17 
18 void ad_update_function_minimizer_report(int feval,int iter,int phase,
19  double fval, double gmax,const char * cbuf);
20 void vm_initialize(void);
21 
22 void set_initial_simplex(const tdmatrix& p, const dvector& y,int nvar,
23  const dvector& x, double delta);
24 
25 int get_option_number(const char * option_name,const char * error_message,
26  int& option_value);
27 
28 int get_option_number(const char * option_name,const char * error_message,
29 #ifdef __BORLANDC__
30  long int& option_value);
31 #else
32  long long int& option_value);
33 #endif
34 
35 extern int traceflag;
36 
37 void tracing_message(int traceflag,const char *s);
38 
40  {
41  return inner_opt_flag;
42  }
43 
45 
46 
48 
50  {
51  int nopt=0;
52  int on=0;
53  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-shess"))>-1)
54  {
56  }
57  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-pis"))>-1)
58  {
60  }
61  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-sp"))>-1)
62  {
64  }
65 # if defined(__MINI_MAX__)
66  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-mm"))>-1)
67  {
69  }
70 # else
71  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-mm"))>-1)
72  {
73  cerr << "option -mm MINI_MAX not defined " << endl;
74  ad_exit(1);
75  }
76 # endif
77 
78  //initial_params::read(); // read in the values for the initial parameters
80  {
83  }
85  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-maxph",nopt))>-1)
86  {
87  //int origMPs = initial_params::max_number_phases;
88  int jj=0;
89  if (!nopt)
90  {
91  cerr << "Usage -maxph option needs integer -- ignored" << endl;
92  }
93  else
94  {
95  jj=atoi(ad_comm::argv[on+1]);
96  if (jj<=0)
97  {
98  cerr << "Usage -maxph option needs positive integer -- ignored.\n";
99  }
100  else
101  {
102  if (jj>allphases)
103  {
104  allphases=jj;
105  }
106  }
107  }
108  if (allphases>initial_params::max_number_phases)
109  {
111  }
112  if (jj<allphases){
113  allphases = jj;
115  // cout<<"NOTE: max_number_of_phases reset from "<<origMPs<<" to "
116  // <<initial_params::max_number_phases << endl;
117  }
118  }
119  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-ndv",nopt))>-1)
120  {
121  if (!nopt)
122  {
123  cerr << "Usage -ndv option needs integer -- ignored" << endl;
124  }
125  else
126  {
127  int jj=atoi(ad_comm::argv[on+1]);
128  if (jj<=0)
129  {
130  cerr << "Usage -ndv option needs positive integer -- ignored.\n";
131  }
132  else
133  {
135  }
136  }
137  }
138 
139  // set the maximum number of function evaluations by command line
140  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-maxfn",nopt))>-1)
141  {
142  if (!nopt)
143  {
144  cerr << "Usage -maxph option needs integer -- ignored" << endl;
145  }
146  else
147  {
148  int _maxfn=atoi(ad_comm::argv[on+1]);
149  if (_maxfn<0)
150  {
151  cerr << "Usage -maxfn option needs positive integer -- ignored.\n";
152  }
153  else
154  {
155  maxfn=_maxfn;
156  }
157  }
158  }
159  int _crit=0;
160  // set the maximum number of function evaluations by command line
161  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-crit",nopt))>-1)
162  {
163  if (!nopt)
164  {
165  cerr << "Usage -crit option needs number -- ignored" << endl;
166  }
167  else
168  {
169  istringstream ist(ad_comm::argv[on+1]);
170  ist >> _crit;
171 
172  if (_crit<=0)
173  {
174  cerr << "Usage -crit option needs positive number -- ignored.\n";
175  _crit=0;
176  }
177  }
178  }
179  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-bw",nopt))>-1)
180  {
181  if (!nopt)
182  {
183  cerr << "Usage -bw option needs number -- ignored" << endl;
184  }
185  else
186  {
187  int bandwidth = 0;
188  istringstream ist(ad_comm::argv[on+1]);
189  ist >> bandwidth;
190 
191  if (bandwidth <= 0)
192  {
193  cerr << "Usage -bw option needs positive number -- ignored" << endl;
194  ad_comm::bandwidth = 0;
195  }
196  else
197  {
198  ad_comm::bandwidth = bandwidth;
199  }
200  }
201  }
202  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-phase"))>-1)
203  {
204  int jj=atoi(ad_comm::argv[on+1]);
205  if (jj <=0)
206  {
207  cerr << " Invalid option following command line option -phase -- "
208  << endl << " phase set equal to 1" << endl;
209  }
210  if (jj>allphases)
211  {
212  jj=allphases;
213  }
214  if (jj<=0)
215  {
216  jj=1;
217  }
219  std::ostream& output_stream = get_output_stream();
220  output_stream << "Set current phase to " << jj << endl;
221  }
222 
224  std::string fullpath(ad_comm::argv[0]);
225 #if defined(_WIN32)
226  auto idx1 = fullpath.rfind("\\");
227  auto idx2 = fullpath.rfind(".");
228  auto total = idx2 - idx1 - 1;
229  std::string model_name = fullpath.substr(idx1 + 1, total);
230 #else
231  auto idx1 = fullpath.rfind("/");
232  if (idx1 > 0) ++idx1;
233  std::string model_name = fullpath.substr(idx1);
234 #endif
235  time_t now = time(0);
236  tm* localtm = localtime(&now);
237  if(!random_effects_flag){
238  cout << "Starting optimization of '";
239  } else {
240  cout << "Starting RE optimization of '";
241  }
242  cout << model_name << "' in phase " <<
243  initial_params::current_phase << " of " <<
244  initial_params::max_number_phases << " at " << asctime(localtm);
245  cout.flush();
246  }
247 
248  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-lapqd"))>-1)
249  {
250  ADqd_flag=1;
251  }
252 
254  while (initial_params::current_phase <= allphases)
255  {
257 
260 
261  // get the number of active parameters
262  int nvar=initial_params::nvarcalc();
263  if (nvar < 1)
264  {
265  cerr << "Error -- no active parameters. There must be at least 1"
266  << endl;
267  ad_exit(1);
268  }
269  dvector g(1,nvar);
270  independent_variables x(1,nvar);
272  initial_params::xinit(x); // get the initial values into the
273 
275  if ( (on=option_match(ad_comm::argc,ad_comm::argv,"-uhess"))>-1)
276  {
277  int ierr=0;
278  ifstream ifs("vector");
279  if (!ifs)
280  {
281  cerr << "couldn't open file vector" << endl;
282  ierr=1;
283  }
284  dvector zz(1,x.indexmax());
285  if(ierr==0)
286  {
287  ifs >> zz;
288  if (!ifs)
289  {
290  cerr << "couldn't read vector" << endl;
291  ierr=1;
292  }
293  }
294  if (ierr==0)
295  {
296  dvector xsave(1,x.indexmax());
297  for (;;)
298  {
299  double delta=0;
300  cout << "enter delta" << endl;
301  cin >> delta;
302  xsave=x;
303  x+=delta*zz;
304  initial_params::reset(x); // get the initial values into the
305  userfunction();
306  x=xsave;
307  }
308  }
309  }
310 
311  double f=0.0;
312 
313  int simpflag = -1;
314  if ( (simpflag=option_match(ad_comm::argc,ad_comm::argv,"-simplex"))>-1)
315  {
317  double delta=1.e-4;
318  double ftol=1.e-16;
319  dmatrix p(1,nvar+1,1,nvar);
320  dvector y(1,nvar+1);
321  set_initial_simplex(p,y,nvar,x,delta);
322  adamoeba(p,y,nvar,ftol,maxfn);
323  double ymin=min(y);
324  for (int i=1;i<=nvar+1;i++)
325  if (ymin==y(i))
326  {
327  x=p(i);
328  break;
329  }
330  cerr << "The -simplex option is deprecated. The user should port "
331  << "to the -neldmead option." << endl;
332  }
333  if ( (simpflag=option_match(ad_comm::argc,ad_comm::argv,"-neldmead"))>-1)
334  {
336  double delta=1.e-4;
337  double ftol=1.e-16;
338  dvector mincords = x;
339  double ynewlo;
340  double* pynewlo = &ynewlo;
341  int icount, numres, ifault;
342  int* picount = &icount;
343  int* pnumres = &numres;
344  int* pifault = &ifault;
345  neldmead(nvar,mincords,mincords,pynewlo,ftol,delta,picount,pnumres,
346  pifault);
347  x = mincords;
348  }
349  int lmnflag = -1;
350  int lmnsteps=10;
351  if ( (lmnflag=option_match(ad_comm::argc,ad_comm::argv,"-lmn",nopt))>-1)
352  {
354  {
355  cerr << "At present you can not use the -lmn option for the outer"
356  << endl << " optimiation in a random-effects model" << endl;
357  ad_exit(1);
358  }
359  if (!nopt)
360  {
361  cerr << "Usage -lmn option needs integer -- set to default 10.\n";
362  }
363  else
364  {
365  int jj=atoi(ad_comm::argv[lmnflag+1]);
366  if (jj<=0)
367  {
368  cerr << "Usage -lmn option needs positive integer"
369  " -- set to default 10.\n";
370  }
371  else
372  {
373  lmnsteps=jj;
374  }
375  }
376  }
377  if (lmnflag==-1)
378  {
379  // *********************************************************
380  // block for quasi newton minimization
382  {
383  trust_region_update(nvar,_crit,x,g,f);
384  }
385 #if defined(USE_ADPVM)
387  {
389  {
390  if (maxfn>0)
391  {
392  switch (ad_comm::pvm_manager->mode)
393  {
394  case 1: // master
396  break;
397  case 2: // slave
398  // these don't exist yet
400  (nvar,_crit,x,g,f);
401  break;
402  default:
403  cerr << "error illega value for pvm_manager->mode" << endl;
404  ad_exit(1);
405  }
406  }
407  }
408  else
409  {
410  if (maxfn>0)
411  {
412  switch (ad_comm::pvm_manager->mode)
413  {
414  case 1: // master
415  quasi_newton_block_pvm_master(nvar,_crit,x,g,f);
416  break;
417  case 2: // slave
419  break;
420  default:
421  cerr << "error illega value for pvm_manager->mode" << endl;
422  ad_exit(1);
423  }
424  }
425  }
426  }
427  else
428 #endif
429  {
430  do
431  {
432  if (spminflag)
433  {
434  repeatminflag=1;
435  spminflag=0;
436  }
437  else
438  {
439  repeatminflag=0;
440  }
441  if (maxfn>0)
442  {
443  int nsteps=5;
445  "-lmn2", nopt);
446  if (lmnflag > -1)
447  {
448  if (!nopt)
449  {
450  cerr << "Usage -lmn2 option needs integer"
451  " -- set to default 5" << endl;
452  }
453  else
454  {
455  int jj=atoi(ad_comm::argv[lmnflag+1]);
456  if (jj<=0)
457  {
458  cerr << "Usage -lmn2 option needs positive integer "
459  " -- set to default 5" << endl;
460  }
461  else
462  {
463  nsteps=jj;
464  }
465  }
466  }
467  if (lmnflag<0)
468  {
469  quasi_newton_block(nvar,_crit,x,g,f);
470  }
471  else
472  {
473  limited_memory_quasi_newton_block(nvar,_crit,x,g,f,nsteps);
474  }
475  }
476  }
477  while(repeatminflag);
478  }
479  } // end block for quasi newton minimization
480  else
481  { // block for limited memory quasi newton minimization
482  if (maxfn>0)
483  {
485  }
486  }
487  // end block for limited memory quasi newton minimization
488  // *********************************************************
490 
494  if (!random_effects_flag || !lapprox)
495  {
496 #if defined(USE_ADPVM)
498  {
499  switch (ad_comm::pvm_manager->mode)
500  {
501  case 1:
504  break;
505  case 2:
507  break;
508  default:
509  cerr << "Illegal value for ad_comm::pvm_manager->mode" << endl;
510  ad_exit(1);
511  }
512  }
513  else
514  {
515 #endif //#if defined(USE_ADPVM)
516  userfunction();
517 #if defined(USE_ADPVM)
518  }
519 #endif //#if defined(USE_ADPVM)
520  }
521  else
522  {
523  (*lapprox)(x,f,this);
527  }
529  report(g);
530  // in case the user changes some initial_params in the report section
531  // call reset again
534  if (quit_flag=='Q') break;
535  if (!quit_flag || quit_flag == 'N')
536  {
538  }
539  }
542  {
545  }
547  }
549  {
551  }
552 
554  mcmc2_flag(-1),
555  robust_hybrid_flag(0),
556  ifn(0),
557  ffbest(0)
558  {
559  lapprox=0;
561  //cout << lapprox << endl;
562  maxfn = 1000;
563  iprint = 1;
564  crit = 0.0001;
565  imax = 30;
566  dfn = 0.01;
567  iexit = 0;
568  ihflag = 0;
569  ihang = 0;
570  scroll_flag = 1;
571  maxfn_flag=0;
572  quit_flag=0;
573  min_improve=.0;
574  negdirections=0;
575  spminflag=0;
576  repeatminflag=0;
577 
578  int ssz = 0;
579 
580  int nopt=get_option_number("-ams",
581  "-ams option needs positive integer -- ignored",ssz);
582  if (nopt>-1 && ssz>0) {
583  sz=ssz;
584  }
585  ssz = -1;
586  nopt = get_option_number("-mip",
587  "Warning: Invalid non-positive argument for command line option -mip.", ssz);
588 
589  if (nopt == 1)
590  {
591  if (ssz > 0)
592  {
594  }
595  else
596  {
597  cerr << "Warning: Invalid non-positive argument for command line option -mip.\n"
598  "The default value (" << initial_params::max_num_initial_params << ") will be used.\n";
599  }
600  }
602 
603 #ifdef __BORLANDC__
604  long int lssz;
605 #else
606  long long int lssz;
607 #endif
608  nopt=get_option_number("-cbs",
609  "-cbs option needs positive integer -- ignored",lssz);
610  if (nopt>-1 && lssz>0) {
611  const size_t size = (size_t)lssz;
613  }
614 
615  nopt=get_option_number("-gbs",
616  "-gbs option needs positive integer -- ignored",lssz);
617  if (nopt>-1 && lssz>0) {
618  const size_t size = (size_t)lssz / sizeof(grad_stack_entry);
620  }
621 
622  if (!sz)
623  {
624  pgs = new gradient_structure;
625  }
626  else
627  {
628  pgs = new gradient_structure(sz);
629  }
630  }
631 
634 {
636  {
637  delete multinomial_weights;
639  }
640  if (lapprox)
641  {
642  delete lapprox;
643  lapprox = 0;
644  }
645  delete pgs;
646  pgs = 0;
647  if (negdirections)
648  {
649  delete negdirections;
650  negdirections = 0;
651  }
654 }
655 
657  const dvector& _y, int nvar, const dvector& x, double delta)
658  {
659  dvector& y=(dvector&) _y;
660  dmatrix& p=(dmatrix&) _p;
661  int i;
662  p(1)=x;
663  for (i=2;i<=nvar+1;i++)
664  {
665  p(i)=x;
666  p(i,i-1)+=delta;
667  }
668  dvector xx(1,nvar);
669  double vf=0;
670  for (i=1;i<=nvar+1;i++)
671  {
672  xx=p(i);
675  userfunction();
677  y(i)=vf;
678  }
679  }
680 
681 int get_option_number(const char * option_name,const char * error_message,
682  int& option_value)
683 {
684  int on1;
685  int nopt = 0;
686  if ( (on1=option_match(ad_comm::argc,ad_comm::argv,option_name,nopt))>-1)
687  {
688  if (!nopt)
689  {
690  ad_printf("%s\n",error_message);
691  // cerr << error_message << endl;
692  on1=-1;
693  }
694  else
695  {
696  option_value=atoi(ad_comm::argv[on1+1]);
697  }
698  }
699  return on1;
700 }
701 
702 int get_option_number(const char * option_name,const char * error_message,
703 #ifdef __BORLANDC__
704  long int& option_value)
705 #else
706  long long int& option_value)
707 #endif
708 {
709  int on1;
710  int nopt = 0;
711  if ( (on1=option_match(ad_comm::argc,ad_comm::argv,option_name,nopt))>-1)
712  {
713  if (!nopt)
714  {
715  ad_printf("%s\n",error_message);
716  // cerr << error_message << endl;
717  on1=-1;
718  }
719  else
720  {
721 #if defined(__BORLANDC__) || defined(_MSC_VER)
722  option_value=atol(ad_comm::argv[on1+1]);
723 #else
724  option_value=atoll(ad_comm::argv[on1+1]);
725 #endif
726  }
727  }
728  return on1;
729 }
730 
731 
733 {
734  if (lapprox)
735  {
737  /*
738  lapprox->separable_call_level++;
739  //lapprox->build_up_nested_shape();
740  lapprox->nested_separable_calls_counter
741  (lapprox->separable_call_level)++;
742  //clean(lapprox->nested_tree_position,lapprox->separable_call_level);
743  lapprox->nested_tree_position(lapprox->separable_call_level)++;
744  */
745  }
746 }
747 
749 {
750  /*
751  if (lapprox)
752  {
753  lapprox->build_up_nested_shape();
754  clean(lapprox->nested_tree_position,lapprox->separable_call_level);
755  lapprox->separable_call_level--;
756  }
757  */
758 }
759 
760 
762 {
764  int is=0;
765  if (lapprox->gh->mi==0)
766  {
767  is=lapprox->gh->is;
768  }
769  else
770  {
771  is=lapprox->gh->mi->get_offset()+1;
772  }
773  lapprox->gh->gauss_hermite_values(nsc,is)=
775 }
776 
778 {
783 }
784 
786 {
789  if (lapprox->saddlepointflag==2)
790  {
794  }
795  else
796  {
800  }
801 }
802 
804 {
806  if (lapprox->hesstype==2)
807  {
809  {
811  }
812  else if (lapprox->num_importance_samples &&
814  {
816  {
818  }
819  }
820  }
821 }
822 
824 {
829 }
831 {
833  {
835  }
836  else
837  {
838  if (lapprox->hesstype==2)
839  {
842  {
844  {
846  }
847  }
849  {
850  if (lapprox->saddlepointflag!=2)
851  {
853  }
854  else if (inner_opt()!=0)
855  {
857  }
858  }
859  }
860  }
861 }
862 
864 {
866  int is=0;
867  if (lapprox->gh->mi==0)
868  {
869  is=lapprox->gh->is;
870  }
871  else
872  {
873  is=lapprox->gh->mi->get_offset()+1;
874  }
875  lapprox->gh->gauss_hermite_values(nsc,is)=
877  lapprox->gh->gauss_hermite_values(nsc,is);
878 }
879 
881 {
882  if (lapprox->is_diagnostics_flag)
883  {
884  if (lapprox->importance_sampling_values)
885  {
886  int mmin=lapprox->importance_sampling_values->indexmin();
887  int mmax=lapprox->importance_sampling_values->indexmax();
888  double mn= mean(*lapprox->importance_sampling_values);
889  dmatrix tmp(1,2,mmin,mmax);
890  tmp(2)=*lapprox->importance_sampling_values-mn;
891  tmp(1).fill_seqadd(1,1);
892  tmp=trans(sort(trans(tmp),2));
893  ofstream ofs("is_diagnostics");
894  ofs << "number of importance samples "
895  << lapprox->num_importance_samples << endl;
896  ofs << "importance_sampling_values" << endl;
897  ofs << *lapprox->importance_sampling_values << endl<< endl;;
898  ofs << "normalized importance_sampling_values" << endl;
899  ofs << *lapprox->importance_sampling_values-mn << endl<< endl;;
900  ofs << "sorted normalized importance_sampling_values" << endl;
901  ofs << setw(9) << tmp << endl<< endl;;
902  ofs << "epsilon(1).indexmax() "
903  << lapprox->epsilon(1).indexmax() << endl;
904  ofs << lapprox->epsilon << endl;
905  dmatrix plotstuff(1,2,mmin,mmax);
906  plotstuff(1)=*lapprox->importance_sampling_weights;
907  plotstuff(2)=*lapprox->importance_sampling_values-mn;
908  ofs << " weight value " << endl;
909  ofs << setw(9) << sort(trans(plotstuff),2) << endl;
910  }
911  }
912 }
static int NUM_DEPENDENT_VARIABLES
laplace_approximation_calculator * lapprox
Definition: admodel.h:1862
static adpvm_manager * pvm_manager
Definition: fvar.hpp:8849
void set_multinomial_weights(dvector &d)
Definition: xmodelm3.cpp:548
void trust_region_update(int nvar, int _crit, independent_variables &x, const dvector &_g, const double &_f)
Description not yet available.
Definition: f1b2trst.cpp:20
dvector * multinomial_weights
Definition: admodel.h:1863
Description not yet available.
Definition: adrndeff.h:182
void begin_funnel_stuff(void)
Definition: xmodelm3.cpp:803
void quasi_newton_block_pvm_master(int nvar, int _crit, independent_variables &x, const dvector &g, const double &f)
static void set_NO_DERIVATIVES(void)
Disable accumulation of derivative information.
Definition: gradstrc.cpp:641
Description not yet available.
static void set_GRADSTACK_BUFFER_SIZE(const size_t i)
Set the number of entries contained in the buffer that, in turn, contains the information necessary f...
Definition: gs_set.cpp:119
void limited_memory_quasi_newton_block(int nvar, int _crit, independent_variables &x, const dvector &_g, const double &_f, int nsteps)
Description not yet available.
Definition: df1b2lmn2.cpp:23
function_minimizer(long int sz=0L)
Definition: xmodelm3.cpp:553
dmatrix trans(const dmatrix &m1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat2.cpp:13
#define x
Vector of double precision numbers.
Definition: dvector.h:50
static int inner_opt_flag
Definition: admodel.h:1860
void quasi_newton_block_pvm_master_random_effects(int nvar, int _crit, independent_variables &x, const dvector &g, const double &f)
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
void get_function_difference(void)
Definition: xmodelm3.cpp:823
int ADqd_flag
Definition: model.cpp:28
void neldmead(int n, dvector &_start, dvector &_xmin, double *ynewlo, double reqmin, double delta, int *icount, int *numres, int *ifault)
Nelder-Mead simplex alogrithm.
Definition: amoeba.cpp:150
dvar_matrix * importance_sampling_components
Definition: adrndeff.h:224
void set_initial_simplex(const dmatrix &p, const dvector &y, int nvar, const dvector &x, double delta)
Definition: xmodelm3.cpp:656
void vm_initialize(void)
static char ** argv
Definition: fvar.hpp:8866
void other_separable_stuff_begin(void)
Definition: xmodelm3.cpp:732
static int max_num_initial_params
Definition: admodel.h:837
Holds derivative information for arithmetic operators and math library functions. ...
Definition: fvar.hpp:894
gauss_hermite_stuff * gh
Definition: adrndeff.h:223
static int inner_opt(void)
Definition: xmodelm3.cpp:39
exitptr ad_exit
Definition: gradstrc.cpp:53
static dvariable reset(const dvar_vector &x)
Definition: model.cpp:345
void ad_update_function_minimizer_report(int feval, int iter, int phase, double fval, double gmax, const char *cbuf)
ADMB variable vector.
Definition: fvar.hpp:2172
virtual void between_phases_calculations(void)
Definition: admodel.h:1937
double mean(const dvector &vec)
Returns computed mean of vec.
Definition: cranfill.cpp:43
int get_option_number(const char *option_name, const char *error_message, int &option_value)
Description not yet available.
Definition: getopt.cpp:17
int atoi(adstring &s)
Returns a integer converted from input s.
Definition: atoi.cpp:20
static int nvarcalc()
Definition: model.cpp:152
int get_offset(void)
Definition: multiindex.cpp:47
void adamoeba(const dmatrix &p, const dvector &y, int ndim, double ftol, int maxfn)
Nelder-Mead simplex alogrithm.
Definition: amoeba.cpp:38
void limited_memory_quasi_newton(const independent_variables &, int)
Definition: lmnewton.cpp:32
dmatrix sort(const dmatrix &m, int column, int NSTACK)
Description not yet available.
Definition: dmsort.cpp:17
void end_get_importance_sampling_comnponent(void)
Definition: xmodelm3.cpp:785
prnstream & endl(prnstream &)
Description not yet available.
Definition: fvar.hpp:1937
static int current_phase
Definition: admodel.h:842
static dvector maximum_function_evaluations
Definition: admodel.h:1917
static int max_number_phases
Definition: admodel.h:841
void pvm_slave_function_evaluation_no_derivatives(void)
#define min(a, b)
Definition: cbivnorm.cpp:188
void begin_gauss_hermite_stuff(void)
Definition: xmodelm3.cpp:761
multi_index * mi
Definition: adrndeff.h:413
static int argc
Definition: fvar.hpp:8863
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
void check_java_flags(int &start_flag, int &quit_flag, int &der_flag, int &next_flag)
void other_separable_stuff_end(void)
Definition: xmodelm3.cpp:748
static objective_function_value * pobjfun
Definition: admodel.h:2394
Description not yet available.
static void xinit(const dvector &x)
Definition: model.cpp:226
static int bad_step_flag
Definition: admodel.h:1853
virtual void report(const dvector &gradients)
Definition: admodel.h:1915
void allocate(unsigned int init_size)
Construct array with init_size.
Definition: model.cpp:1318
void function_evaluation_block_pvm_slave(void)
static void set_inactive_random_effects(void)
Definition: model.cpp:288
Description not yet available.
Definition: fvar.hpp:2819
double fill_seqadd(double, double)
Description not yet available.
Definition: dmat21.cpp:35
static void set_CMPDIF_BUFFER_SIZE(const size_t i)
Set the size in bytes of the buffer used to contain the information generated by the &quot;precompiled&quot; de...
Definition: gs_set.cpp:75
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
void set_initial_simplex(const tdmatrix &p, const dvector &y, int nvar, const dvector &x, double delta)
void quasi_newton_block(int nvar, int crit, independent_variables &x, const dvector &g, const double &f)
Description not yet available.
Definition: df1b2qnm.cpp:23
int traceflag
Definition: fvar1.cpp:18
void pvm_master_function_evaluation_no_derivatives(double &f, independent_variables &x, int nvar)
void print_is_diagnostics(laplace_approximation_calculator *lapprox)
Definition: xmodelm3.cpp:880
void report_function_minimizer_stats(void)
Definition: admodel.h:1914
void end_gauss_hermite_stuff(void)
Definition: xmodelm3.cpp:863
dvar_matrix gauss_hermite_values
Definition: adrndeff.h:409
static int bandwidth
Definition: fvar.hpp:8837
static int restart_phase
Definition: admodel.h:843
Description not yet available.
virtual ~function_minimizer()
Destructor.
Definition: xmodelm3.cpp:633
gradient_structure * pgs
Definition: admodel.h:1910
static int output_flag
Definition: admodel.h:1972
static void save(void)
Definition: model.cpp:382
void end_df1b2_funnel_stuff(void)
Definition: xmodelm3.cpp:830
static int negative_eigenvalue_flag
Definition: admodel.h:1859
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
double min_improve
Definition: admodel.h:1900
virtual void userfunction(void)=0
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
void function_evaluation_block_pvm_slave_random_effects(void)
void tracing_message(int traceflag, const char *s)
Description not yet available.
Definition: newfmin.cpp:94
static dvector convergence_criteria
Definition: admodel.h:1915
int ad_printf(FILE *stream, const char *format, Args...args)
Definition: fvar.hpp:9487
static int print_importance_sampling_weights_flag
Definition: adrndeff.h:203
static void set_inactive_only_random_effects(void)
Definition: model.cpp:259
static int random_effects_flag
Definition: admodel.h:1857
static adlist_ptr varsptr
Definition: admodel.h:838
void deallocate(void)
Called by destructor to deallocate memory for a dvector object.
Definition: dvector.cpp:92
void start_get_importance_sampling_comnponent(void)
Definition: xmodelm3.cpp:777
virtual void minimize(void)
Definition: xmodelm3.cpp:49