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

Function test_qp4_test2

dlib/test/opt_qp_solver.cpp:127–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125// ----------------------------------------------------------------------------------------
126
127 void test_qp4_test2()
128 {
129 matrix<double> A(3,2);
130 A = 1,2,
131 3,-1,
132 6,7;
133
134 matrix<double,0,1> b(2);
135 b = 1,
136 2;
137
138 const double C = 2;
139
140 matrix<double,0,1> alpha(2), true_alpha(2), d(3), lambda;
141 alpha = C/2, C/2;
142 d = 0;
143
144 solve_qp4_using_smo(A, tmp(trans(A)*A), b, d, alpha, lambda, 1e-9, 800);
145 matrix<double,0,1> w = lowerbound(-A*alpha, 0);
146
147 dlog << LINFO << "*******************************************************";
148
149 dlog << LINFO << "w: " << trans(w);
150
151 dlog << LINFO << "computed obj: "<< compute_objective_value(w,A,b,C);
152 w = 0, 0.25, 0;
153 dlog << LINFO << "with true w obj: "<< compute_objective_value(w,A,b,C);
154
155 dlog << LINFO << "alpha: " << trans(alpha);
156 true_alpha = 0.43750, 1.56250;
157 dlog << LINFO << "true alpha: "<< trans(true_alpha);
158
159 dlog << LINFO << "alpha error: "<< max(abs(alpha-true_alpha));
160 DLIB_TEST(max(abs(alpha-true_alpha)) < 1e-9);
161 }
162
163// ----------------------------------------------------------------------------------------
164

Callers 1

test_solve_qp4_using_smoFunction · 0.85

Calls 7

solve_qp4_using_smoFunction · 0.85
tmpFunction · 0.85
lowerboundFunction · 0.85
compute_objective_valueFunction · 0.85
absFunction · 0.85
transFunction · 0.50
maxFunction · 0.50

Tested by

no test coverage detected