Commit b509a169 authored by Davis King's avatar Davis King

Made tests more robust.

parent 5fecb30c
......@@ -253,7 +253,7 @@ namespace
const double C = 2;
matrix<double,0,1> alpha(2), true_alpha(2), d(3), lambda;
matrix<double,0,1> alpha(2), d(3), lambda;
alpha = C/2, C/2;
solve_qp4_using_smo(A, tmp(trans(A)*A), b, d, alpha, lambda, 1e-9, 800);
......@@ -263,16 +263,13 @@ namespace
dlog << LINFO << "w: " << trans(w);
dlog << LINFO << "computed obj: "<< compute_objective_value(w,A,b,C);
const double computed_obj = compute_objective_value(w,A,b,C);
w = 0, 0, 0;
dlog << LINFO << "with true w obj: "<< compute_objective_value(w,A,b,C);
const double true_obj = compute_objective_value(w,A,b,C);
dlog << LINFO << "computed obj: "<< computed_obj;
dlog << LINFO << "with true w obj: "<< true_obj;
dlog << LINFO << "alpha: " << trans(alpha);
true_alpha = 0, 2;
dlog << LINFO << "true alpha: "<< trans(true_alpha);
dlog << LINFO << "alpha error: "<< max(abs(alpha-true_alpha));
DLIB_TEST_MSG(max(abs(alpha-true_alpha)) < 1e-8, max(abs(alpha-true_alpha)));
DLIB_TEST_MSG(abs(computed_obj - true_obj) < 1e-8, abs(computed_obj - true_obj));
}
void test_qp4_test6()
......@@ -289,26 +286,24 @@ namespace
const double C = 2;
matrix<double,0,1> alpha(3), true_alpha(3), d(3), lambda;
matrix<double,0,1> alpha(3), d(3), lambda;
alpha = C/2, C/2, 0;
solve_qp4_using_smo(A, tmp(trans(A)*A), b, d, alpha, lambda, 1e-9, 800);
solve_qp4_using_smo(A, tmp(trans(A)*A), b, d, alpha, lambda, 1e-9, 3000);
matrix<double,0,1> w = lowerbound(-A*alpha, 0);
dlog << LINFO << "*******************************************************";
dlog << LINFO << "w: " << trans(w);
dlog << LINFO << "computed obj: "<< compute_objective_value(w,A,b,C);
w = 0, 0, 0;
dlog << LINFO << "with true w obj: "<< compute_objective_value(w,A,b,C);
dlog << LINFO << "alpha: " << trans(alpha);
true_alpha = 2, 0, 0;
dlog << LINFO << "true alpha: "<< trans(true_alpha);
const double computed_obj = compute_objective_value(w,A,b,C);
w = 0, 0, 0;
const double true_obj = compute_objective_value(w,A,b,C);
dlog << LINFO << "computed obj: "<< computed_obj;
dlog << LINFO << "with true w obj: "<< true_obj;
dlog << LINFO << "alpha error: "<< max(abs(alpha-true_alpha));
DLIB_TEST(max(abs(alpha-true_alpha)) < 1e-9);
DLIB_TEST_MSG(abs(computed_obj - true_obj) < 1e-8, abs(computed_obj - true_obj));
}
void test_qp4_test7()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment