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

Function test_qp4_test5

dlib/test/opt_qp_solver.cpp:203–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201// ----------------------------------------------------------------------------------------
202
203 void test_qp4_test5()
204 {
205 matrix<double> A(3,3);
206 A = 1,2,4,
207 3,1,6,
208 6,7,-2;
209
210 matrix<double,0,1> b(3);
211 b = 1,
212 2,
213 3;
214
215 const double C = 2;
216
217 matrix<double,0,1> alpha(3), true_alpha(3), d(3), lambda;
218 alpha = C/2, C/2, 0;
219 d = 0;
220
221 solve_qp4_using_smo(A, tmp(trans(A)*A), b, d, alpha, lambda, 1e-9, 800);
222 matrix<double,0,1> w = lowerbound(-A*alpha, 0);
223
224
225 dlog << LINFO << "*******************************************************";
226
227 dlog << LINFO << "w: " << trans(w);
228
229 dlog << LINFO << "computed obj: "<< compute_objective_value(w,A,b,C);
230 w = 0, 0, 0.11111111111111111111;
231 dlog << LINFO << "with true w obj: "<< compute_objective_value(w,A,b,C);
232
233 dlog << LINFO << "alpha: " << trans(alpha);
234 true_alpha = 0, 0.432098765432099, 1.567901234567901;
235 dlog << LINFO << "true alpha: "<< trans(true_alpha);
236
237 dlog << LINFO << "alpha error: "<< max(abs(alpha-true_alpha));
238 DLIB_TEST(max(abs(alpha-true_alpha)) < 1e-9);
239 }
240
241// ----------------------------------------------------------------------------------------
242

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