| 383 | |
| 384 | |
| 385 | void test_simple ( |
| 386 | const matrix<double,2,1> p |
| 387 | ) |
| 388 | { |
| 389 | const double eps = 1e-12; |
| 390 | const double minf = -10000; |
| 391 | matrix<double,2,1> x, opt; |
| 392 | opt(0) = 0; |
| 393 | opt(1) = 0; |
| 394 | double val = 0; |
| 395 | |
| 396 | dlog << LINFO << "testing with simple and the start point: " << trans(p); |
| 397 | |
| 398 | total_count = 0; |
| 399 | x = p; |
| 400 | val=find_min(bfgs_search_strategy(), |
| 401 | objective_delta_stop_strategy(eps), |
| 402 | simple, der_simple, x, minf); |
| 403 | DLIB_TEST_MSG(dlib::equal(x,opt, 1e-5),opt-x); |
| 404 | DLIB_TEST(approx_equal(val , simple(x))); |
| 405 | dlog << LINFO << "find_min() bfgs: got simple in " << total_count; |
| 406 | |
| 407 | |
| 408 | total_count = 0; |
| 409 | x = p; |
| 410 | val=find_min(bfgs_search_strategy(), |
| 411 | gradient_norm_stop_strategy(), |
| 412 | simple, der_simple, x, minf); |
| 413 | DLIB_TEST_MSG(dlib::equal(x,opt, 1e-5),opt-x); |
| 414 | DLIB_TEST(approx_equal(val , simple(x))); |
| 415 | dlog << LINFO << "find_min() bfgs(gn): got simple in " << total_count; |
| 416 | |
| 417 | |
| 418 | total_count = 0; |
| 419 | x = p; |
| 420 | val=find_min(lbfgs_search_strategy(3), |
| 421 | objective_delta_stop_strategy(eps), |
| 422 | simple, der_simple, x, minf); |
| 423 | DLIB_TEST_MSG(dlib::equal(x,opt, 1e-5),opt-x); |
| 424 | DLIB_TEST(approx_equal(val , simple(x))); |
| 425 | dlog << LINFO << "find_min() lbfgs-3: got simple in " << total_count; |
| 426 | |
| 427 | |
| 428 | total_count = 0; |
| 429 | x = p; |
| 430 | val=find_min(cg_search_strategy(), |
| 431 | objective_delta_stop_strategy(eps), |
| 432 | simple, der_simple, x, minf); |
| 433 | DLIB_TEST_MSG(dlib::equal(x,opt, 1e-5),opt-x); |
| 434 | DLIB_TEST(approx_equal(val , simple(x))); |
| 435 | dlog << LINFO << "find_min() cg: got simple in " << total_count; |
| 436 | |
| 437 | |
| 438 | |
| 439 | total_count = 0; |
| 440 | x = p; |
| 441 | val=find_min(bfgs_search_strategy(), |
| 442 | objective_delta_stop_strategy(eps), |
no test coverage detected