MCPcopy Create free account
hub / github.com/davisking/dlib / test_bound_solver_neg_rosen

Function test_bound_solver_neg_rosen

dlib/test/optimization.cpp:972–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

970
971 template <typename search_strategy_type>
972 double test_bound_solver_neg_rosen (dlib::rand& rnd, search_strategy_type search_strategy)
973 {
974 using namespace dlib::test_functions;
975 print_spinner();
976 matrix<double,2,1> starting_point, lower, upper, x;
977
978
979 // pick random bounds
980 lower = rnd.get_random_gaussian()+1, rnd.get_random_gaussian()+1;
981 upper = rnd.get_random_gaussian()+1, rnd.get_random_gaussian()+1;
982 while (upper(0) < lower(0)) upper(0) = rnd.get_random_gaussian()+1;
983 while (upper(1) < lower(1)) upper(1) = rnd.get_random_gaussian()+1;
984
985 starting_point = rnd.get_random_double()*(upper(0)-lower(0))+lower(0),
986 rnd.get_random_double()*(upper(1)-lower(1))+lower(1);
987
988 dlog << LINFO << "lower: "<< trans(lower);
989 dlog << LINFO << "upper: "<< trans(upper);
990 dlog << LINFO << "starting: "<< trans(starting_point);
991
992 x = starting_point;
993 double val = find_max_box_constrained(
994 search_strategy,
995 objective_delta_stop_strategy(1e-16, 500),
996 neg_rosen, der_neg_rosen, x,
997 lower,
998 upper
999 );
1000
1001 DLIB_TEST_MSG(std::abs(val - neg_rosen(x)) < 1e-11, std::abs(val - neg_rosen(x)));
1002 dlog << LINFO << "neg_rosen solution:\n" << x;
1003
1004 dlog << LINFO << "neg_rosen gradient: "<< trans(der_neg_rosen(x));
1005 const double gradient_residual = unconstrained_gradient_magnitude_neg_funct(der_neg_rosen, x, lower, upper);
1006 dlog << LINFO << "gradient_residual: "<< gradient_residual;
1007
1008 return gradient_residual;
1009 }
1010
1011 template <typename search_strategy_type>
1012 double test_bound_solver_rosen (dlib::rand& rnd, search_strategy_type search_strategy)

Callers 1

Calls 10

print_spinnerFunction · 0.85
find_max_box_constrainedFunction · 0.85
absFunction · 0.85
neg_rosenFunction · 0.85
der_neg_rosenFunction · 0.85
get_random_gaussianMethod · 0.80
get_random_doubleMethod · 0.80
transFunction · 0.50

Tested by

no test coverage detected