Revision 1109 trunk/src/df1b2separable/dflocmin.cpp
dflocmin.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 
...  ...  
27  27  
28  28 
double re_objective_function_value::fun_without_pen=0; 
29  29  
30 


31 
int laplace_approximation_calculator::saddlepointflag=0; 

30 
int laplace_approximation_calculator::saddlepointflag=0; 

32  31 
int laplace_approximation_calculator::print_importance_sampling_weights_flag=0; 
33  32  
34 
int laplace_approximation_calculator::where_are_we_flag=0;


35 
dvar_vector *


33 
int laplace_approximation_calculator::where_are_we_flag=0; 

34 
dvar_vector * 

36  35 
laplace_approximation_calculator::variance_components_vector=0; 
37  36 
*/ 
38  37  
...  ...  
61  60 
if(f2<fbest) 
62  61 
{ 
63  62 
better_flag=1; 
64 
fbest=f2;


63 
fbest=f2; 

65  64 
lambda*=5.0; 
66  65 
vbest=v; 
67  66 
s=v; 
...  ...  
72  71 
{ 
73  72 
// we have a better value so go with it 
74  73 
return vbest; 
75 
}


74 
} 

76  75 
else 
77  76 
{ 
78  77 
// try a smaller trust region 
...  ...  
110  109 
fmc1.crit=1.e12; 
111  110 
double fmsave=fmc1.maxfn; 
112  111 
fmc1.maxfn=1000;; 
113 


114 


112  
115  113 
fmc1.dfn=1.e2; 
116  114 
while (fmc1.ireturn>=0) 
117  115 
{ 
...  ...  
124  122  
125  123 
dvector z=H*v; 
126  124 
double vHv=v*z; 
127 


125  
128  126 
double gradv=grad*v; 
129  127 
f=lambda*gradv+0.5*lambda*lambda*vHv+ square(ns21.0); 
130  128 
//f=0.5*lambda*lambda*s*H*s; 
131 
if (f<fb)


129 
if (f<fb) 

132  130 
{ 
133  131 
fb=f; 
134  132 
ub=s; 
135  133 
} 
136 
g=lambda*grad/ns lambda * gradv*s/ns2


137 
+ lambda * lambda * z/ns


134 
g=lambda*grad/ns lambda * gradv*s/ns2 

135 
+ lambda * lambda * z/ns 

138  136 
 lambda * lambda * vHv*s/ns2 + 4.0*(ns21.0)*s; 
139 


140  137 
} 
141  138 
} 
142  139 
s=ub; 
...  ...  
165  162 
// fmc1.ihflag=0; 
166  163 
// fmc1.crit=1.e12; 
167  164 
// double beta=.1; 
168 
//


165 
// 

169  166 
// s.initialize(); 
170 
//


167 
// 

171  168 
// fmc1.dfn=1.e2; 
172  169 
// while (fmc1.ireturn>=0) 
173  170 
// { 
...  ...  
183  180 
// else 
184  181 
// { 
185  182 
// f=grad*s+0.5*(s*(H*s))+0.5*beta/den; 
186 
// if (f<fb)


183 
// if (f<fb) 

187  184 
// { 
188  185 
// fb=f; 
Also available in: Unified diff