Consider the a general constrained optimization problem:
|
(237) |
By introducing slack variables
, all inequality
constraints can be converted into equality constraints:
|
(238) |
which can then be combined with the equality constraints and still
denoted by
, while the slack variables
are also combined with the original variables and still
denoted by . We assume there are in total equality
constraints and variables. Now the optimization problem can be
reformulated as:
|
(239) |
The Lagrangian is
|
(240) |
The KKT conditions are
|
(241) |
where
,
,
and
is the Jacobian matrix of
:
|
(242) |
To simplify the problem, the non-negativity constraints can be removed
by introducing an indicator function:
|
(243) |
which, when used as a cost function, penalizes any violation of the
non-negativity constraint . Now the optimization problem can
be reformulated as shown below without the non-negative constants
:
|
(244) |
However, as the indicator function is not smooth and therefore not
differentiable, it is approximated by the logarithmic barrier function
which approaches when the parameter approaches infinity:
|
(245) |
Now the optimization problem can be written as:
|
(246) |
The Lagrangian is:
|
(247) |
and its gradient is:
|
(248) |
We define
i.e. |
(249) |
and combine this equation with the KKT conditions of the new
optimization problem to get
|
(250) |
The third condition is actually from the definition of
given above, but here it is labeled as complementarity, so that
these conditions can be compared with the KKT conditions of the
original problem. We see that the two sets of KKT conditions are
similar to each other, with the following differences:
- The non-negativity
in the primal feasibility
of the original KKT is dropped;
- Consequently the inequality
in the dual
feasibility of the original KKT conditions is also dropped;
- There is an extra term in complementarity which
will vanish when
.
The optimal solution that minimizes the objective function
can be found by solving the simultaneous equations in the modified
KKT conditions (with no inequalities) given above. To do so, we first
express the equations in the KKT conditions above as a nonlinear
equation system
, and
find its Jacobian matrix
composed of the partial
derivatives of the function
with respect to each of the three variables ,
,
and :
|
(251) |
where
is symmetric as the Hessian matrices and
are symmetric.
We can now use the
Newton-Raphson method
to find the solution of the nonlinear equation
iteratively:
|
(253) |
where is a parameter that controls the step size and
is the
search direction (Newton direction), which can be found by
solving the following equation:
To get the initial values for the iteration, we first find any point
inside the feasible region and then
,
based on which we further find
by solving the first
equation in the KKT conditions in Eq. (250).
Actually this equation system above can be separated into two
subsystems, which are easier to solve. Pre-multiplying
to the third equation:
|
(255) |
we get
|
(256) |
Adding this to the first equation:
|
(257) |
we get
|
(258) |
Combining this equation with the second one, we get an equation system
of two vector variables
and
with
symmetric coefficient matrix:
|
(259) |
Solving this equation system we get
and
,
and we can further find
by solving the third equation
|
(260) |
to get
|
(261) |
We now consider the two special cases of linear and quadratic
programming:
- Linear programming:
|
(262) |
We have
The Lagrangian is
|
(263) |
The KKT conditions are:
The search direction of the iteration can be found by solving the
this equation system:
|
(264) |
By solving the equation
we get the initial value
. The Matlab code for the interior
point method for the LP problem is listed below:
function x=InterierPointLP(A,c,b,x)
% given A,b,c of the LP problem and inital value of x,
% find optimal solution x that minimizes c'*x
[m n]=size(A); % m constraints, n variables
z1=zeros(n);
z2=zeros(m); % zero matrices in coefficient matrix
z3=zeros(m,n);
I=eye(n); % identity matrix in coefficient matrix
y=ones(n,1);
t=9; % initinal value for parameter t
alpha=0.3; % small enough not to exceed boundary
mu=x./t;
lambda=pinv(A')*(mu-c); % initial value of lambda
w=[x; lambda; mu]; % initial values for all three
B=[c+A'*lambda-mu; A*x-b; x.*mu-y/t];
p=[x(1) x(2)]; % initial guess of solution
while norm(B)>10^(-7)
t=t*9; % increase parameter t
X=diag(x);
M=diag(mu);
C=[z1 A' -I; A z2 z3; M z3' X];
B=[c+A'*lambda-mu; A*x-b; x.*mu-y/t];
dw=-inv(C)*B; % find search direction
w=w+alpha*dw; % step forward
x=w(1:n);
lambda=w(n+1:n+m);
mu=w(n+m+1:length(w));
p=[p; x(1), x(2)];
end
scatter(p(:,1),p(:,2)); % plot trajectory of solution
end
Example:
A given linear programming problem shown below is first
converted into the standard form:
or in matrix form:
with
where
are the slack variables.
We choose an initial value
, and
an initial parameter , which is scaled up by a factor of
in each iteration. We also used full Newton step size of .
After 8 iterations, the algorithm converged to the optimal solution
corresponding to the maximum function value
:
At the end of the iteration, we also get the values of the slack
variables:
.
- Quadratic programming:
|
(265) |
We have
The Lagrangian is
|
(266) |
The KKT conditions are:
The equation system for the Newton-Raphson method is:
|
(267) |
The Matlab code for the interior point method for the QP problem is
listed below:
function [x mu lambda]=InteriorPointQP(Q,A,c,b,x)
n=length(c); % n variables
m=length(b); % m constraints
z2=zeros(m);
z3=zeros(m,n);
I=eye(n);
y=ones(n,1);
t=9; % initinal value for parameter t
alpha=0.1; % stepsize, small enough not to exceed boundary
mu=x./t;
lambda=pinv(A')*(mu-c-Q*x); % initial value of lambda
w=[x; lambda; mu]; % initial value
B=[Q*x+c+A'*lambda-mu; A*x-b; x.*mu-y/t];
while norm(B)>10^(-7)
t=t*9; % increase parameter t
X=diag(x);
M=diag(mu);
C=[Q A' -I; A z2 z3; M z3' X];
B=[Q*x+c+A'*lambda-mu; A*x-b; x.*mu-y/t];
dw=-inv(C)*B; % find search direction
w=w+alpha*dw; % step forward
x=w(1:n);
lambda=w(n+1:n+m);
mu=w(n+m+1:length(w));
end
end
Example:
A 2-D quadratic programming problem shown below is to minimize
four different quadratic functions under the same linear
constraints as the liniear programming problem in the previous
example. In general, the quadratic function is given in the
matrix form:
with following four different sets of function parameters:
As shown in the four panels in the figure below, the iteration of
the interior point algorithm brings the solution from the same
initial position at
to the final position
for each of the four objective functions
, the optimal
solution, which is on the boundary of the feasible region in all
cases except the third one, where the optimal solution is inside
the feasible region, i.e., the optimization problem is not constrained.
Also note that the trajectories of the solution during the iteration
go straightly from the initial guess to the final optimal solution
by following the negative gradient direction of the quadratic function
in all cases execpt in the last one, where it makes a turn while
approaching the vertical boundary, due obviously to the significantly
greater value of the log barrier function close to the boundary.