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

Function solve_qp_box_using_smo

dlib/test/mpc.cpp:25–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 typename T, long NR, long NC, typename MM, typename L
24 >
25 unsigned long solve_qp_box_using_smo (
26 const matrix_exp<EXP1>& _Q,
27 const matrix_exp<EXP2>& _b,
28 matrix<T,NR,NC,MM,L>& alpha,
29 matrix<T,NR,NC,MM,L>& lower,
30 matrix<T,NR,NC,MM,L>& upper,
31 T eps,
32 unsigned long max_iter
33 )
34 /*!
35 ensures
36 - solves: 0.5*trans(x)*Q*x + trans(b)*x where x is box constrained.
37 !*/
38 {
39 const_temp_matrix<EXP1> Q(_Q);
40 const_temp_matrix<EXP2> b(_b);
41 //cout << "IN QP SOLVER" << endl;
42 //cout << "max eig: " << max(real_eigenvalues(Q)) << endl;
43 //cout << "min eig: " << min(real_eigenvalues(Q)) << endl;
44 //cout << "Q: \n" << Q << endl;
45 //cout << "b: \n" << b << endl;
46
47 // make sure requires clause is not broken
48 DLIB_ASSERT(Q.nr() == Q.nc() &&
49 alpha.size() == lower.size() &&
50 alpha.size() == upper.size() &&
51 is_col_vector(b) &&
52 is_col_vector(alpha) &&
53 is_col_vector(lower) &&
54 is_col_vector(upper) &&
55 b.size() == alpha.size() &&
56 b.size() == Q.nr() &&
57 alpha.size() > 0 &&
58 0 <= min(alpha-lower) &&
59 0 <= max(upper-alpha) &&
60 eps > 0 &&
61 max_iter > 0,
62 "\t unsigned long solve_qp_box_using_smo()"
63 << "\n\t Invalid arguments were given to this function"
64 << "\n\t Q.nr(): " << Q.nr()
65 << "\n\t Q.nc(): " << Q.nc()
66 << "\n\t is_col_vector(b): " << is_col_vector(b)
67 << "\n\t is_col_vector(alpha): " << is_col_vector(alpha)
68 << "\n\t is_col_vector(lower): " << is_col_vector(lower)
69 << "\n\t is_col_vector(upper): " << is_col_vector(upper)
70 << "\n\t b.size(): " << b.size()
71 << "\n\t alpha.size(): " << alpha.size()
72 << "\n\t lower.size(): " << lower.size()
73 << "\n\t upper.size(): " << upper.size()
74 << "\n\t Q.nr(): " << Q.nr()
75 << "\n\t min(alpha-lower): " << min(alpha-lower)
76 << "\n\t max(upper-alpha): " << max(upper-alpha)
77 << "\n\t eps: " << eps
78 << "\n\t max_iter: " << max_iter
79 );
80
81
82 // Compute f'(alpha) (i.e. the gradient of f(alpha)) for the current alpha.

Callers 2

solve_linear_mpcFunction · 0.85
perform_testMethod · 0.85

Calls 9

is_col_vectorFunction · 0.85
reciprocal_maxFunction · 0.85
absFunction · 0.85
minFunction · 0.50
maxFunction · 0.50
diagFunction · 0.50
nrMethod · 0.45
ncMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected