a 2D version
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
648 B

4 years ago
%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-01-08 17:00:14
% @LastEditTime: 2021-01-10 09:07:05
%--------------------------
function x = quadratic_programming(A, b, Q_obj)
% 1. compute initial feasible solution
warning('off','all')
x0 = A \ b;
warning('on','all')
% 2. compute null-space matrix Z
[~, SpRight] = spspaces(A, 3, 10^-10);
Q = SpRight{1};
J = SpRight{3};
Z = Q(:,J); % null-space matrix of A
% Z = null(full(A)); % slow version
% 3. compute step \omega
L = Z' * Q_obj * Z;
rhs = - Z' * Q_obj * x0;
omega = L \ rhs;
x = x0 + Z * omega;
end