ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mod_mc2.cpp
Go to the documentation of this file.
1 
5 # include <df1b2fun.h>
6 # include <adrndeff.h>
7 #include <admodel.h>
8 
9 double better_rand(long int&);
10 
12  const independent_variables& x)
13 {
14  //initial_params::xinit(x);
15  double f=0.0;
16  if (mcmc2_flag==0 && lapprox)
17  {
18  dvector g=(*lapprox)(x,f,this);
19  }
20  else
21  {
22  dvariable vf=0.0;
25  userfunction();
27  f=value(vf);
28  }
29  return f;
30 }
31 
32 #if !defined(USE_ADPVM)
34  const dvector& x){return 0.0;}
35 #else
37  const dvector& x)
38 {
39  double f=0.0;
40  {
41  dvariable vf=0.0;
43  vf=initial_params::reset(vx);
44  send_x_to_slaves(vx);
46  userfunction();
48  dvar_matrix fslave=get_f_from_slaves();
49  vf+=sum(fslave);
50  f=value(vf);
51  }
52  return f;
53 }
54 #endif
55 
56 #if !defined(USE_ADPVM)
58 #else
60 {
61  double f=0.0;
62  {
63  dvariable vf=0.0;
64  dvar_vector vx=get_x_from_master();
65  vf=initial_params::reset(vx);
67  userfunction();
69  send_int_to_master(67);
70  send_f_to_master(vf);
71  }
72 }
73 #endif
74 
77 {
78  //initial_params::xinit(x);
79  double f=0.0;
80  if (mcmc2_flag==0 && lapprox)
81  {
82  g=(*lapprox)(x,f,this);
83  }
84  else
85  {
86  dvariable vf=0.0;
89  userfunction();
91  f=value(vf);
92  gradcalc(nvar,g);
93  }
94  return f;
95 }
laplace_approximation_calculator * lapprox
Definition: admodel.h:1862
Description not yet available.
#define x
Vector of double precision numbers.
Definition: dvector.h:50
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
static dvariable reset(const dvar_vector &x)
Definition: model.cpp:345
ADMB variable vector.
Definition: fvar.hpp:2172
void gradcalc(int nvar, const dvector &g)
Definition: sgradclc.cpp:77
Description not yet available.
Definition: fvar.hpp:1937
static objective_function_value * pobjfun
Definition: admodel.h:2394
Description not yet available.
double pvm_master_get_monte_carlo_value(int nvar, const dvector &x)
Definition: mod_mc2.cpp:36
void pvm_slave_get_monte_carlo_value(int nvar)
Definition: mod_mc2.cpp:59
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
Description not yet available.
double better_rand(long int &idum)
Description not yet available.
Definition: bet_rand.cpp:18
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
virtual void userfunction(void)=0
double get_monte_carlo_value(int nvar, const independent_variables &x)
Definition: mod_mc2.cpp:11
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518