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

Function test_rosen

dlib/test/optimization.cpp:515–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513
514
515 void test_rosen (
516 const matrix<double,2,1> p
517 )
518 {
519 const double eps = 1e-15;
520 const double minf = -10;
521 matrix<double,2,1> x, opt;
522 opt(0) = 1;
523 opt(1) = 1;
524
525 double val = 0;
526
527 dlog << LINFO << "testing with rosen and the start point: " << trans(p);
528
529 total_count = 0;
530 x = p;
531 val=find_min(bfgs_search_strategy(),
532 objective_delta_stop_strategy(eps),
533 rosen, der_rosen, x, minf);
534 DLIB_TEST_MSG(dlib::equal(x,opt, 1e-7),opt-x);
535 DLIB_TEST(approx_equal(val , rosen(x)));
536 dlog << LINFO << "find_min() bfgs: got rosen in " << total_count;
537
538
539 total_count = 0;
540 x = p;
541 val=find_min(bfgs_search_strategy(),
542 gradient_norm_stop_strategy(),
543 rosen, der_rosen, x, minf);
544 DLIB_TEST_MSG(dlib::equal(x,opt, 1e-7),opt-x);
545 DLIB_TEST(approx_equal(val , rosen(x)));
546 dlog << LINFO << "find_min() bfgs(gn): got rosen in " << total_count;
547
548
549 total_count = 0;
550 x = p;
551 val=find_min(lbfgs_search_strategy(20),
552 objective_delta_stop_strategy(eps),
553 rosen, der_rosen, x, minf);
554 DLIB_TEST_MSG(dlib::equal(x,opt, 1e-7),opt-x);
555 DLIB_TEST(approx_equal(val , rosen(x)));
556 dlog << LINFO << "find_min() lbfgs-20: got rosen in " << total_count;
557
558
559 total_count = 0;
560 x = p;
561 val=find_min(cg_search_strategy(),
562 objective_delta_stop_strategy(eps),
563 rosen, der_rosen, x, minf);
564 DLIB_TEST_MSG(dlib::equal(x,opt, 1e-7),opt-x);
565 DLIB_TEST(approx_equal(val , rosen(x)));
566 dlog << LINFO << "find_min() cg: got rosen in " << total_count;
567
568
569
570 total_count = 0;
571 x = p;
572 val=find_min(bfgs_search_strategy(),

Callers 1

optimization_testFunction · 0.85

Calls 15

find_minFunction · 0.85
absFunction · 0.85
find_min_bobyqaFunction · 0.85
approx_equalFunction · 0.70
rosenFunction · 0.70
transFunction · 0.50
equalFunction · 0.50

Tested by

no test coverage detected