Revision 1109 trunk/src/df1b2-separable/df1b2im3.cpp

df1b2im3.cpp (revision 1109)
2 2
 * $Id$
3 3
 *
4 4
 * Author: David Fournier
5
 * Copyright (c) 2008-2012 Regents of the University of California 
5
 * Copyright (c) 2008-2012 Regents of the University of California
6 6
 */
7 7
/**
8 8
 * \file
......
35 35
  int hroom =  int(sum(square(lrea)));
36 36
  int nvar=x.size()+u0.size()+hroom;
37 37
  independent_variables y(1,nvar);
38
  
38

  
39 39
  // need to set random effects active together with whatever
40 40
  // init parameters should be active in this phase
41
  initial_params::set_inactive_only_random_effects(); 
42
  initial_params::set_active_random_effects(); 
43
  /*int onvar=*/initial_params::nvarcalc(); 
41
  initial_params::set_inactive_only_random_effects();
42
  initial_params::set_active_random_effects();
43
  /*int onvar=*/initial_params::nvarcalc();
44 44
  initial_params::xinit(y);    // get the initial values into the
45 45
  // do we need this next line?
46 46
  y(1,xs)=x;
......
55 55
    quadratic_prior::get_cHessian_contribution(Hess,vxs);
56 56
  }
57 57
 // Here need hooks for sparse matrix structures
58
  
58

  
59 59
  dvar3_array & block_diagonal_vhessian=
60 60
    *pmin->lapprox->block_diagonal_vhessian;
61 61
  block_diagonal_vhessian.initialize();
......
76 76
  dvector g(1,nvar);
77 77
  gradcalc(0,g);
78 78
  gradient_structure::set_YES_DERIVATIVES();
79
  dvar_vector vy=dvar_vector(y); 
79
  dvar_vector vy=dvar_vector(y);
80 80
  //initial_params::stddev_vscale(d,vy);
81 81
  ii=xs+us+1;
82 82
  if (initial_df1b2params::have_bounded_random_effects)
......
105 105
   int nsamp=pmin->lapprox->num_importance_samples;
106 106

  
107 107
   dvariable vf=0.0;
108
  
108

  
109 109
   dvar_vector sample_value(1,nsamp);
110 110
   sample_value.initialize();
111 111

  
......
122 122
         pmin->lapprox->epsilon(is)(offset+1,offset+lus).shift(1);
123 123
       offset+=lus;
124 124
     }
125
    
125

  
126 126
     // have to reorder the terms to match the block diagonal hessian
127 127
     imatrix & ls=*(pmin->lapprox->block_diagonal_re_list);
128 128
     int mmin=ls.indexmin();
129 129
     int mmax=ls.indexmax();
130
    
130

  
131 131
     int ii=1;
132 132
     int i;
133 133
     for (i=mmin;i<=mmax;i++)
......
187 187
         neps-value(*objective_function_value::pobjfun);
188 188

  
189 189
       sample_value(is)=*objective_function_value::pobjfun
190
         -neps; 
190
         -neps;
191 191
     }
192 192
   }
193 193

  
......
241 241

  
242 242

  
243 243
   double min_vf=min(value(sample_value));
244
   vf=min_vf-log(mean(exp(min_vf-sample_value))); 
245
   vf-=us*0.91893853320467241; 
246
   
247
  
244
   vf=min_vf-log(mean(exp(min_vf-sample_value)));
245
   vf-=us*0.91893853320467241;
246

  
248 247
   int sgn=0;
249 248
   dvariable ld=0.0;
250 249
   if (ad_comm::no_ln_det_choleski_flag)
......
275 274
   initial_params::reset(vy);    // get the values into the model
276 275
   gradient_structure::set_YES_DERIVATIVES();
277 276
  
278
  
279 277
  ii=1;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff