| 290 | } |
| 291 | |
| 292 | void test_powell ( |
| 293 | const matrix<double,4,1> p |
| 294 | ) |
| 295 | { |
| 296 | const double eps = 1e-15; |
| 297 | const double minf = -1; |
| 298 | matrix<double,4,1> x, opt; |
| 299 | opt(0) = 0; |
| 300 | opt(1) = 0; |
| 301 | opt(2) = 0; |
| 302 | opt(3) = 0; |
| 303 | |
| 304 | double val = 0; |
| 305 | |
| 306 | dlog << LINFO << "testing with powell and the start point: " << trans(p); |
| 307 | |
| 308 | /* |
| 309 | total_count = 0; |
| 310 | x = p; |
| 311 | val=find_min(bfgs_search_strategy(), |
| 312 | objective_delta_stop_strategy(eps), |
| 313 | powell, derivative(powell,1e-8), x, minf); |
| 314 | DLIB_TEST_MSG(dlib::equal(x,opt, 1e-2),opt-x); |
| 315 | DLIB_TEST(approx_equal(val , powell(x))); |
| 316 | dlog << LINFO << "find_min() bfgs: got powell/noder in " << total_count; |
| 317 | |
| 318 | |
| 319 | total_count = 0; |
| 320 | x = p; |
| 321 | val=find_min(cg_search_strategy(), |
| 322 | objective_delta_stop_strategy(eps), |
| 323 | powell, derivative(powell,1e-9), x, minf); |
| 324 | DLIB_TEST_MSG(dlib::equal(x,opt, 1e-2),opt-x); |
| 325 | DLIB_TEST(approx_equal(val , powell(x))); |
| 326 | dlog << LINFO << "find_min() cg: got powell/noder in " << total_count; |
| 327 | */ |
| 328 | |
| 329 | total_count = 0; |
| 330 | x = p; |
| 331 | val=find_min_using_approximate_derivatives(bfgs_search_strategy(), |
| 332 | objective_delta_stop_strategy(eps), |
| 333 | powell, x, minf, 1e-10); |
| 334 | DLIB_TEST_MSG(dlib::equal(x,opt, 1e-1),opt-x); |
| 335 | DLIB_TEST(approx_equal(val , powell(x))); |
| 336 | dlog << LINFO << "find_min() bfgs: got powell/noder2 in " << total_count; |
| 337 | |
| 338 | |
| 339 | total_count = 0; |
| 340 | x = p; |
| 341 | val=find_min_using_approximate_derivatives(lbfgs_search_strategy(4), |
| 342 | objective_delta_stop_strategy(eps), |
| 343 | powell, x, minf, 1e-10); |
| 344 | DLIB_TEST_MSG(dlib::equal(x,opt, 1e-1),opt-x); |
| 345 | DLIB_TEST(approx_equal(val , powell(x))); |
| 346 | dlog << LINFO << "find_min() lbfgs-4: got powell/noder2 in " << total_count; |
| 347 | |
| 348 | |
| 349 | total_count = 0; |
no test coverage detected