Revision 760 branches/threaded2/tests/threaded_hessian_routine/tests_threaded_hessian_routine.cpp
tests_threaded_hessian_routine.cpp (revision 760)  

31  31 
__thread dvariable* tests_threaded::variable = nullptr; 
32  32  
33  33 
int simple(int argc, char* argv[]); 
34 
/* 

35  34 
void hello_world() 
36  35 
{ 
37  36 
} 
...  ...  
856  855 
} 
857  856 
ASSERT_EQ(nullptr, initial_params::varsptr); 
858  857 
} 
859 
TEST(tests_threaded, simple) 

858 
TEST(tests_threaded, simple2)


860  859 
{ 
861  860 
initial_params::varsptr = new adlist_ptr(initial_params::max_num_initial_params); 
862  861 
char* argv[] = { (char*)"simple/simple" }; 
...  ...  
1280  1279 
} 
1281  1280 
ASSERT_EQ(nullptr, initial_params::varsptr); 
1282  1281 
} 
1282 
TEST(tests_threaded, simple) 

1283 
{ 

1284 
initial_params::varsptr = new adlist_ptr(initial_params::max_num_initial_params); 

1285 
char* argv[] = { (char*)"simple/simple" }; 

1286 
simple(1, argv); 

1287 
delete initial_params::varsptr; 

1288 
initial_params::varsptr = nullptr; 

1289 
} 

1283  1290 
TEST(tests_threaded, hess_routine_noparallel) 
1284  1291 
{ 
1285  1292 
int argc = 1; 
...  ...  
1301  1308 
delete initial_params::varsptr; 
1302  1309 
initial_params::varsptr = nullptr; 
1303  1310 
} 
1304 
*/ 

1305 
TEST(tests_threaded, threaded_hess_routine_noparallel) 

1311 
TEST(tests_threaded, threaded_hess_routine_threaded) 

1306  1312 
{ 
1307  1313 
int argc = 1; 
1308  1314 
char* argv[] = { (char*)"simple/simple" }; 
1309  1315 
ad_set_new_handler(); 
1310  1316 
ad_exit=&ad_boundf; 
1311  1317  
1312 
ASSERT_EQ(nullptr, initial_params::varsptr); 

1313 
gradient_structure::set_NO_DERIVATIVES(); 

1314 
gradient_structure::set_YES_SAVE_VARIABLES_VALUES(); 

1315 
initial_params::varsptr = new adlist_ptr(initial_params::max_num_initial_params); 

1316  
1317 
if (!arrmblsize) arrmblsize=15000000; 

1318 
model_parameters mp(arrmblsize,argc,argv); 

1319 
mp.iprint=10; 

1320 
mp.preliminary_calculations(); 

1321 
mp.minimize(); 

1322 
mp.hess_routine_noparallel(); 

1323  
1324 
function<void(void)> f = [&argc, &argv](){ 

1318 
function<void(const dvector&, const dvector&)> f = [&argc, &argv](const dvector& dv, const dvector& g){ 

1319 
ASSERT_EQ(nullptr, gradient_structure::GRAD_STACK1); 

1325  1320 
gradient_structure::set_YES_DERIVATIVES(); 
1326 
//gradient_structure::set_YES_SAVE_VARIABLES_VALUES(); 

1327  1321 
initial_params::varsptr = new adlist_ptr(initial_params::max_num_initial_params); 
1328  1322 
const long int arrmblsize = 15000000; 
1329  1323 
model_parameters mp(arrmblsize, argc, argv); 
1324 
mp.iprint = 10; 

1325 
mp.preliminary_calculations(); 

1330  1326  
1331  1327 
const int nvar=initial_params::nvarcalc(); 
1332  1328 
independent_variables x(1,nvar); 
1333  1329 
initial_params::xinit(x); 
1330 
x = dv; 

1334  1331  
1335 
mp.preliminary_calculations(); 

1336  1332 
dvariable vf = initial_params::reset(dvar_vector(x)); 
1337 
*objective_function_value::pobjfun=0.0;


1338 
mp.userfunction(); 

1333 
*objective_function_value::pobjfun = 0.0;


1334 
mp.pre_userfunction();


1339  1335 
vf+=*objective_function_value::pobjfun; 
1340  1336 
double f = value(vf); 
1341  1337  
1342 
dvector g1(1, nvar); 

1343 
gradcalc(nvar,g1); 

1344 
cout << __FILE__ << ' ' << __LINE__ << ' ' << g1 << endl; 

1338 
g.initialize(); 

1339 
gradcalc(nvar,g); 

1345  1340  
1346  1341 
delete initial_params::varsptr; 
1347  1342 
initial_params::varsptr = nullptr; 
1348  1343 
}; 
1349  1344  
1350 
const int nvar = initial_params::nvarcalc(); 

1345 
const double delta = 1.e5; 

1346 
const double eps = 0.1; 

1347 
const double eps2 = eps * eps; 

1348 
const int nvar = 2;//initial_params::nvarcalc(); 
Also available in: Unified diff