Revision 1109 trunk/src/df1b2separable/df1b2impf.cpp
df1b2impf.cpp (revision 1109)  

2  2 
* $Id$ 
3  3 
* 
4  4 
* Author: David Fournier 
5 
* Copyright (c) 20082012 Regents of the University of California


5 
* Copyright (c) 20082012 Regents of the University of California 

6  6 
*/ 
7  7 
/** 
8  8 
* \file 
...  ...  
29  29 
gradient_structure::set_YES_DERIVATIVES(); 
30  30 
int nvar=x.size()+u0.size()+u0.size()*u0.size(); 
31  31 
independent_variables y(1,nvar); 
32 


32  
33  33 
// need to set random effects active together with whatever 
34  34 
// init parameters should be active in this phase 
35 
initial_params::set_inactive_only_random_effects();


36 
initial_params::set_active_random_effects();


37 
/*int onvar=*/initial_params::nvarcalc();


35 
initial_params::set_inactive_only_random_effects(); 

36 
initial_params::set_active_random_effects(); 

37 
/*int onvar=*/initial_params::nvarcalc(); 

38  38 
initial_params::xinit(y); // get the initial values into the 
39  39 
// do we need this next line? 
40  40 
y(1,xs)=x; 
...  ...  
55  55 
for (j=1;j<=us;j++) 
56  56 
y(ii++)=Hess(i,j); 
57  57  
58 
dvar_vector vy=dvar_vector(y);


58 
dvar_vector vy=dvar_vector(y); 

59  59 
initial_params::stddev_vscale(d,vy); 
60  60 
dvar_matrix vHess(1,us,1,us); 
61  61 
ii=xs+us+1; 
...  ...  
100  100 
ad_begin_funnel(); 
101  101 
int icount=0; 
102  102  
103 


104  103 
for (int is=lbound;is<=ubound;is++) 
105  104 
{ 
106  105 
if (is>nsamp) break; 
107  106 
icount++; 
108  107 
dvar_vector tau=ch*pmin>lapprox>epsilon(is); 
109 


108 


110  109 
vy(xs+1,xs+us).shift(1)+=tau; 
111  110 
initial_params::reset(vy); // get the values into the model 
112  111 
vy(xs+1,xs+us).shift(1)=tau; 
113 


112  
114  113 
*objective_function_value::pobjfun=0.0; 
115  114 
pmin>AD_uf_outer(); 
116 


115  
117  116 
if (pmin>lapprox>use_outliers==0) 
118  117 
{ 
119  118 
sample_value(icount)=*objective_function_value::pobjfun 
...  ...  
122  121 
else 
123  122 
{ 
124  123 
dvector& e=pmin>lapprox>epsilon(is); 
125 


124  
126  125 
sample_value(icount)=*objective_function_value::pobjfun 
127 
+sum(log(.95*exp(0.5*square(e))+.05/3.0*exp(square(e)/18.0)));


126 
+sum(log(.95*exp(0.5*square(e))+.05/3.0*exp(square(e)/18.0))); 

128  127 
} 
129  128 
} 
130 


129  
131  130 
if (icount>0) 
132  131 
{ 
133  132 
mean_count+=1; 
134  133 
dvar_vector tsp=sample_value(1,icount); 
135  134 
double min_vf=min(value(tsp)); 
136 
fdv=log(mean(exp(min_vftsp)))min_vf;


135 
fdv=log(mean(exp(min_vftsp)))min_vf; 

137  136 
dvariable tmp; 
138  137 
tmp=fdv; 
139  138 
fvalues(mean_count)=tmp; 
...  ...  
141  140 
} 
142  141 
lbound+=samplesize; 
143  142 
ubound+=samplesize; 
144 


145  143 
} 
146  144 

147  145 
double fm=mean(value(fvalues(1,mean_count))); 
Also available in: Unified diff