%% Examine quadprog Optimization Process
% To see the optimization process for quadprog, set options to show an iterative display and return four outputs. The problem is to minimize
% \frac{1}{2}x^T Hx + f^T x
% subject to
% 0\le x\le 1,
% where
% H=\left\lbrack \begin{array}{ccc}
% 2 & 1 & -1\\
% 1 & 3 & \frac{1}{2}\\
% -1 & \frac{1}{2} & 5
% \end{array}\right\rbrack, f=\left\lbrack \begin{array}{c}
% 4\\
% -7\\
% 12
% \end{array}\right\rbrack.
% Enter the problem coefficients.

H = [2 1 -1
    1 3 1/2
    -1 1/2 5];
f = [4;-7;12];
lb = zeros(3,1);
ub = ones(3,1);

% Set the options to display iterative progress of the solver.

options = optimoptions('quadprog','Display','iter');

% Call quadprog with four outputs.

[x fval,exitflag,output] = quadprog(H,f,[],[],[],[],lb,ub,[],options)

% Copyright 2018 The MathWorks, Inc.