Revision 1935 trunk/src/nh99/hybmcmc.cpp

hybmcmc.cpp (revision 1935)
11 11
#include <sstream>
12 12
using std::istringstream;
13 13

  
14
#if defined(USE_LAPLACE)
15 14
#  include <df1b2fun.h>
16 15
#  include <adrndeff.h>
17
#endif
18 16
#include <admodel.h>
19 17

  
20 18
#if defined(_MSC_VER)
......
126 124
    //double total_spread=2500;
127 125
    //uostream * pofs_sd = NULL;
128 126

  
129
#if defined(USE_LAPLACE)
130 127
    initial_params::set_inactive_random_effects();
131 128
    //int nvar_x=initial_params::nvarcalc();
132 129
    initial_params::set_active_random_effects();
133
    int nvar_re=initial_params::nvarcalc();
134
#endif
135 130

  
136 131
    int nvar=initial_params::nvarcalc(); // get the number of active parameters
137 132
    dmatrix s_covar;
......
154 149
    int ndvar=stddev_params::num_stddev_calc();
155 150
    /*int numdvar=*/stddev_params::num_stddev_number_calc();
156 151

  
157
#if defined(USE_LAPLACE)
158 152
    if (mcmc2_flag==0)
159 153
    {
160 154
      initial_params::set_inactive_random_effects();
161 155
      nvar=initial_params::nvarcalc(); // get the number of active parameters
162 156
    }
163
#endif
164 157

  
165
#if defined(USE_LAPLACE)
166
      independent_variables parsave(1,nvar_re);
167
      initial_params::restore_start_phase();
168
#else
169
      independent_variables parsave(1,nvar);
170
#endif
158
    independent_variables parsave(1,nvar);
159
    initial_params::restore_start_phase();
160

  
171 161
    dvector x(1,nvar);
172 162
    //dvector scale(1,nvar);
173 163
    dmatrix values;
......
488 478
      dvector y(1,nvar);
489 479
      y.initialize();
490 480

  
491
#if defined(USE_LAPLACE)
492 481
      if (mcmc2_flag==0)
493 482
      {
494 483
        initial_params::set_inactive_random_effects();
495 484
      }
496
#endif
497 485

  
498 486
      dvector p(1,nvar);  // momentum
499 487
      int iseed=2197;
......
704 692
{
705 693
  //initial_params::xinit(x);
706 694
  double f=0.0;
707
#if defined(USE_LAPLACE)
708 695
  if (mcmc2_flag==0 && lapprox)
709 696
  {
710 697
    cerr << "error not implemented" << endl;
......
713 700
  }
714 701
  else
715 702
  {
716
#endif
717 703
    dvariable vf=0.0;
718 704
    dvar_vector vx=dvar_vector(x);
719 705
    vf=initial_params::reset(vx);
......
725 711
    vf+=*objective_function_value::pobjfun;
726 712
    f=value(vf);
727 713
    gradcalc(nvar,g);
728
#if defined(USE_LAPLACE)
729 714
  }
730
#endif
731 715
  return f;
732 716
}

Also available in: Unified diff