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

Function test_qp4_test3

dlib/test/opt_qp_solver.cpp:165–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163// ----------------------------------------------------------------------------------------
164
165 void test_qp4_test3()
166 {
167 matrix<double> A(3,2);
168 A = 1,2,
169 -3,-1,
170 6,7;
171
172 matrix<double,0,1> b(2);
173 b = 1,
174 2;
175
176 const double C = 2;
177
178 matrix<double,0,1> alpha(2), true_alpha(2), d(3), lambda;
179 alpha = C/2, C/2;
180 d = 0;
181
182 solve_qp4_using_smo(A, tmp(trans(A)*A), b, d, alpha, lambda, 1e-9, 800);
183 matrix<double,0,1> w = lowerbound(-A*alpha, 0);
184
185 dlog << LINFO << "*******************************************************";
186
187 dlog << LINFO << "w: " << trans(w);
188
189 dlog << LINFO << "computed obj: "<< compute_objective_value(w,A,b,C);
190 w = 0, 2, 0;
191 dlog << LINFO << "with true w obj: "<< compute_objective_value(w,A,b,C);
192
193 dlog << LINFO << "alpha: " << trans(alpha);
194 true_alpha = 0, 2;
195 dlog << LINFO << "true alpha: "<< trans(true_alpha);
196
197 dlog << LINFO << "alpha error: "<< max(abs(alpha-true_alpha));
198 DLIB_TEST(max(abs(alpha-true_alpha)) < 1e-9);
199 }
200
201// ----------------------------------------------------------------------------------------
202

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