Quadratic and Integer Programming
Kathrin Gruber, Maria Crepaz
. Mai
QUADRATIC PROGRAMMING
1 Quadratic Programming
1.1 The Quadratic Programming Problem
Standard form:
min xT Qx + c T x
x
Ax
=
b
x
≥
()
A ∈ Rm×n , b, c ∈ Rm , Q ∈ Rn×n is positive semidefinite y T Qy ≥ , x ∈ Rn
e.g. OLS are QP without constraints, Markovitz mean-variance optimization problem
The dual problem:
max b T y − xT Qx
x,y,s
AT y − Qx + s
x, s
()
=
c
≥
. Interior Point Methods (IPM)
QUADRATIC PROGRAMMING
Optimality conditions: Karush-Kuhn-Tucker Theorem (KKT conditions)
⇒ List of conditions which are necessarily satisfied at any local optimal solution
• primal feasibility: Ax = b, x ≥
• dual feasibility: AT y = Qx + s = c, s ≥
• complementary slackness: xi , si = (∀i = , . . . , n)
In matrix notation
T
A y − Qx + s − c
Ax − b
F(x, y, s) =
= ,
XSe
(x, s) ≥
1.2 Interior Point Methods (IPM)
• To solve LPs in and QPs in polynomial time
• based on Newthon’s method but modified to handle inequality constraints
• Path-following algorithms, centered Newthon-direction, neighborhoods of the central path
QP MODELS: PORTFOLIO OPTIMIZATION
2 QP Models: Portfolio Optimization
2.1 Mean-Variance Optimization
Markowitz’ theory of mean-variance optimization (MVO) is about the selection of portfolios of
securities (or asset classes) in a manner that trades off the expected returns and the perceived
risk of potential portfolios. Mathematically the formulation produces a quadratic programming
problem:
min xT Qx
x
µT x
Ax
≥
=
R
b
Cx
≥
d
()
Where
• x is the proportion of the total funds invested in security i.
• Q = (σij ) is the n × n symmetric covariance matrix.
• µ and σ are the expected return and the standard deviation of the return.
. Efficient Portfolio
QP MODELS: PORTFOLIO OPTIMIZATION
• A is an m × n matrix e.g. the weights of the portfolio that should equal b = .
• C is a p × n matrix e.g. all the assets of the portfolio.
• d is a p-dimensional vector, if p = short sales are not allowed.
2.2 Efficient Portfolio
Definition: Recall that a feasible portfolio x is called effcient if it has the maximal expected return among all portfolios with the same variance, or alternatively, if it has the minimum variance
among all portfolios that have at least a certain expected return. The collection of effcient portfolios form the effcient frontier of the portfolio universe. The effcient frontier is often represented
as a curve in a two-dimensional graph where the coordinates of a plotted point corresponds to
the expected return and the standard deviation on the return of an effcient portfolio. Since we assume that Q is positive defnite, the variance is a strictly convex function of the portfolio variables
and there exists a unique portfolio that has the minimum variance.
. Markovitz Example
QP MODELS: PORTFOLIO OPTIMIZATION
2.3 Markovitz Example
We apply Markowitz’s MVO model to the problem of constructing a portfolio of US stocks, bonds
and cash. We use historical data for the returns of these three asset classes: The S& P index for
the returns on stocks, the -year Treasury bond index for the returns on bonds, and we assume
that the cash is invested in a money market account whose return is the -day federal fund rate.
The times series for the Total Return are given for each asset between and .
Let Ri denote the random rate of return of asset i. From the above historical data, we can
compute the arithmetic mean rate of return for each asset:
ri =
T
X
r
T t= it
Or the geometric mean instead of the arithmetic mean:
T
Y
µi = ( ( + rit )) T −
t=
Now we set up the quadratic programm for portfolio optimization
. Markovitz Example
QP MODELS: PORTFOLIO OPTIMIZATION
min .xS + × .xS xB + × .xS xM
+.xB − × −.xM
()
.xS + .xB + .xM
xS + xB + xM
≥ R
=
xS , xB , X M
≥
and solving it for R = . to R = . % with increments of . % we get the optimal portfolios
and can depict the optimal allocations on the effcient frontier.
. MVO Examples
QP MODELS: PORTFOLIO OPTIMIZATION
2.4 MVO Examples
Exercise
Solve Markovitz’s MVO model for constructing a portfolio of US stocks, bonds and cash using
arithmetic means, instead of geometric means as above. Vary R from . % to % with increments of . % . Compare with the results obtained above.
Exercise
In addition to the three securities given earlier (S & P Index, -year Treasury Bond Index and
Money Market), consider a th security (the NASDAQ Composite Index). Construct a portfolio
consisting of the S & P index, the NASDAQ index, the -year Treasury bond index and cash,
using Markowitz’s MVO model. Solve the model for different values of R.
. Issues with Markovitz model
QP MODELS: PORTFOLIO OPTIMIZATION
2.5 Issues with Markovitz model
Diversification: model tends to produce portfolios with unreasonably large weights
Solutions:
• Additional constraints to ensure diversification (limits)
• Group securites to sectors and limit exposure to sector.
Transaction Costs: model does not account for transaction costs when reallocating
Solutions:
• Introduce a turnover constraint → the amount bought and sold is restricted.
• Include transaction costs (if known) directly in the model. E.g. proportional to the amount
bought or sold.
Parameter Estimation: assumption of perfect information (on µi and σij → small changes lead
to large changes in ”optimal” solution
Solutions:
• Sample the mean returns µi and the covariance coffcients σij from a confdence interval
around each parameter and then combine the portfolios obtained
. Issues with Markovitz model
QP MODELS: PORTFOLIO OPTIMIZATION
• Generate a random value uniformly in an interval around the µi for each stock i repetetively
and average portfolios obtained.
Exercise
Using historical returns of the stocks in the DJIA, estimate their mean µi and covariance matrix.
Let R be the median of the µi s.
• (i) Solve Markowitz’s MVO model to construct a portfolio of stocks from the DJIA that has
expected return at least R.
• (ii) Generate a random value uniformly in the interval [.µi ; .µi ], for each stock i.
Resolve Markowitz’s MVO model with these mean returns, instead of µs as in (i). Compare the
results obtained in (i) and (ii). (iii) Repeat three more times and average the five portfolios found
in (i), (ii) and (iii). Compare this portfolio with the one found in (i).
. Black-Litterman Model
QP MODELS: PORTFOLIO OPTIMIZATION
2.6 Black-Litterman Model
Black and Litterman recommend to combine the investor’s view with the market equilibrium.
The expected return vector µ is assumed to have a probability distribution that is the product
of two multivariate normal distributions. The frst distribution represents the returns at market
equilibrium, the second distribution represents the investor’s view about the µi ’s.
The resulting distribution for µ is a multivariate normal distribution with mean
µ̄ = [(τQ)− + P T Ω − P]− [(τQ)− π + P T Ω − q]
Black and Litterman use µ̄ as the vector of expected returns in the Markowitz model.
. Black-Litterman Example
QP MODELS: PORTFOLIO OPTIMIZATION
2.7 Black-Litterman Example
We use the expected returns on Stocks, Bonds and Money Market of the earlier examples for the
vector π representing the market equilibrium. We need to choose the value of the small constant
τ. We take τ = .. We have two views that we would like to incorporate into the model. First, we
hold a strong view that the Money Market rate will be % next year. Second, we also hold the
view that S& P will outperform -year Treasury Bonds by % but we are not as confident
about this view. These two views are expressed as follows
µM
µM
Then P =
−
!
,q =
= . strong view: ω = .
= . weaker view: ω = .
!
!
.
.
andΩ =
.
.
Solve it for R = . % to R = . % with increments of . %.
. Mean-Absolute Deviation PO
QP MODELS: PORTFOLIO OPTIMIZATION
2.8 Mean-Absolute Deviation PO
Konno and Yamazaki propose a linear programming model instead of the classical quadratic model. Their approach is based on the observation that different measures of risk, such a volatility
and L-risk, are closely related, and that alternate measures of risk are also appropriate for portfolio optimization. This theorem implies that minimizing σ is equivalent to minimizing ω when
(R , . . . , Rn ) is multivariate normally distributed. With this assumption, the Markowitz model can
be formulated as
n
X
(Ri − µi )xi |]
min E[|
()
i=
subj. to
n
X
µ i xi
≥ R
i=
n
X
xi
=
i=
≤ xi ≤ m i
for i = , . . . , n
. Other Examples for QP Models in Finance QP MODELS: PORTFOLIO OPTIMIZATION
the model can be rewritten as
min
T
X
yt + zt
i=
Pn
subj.
Pn to yt − zt = i= (rit − µi )xi
µ i xi ≥ R
Pi=
n
i= xi =
≤ xi ≤ mi for i = , . . . , n
yt ≥ , zt ≥ for t = , . . . , T
for t = , . . . , T
This is a linear program. Therefore this approach can be used to solve large scale portfolio
optimization problems. (See page )
2.9 Other Examples for QP Models in Finance
Maximizing the Sharpe Ratio:
• When you look for a specific portfolio that lies on the efficient frontier you can define a risk
you are willing to bear. Return/risk profiles of different combinations of a risky portfolio
. Other Examples for QP Models in Finance QP MODELS: PORTFOLIO OPTIMIZATION
with the riskless asset can be represented as a straight line – the capital allocation line
(CAL) – on the mean vs. standard deviation graph. This optimal CAL goes through a point
on the effcient frontier and never goes above a point on the effcient frontier. It is called the
reward-to-volatility ratio introduced by Sharpe.
• The standard strategy to find the portfolio maximizing the Sharpe ratio, often called the
optimal risky portfolio, is the following: First, one traces out the effcient frontier on a two
dimensional return vs. standard deviation graph. Then, the point on this graph corresponding to the optimal risky portfolio is found as the tangency point of the line going through
the point representing the riskless asset and is tangent to the efcient frontier. Once this
point is identifed, one can recover the composition of this portfolio from the information
generated and recorded while constructing the effcient frontier.
Returns-Based Style Analysis:
• Constrained optimization techniques can also be used to determine the effective asset mix
of a fund using only the return time series for the fund and a number of carefully chosen
asset classes. The allocations in the portfolio can be interpreted as the fund’s style and
consequently, this approach has become to known as returns-based style analysis.
• It is used when only the returns of a fund is available but not the detailed holdings. A
. Other Examples for QP Models in Finance QP MODELS: PORTFOLIO OPTIMIZATION
generic linear factor model is used to explain the returns of passive investments with an
error term ǫt that represents the contribution of active management.
• The objective is to determine a benchmark portfolio such that the difference between fund
returns and the benchmark returns is as close to constant (i.e., variance ) as possible.The
fund return and benchmark return graphs should show two almost parallel lines.
• The problem is convex quadratic programming problem and is easily solvable using wellknown optimization techniques such as interior-point methods.
INTEGER PROGRAMMING
3 Integer Programming
These are feasible programs in which some or all variables are restricted to be integers.
3.1 Combinatorial Auctions
Allows the bidder to submit bids on combinations of items
• M = {, , . . . , m} . . . the set of items the auctioneer has to sell
• Bj = (Sj , pj ) . . . a bid, Sj ≤ M is a nonempty set of items, pj is the price offer for the set
Suppose the auctioneer has received
• n . . . the number of bids B , . . . , Bn
if Bj wins
• xj =
otherwise
. Combinatorial Auctions
INTEGER PROGRAMMING
Solving the integer programm
max
n
X
()
p j xj
i=
subj. to
X
xj
≤
for i = , . . . , m
xj
=
or for
j:i∈Sj
constraints impose that each item is sold at most once
R-Example
j = , . . . , n
. Combinatorial Auctions
INTEGER PROGRAMMING
Multiple units of each item to sale:
j
j
j
• Bj = (λ , λ , . . . , λm ; pj )
j
• λi . . . the desired number of units of item i
• pj . . . the price offer
• ui . . . number of units of item i for sale
max
n
X
()
p j xj
i=
subj. to
X
j
λ i xj
≤ ui
for i = , . . . , m
j:i∈Sj
xj
=
or for
j = , . . . , n
. The Lockbox Problem
INTEGER PROGRAMMING
3.2 The Lockbox Problem
Lockbox: Often companies receive a large number of payments via checks in the mail have the
bank set up a post office box for them, open their mail, and deposit any checks found.
From
West
Midwest
East
South
L.A.
Cincinnati
Boston
Houston
Tabelle : The average of days from mailing to clearing
Calculate the losses
From
West
Midwest
East
South
L.A.
Cincinnati
Boston
Houston
Tabelle : The average of days from mailing to clearing
. The Lockbox Problem
INTEGER PROGRAMMING
Formulate the LP
if lockbox j is opened
yj =
otherwise
xij . . . if region i sends to lockbox j
Minimize the total yearly costs (each region must assign to one lockbox)
min x + x + x + . . . + y + y + y + y
X
subj. to
xij
j
or a region can only be assigned to an open lockbox ( constraints)
subj. to (LA)
x + x + x + x
R-Example
≤
y
()
=
∀i
. Constructing an Index Fund
INTEGER PROGRAMMING
3.3 Constructing an Index Fund
3.3.1 A Large Scale Deterministic Model
Model that clusters the assets into groups of similar assets and selects one representative asset
from each group to be included in the index fund portfolio
• ρij . . . similarity between i and j (e.g. correlation between i and j)
if j is selected
• yj =
otherwise
• xij =
if j is the most similar stock in the index fund
otherwise
. Constructing an Index Fund
Z = max
INTEGER PROGRAMMING
n
n X
X
()
ρij xij
i= j=
subj. to
n
X
yj
=
q
xij
=
for
xij
≤
yj
xij , yj
=
or
j=
n
X
i = , . . . , n
j=
for i, j = , . . . , n
for i, j = , . . . , n
If model has been solved and q stocks have been selected for the index fund, weight wj is
calculated for each j in the fund
n
X
Vi xij
()
wj =
i=
• wj . . . total market value of the stocks represented by stock j
• Vi . . . market value of stock i
. Constructing an Index Fund
INTEGER PROGRAMMING
Also possible is an objective function that takes the weights wj directly into account such that
n
n X
X
Vi ρij xij
i= j=
but q stocks still need to be weighted here.
Solution strategy
Branch-and-Bound, very large formulation of the S&P :
variables, constraints xij ≤ yj
⇒ Lagrangian relaxation defined for any vector u = (u , . . . , un )
()
. Constructing an Index Fund
L(u) = max
n
n X
X
i=j j=
ρij xij +
INTEGER PROGRAMMING
n
X
ui ( −
i=
n
X
()
xij
j=
subj. to
n
X
yj
=
q
xij
≤
yj
xij , yj
=
or
j=
for i, j = , . . . , n
for i, j = , . . . , n
Property :
L(u) ≥ Z
where Z is the maximum for the model
()
. Constructing an Index Fund
INTEGER PROGRAMMING
Property :
L(u) = max
n
X
n
X
ui
n
n X
X
yj
=
q
yj
=
or
Cj yj +
j=
subj. to
()
i=
j= j=
where Cj =
Property :
Pn
i= (ρij
for j = , . . . , n
− ui )+ , if ρij − ui >
if
ρij − ui > then
xij = yj
otherwise
xij =
()
In an optimal solution of the Lagrangian relaxation yj is equal to for the largest values of Cj
and the remaining yj are equal to . Can also be used as heuristic solution for the model, yields to
a feasible but not necessarily optimal solution but provides a lower bound on the optimum value
Z.
. A Linear Programming Model
INTEGER PROGRAMMING
3.4 A Linear Programming Model
Assumes that important characteristics of the market index to be tracked have already been identified (e.g. fraction f i of index in each sector i, of companies with market capitalization in various
range - small, medium, large)
if company j has characteristic i
• aij =
otherwise
• xij . . . the optimum weight of asset j in the portfolio (assume that initially the portfolio hast
weights )
• yj . . . fraction of asset j bought
• zj . . . fraction sold
. A Linear Programming Model
min
INTEGER PROGRAMMING
n
X
(yj + zj )
()
j=
subj. to
X
=
fi
xj
=
xj − xj
≤
yj
for j = , . . . , n
xj − xj
≤
zj
for i = , . . . , n
yj , zj , xj
≥
for i = , . . . , n
aij xj
for i = , . . . , m
i=
n
X
j=
R-Example
. A Linear Programming Model
INTEGER PROGRAMMING
The End!
© Copyright 2026 Paperzz