Exercise 4.3: Solve a simple QP with inequality constraints
P = [13 12 -2; 12 17 6; -2 6 12];
q = [-22; -14.5; 13];
r = 1;
n = 3;
x_star = [1;1/2;-1];
fprintf(1,'Computing the optimal solution ...');
cvx_begin
variable x(n)
minimize ( (1/2)*quad_form(x,P) + q'*x + r)
x >= -1;
x <= 1;
cvx_end
fprintf(1,'Done! \n');
disp('------------------------------------------------------------------------');
disp('The computed optimal solution is: ');
disp(x);
disp('The given optimal solution is: ');
disp(x_star);
Computing the optimal solution ...
Calling SeDuMi: 12 variables (1 free), 8 equality constraints
------------------------------------------------------------------------
SeDuMi 1.1 by AdvOL, 2005 and Jos F. Sturm, 1998, 2001-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
Split 1 free variables
eqs m = 8, order n = 11, dim = 14, blocks = 2
nnz(A) = 23 + 0, nnz(ADA) = 40, nnz(L) = 24
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 2.60E-001 0.000
1 : -3.21E+001 6.75E-002 0.000 0.2592 0.9000 0.9000 2.59 1 1 1.1E+000
2 : -3.85E+001 2.18E-002 0.000 0.3228 0.9000 0.9000 1.01 1 1 4.3E-001
3 : -4.07E+001 6.79E-003 0.000 0.3115 0.9000 0.9000 0.73 1 1 1.6E-001
4 : -4.30E+001 2.20E-003 0.000 0.3245 0.9000 0.9000 0.63 1 1 6.5E-002
5 : -4.40E+001 6.39E-004 0.000 0.2899 0.9000 0.9000 0.74 1 1 2.2E-002
6 : -4.45E+001 1.76E-004 0.000 0.2759 0.9000 0.9000 0.80 1 1 6.7E-003
7 : -4.46E+001 3.69E-005 0.000 0.2096 0.9000 0.9000 0.94 1 1 1.5E-003
8 : -4.46E+001 1.05E-006 0.000 0.0285 0.9900 0.9900 0.97 1 1 4.2E-005
9 : -4.46E+001 2.75E-008 0.275 0.0261 0.9900 0.8177 1.00 1 1 5.2E-006
10 : -4.46E+001 8.13E-010 0.358 0.0296 0.9904 0.9900 1.00 1 1 2.0E-007
11 : -4.46E+001 6.17E-011 0.000 0.0759 0.9900 0.9489 0.99 1 1 1.5E-008
12 : -4.46E+001 1.38E-011 0.092 0.2234 0.7969 0.9000 1.00 2 2 3.5E-009
iter seconds digits c*x b*y
12 0.1 Inf -4.4624999751e+001 -4.4624999677e+001
|Ax-b| = 9.6e-010, [Ay-c]_+ = 1.7E-008, |x|= 3.0e+001, |y|= 2.1e+001
Detailed timing (sec)
Pre IPM Post
0.000E+000 6.009E-002 1.001E-002
Max-norms: ||b||=3.605551e+000, ||c|| = 22,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 3.60555.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): -21.625
Done!
------------------------------------------------------------------------
The computed optimal solution is:
1.0000
0.4999
-1.0000
The given optimal solution is:
1.0000
0.5000
-1.0000