Linear Programming Examples Using Matlab
Linear Programming Examples Using Matlab
Joane Joseph
Problem 1.
Given the attached black-and-white jpeg image in 1500 × 981 pixels, use Matlab to compress the
image by truncating the singular value decomposition, the matrix representing the color gradient in the
image. Compute the approximation errors for the corresponding compressions.
1
Solution:
2
3
Problem 2.
Given the following data points in R2 :
{(0, 0), (1, 3), (2, 7), (3, −1), (4, 0), (5, 5), (6, 10)}
p(x) = c3 x3 + c2 x2 + c1 x + c0
Find the optimal solution and the optimal value for the problem as a least squares problem. Then
solve the problem using CVX.
4
Solution:
Let
1 0 0 0 0
1 1 1 1 3
c0
1 2 4 8 7
c1
A= 1 3 9 27 ,b = −1 ,c =
c2
1 4 16 64 0
c3
1 5 25 125 5
1 6 36 216 10
Then this problem is equivalent to the least squares problem
7
X
min kAc − bk2 = min (p(xi ) − yi )2 .
c∈R4 c∈R4
i=1
Therefore, the solution to this equation can be written as c = (AT A)−1 AT b, and so plugging in for A and
b, the solution is
c0 0.0000
c1 6.9405
c2 = −3.3571
c3 0.4167
0.0000
6.9405
c=
−3.3571
0.4167
5
Problem 3.
In radiation treatment, radiation is delivered to a patient, with the goal of killing or damaging the
cells in a tumor, while carrying out minimal damage to other tissue. The radiation is delivered in beams,
each of which has a known pattern; the level of each beam can be adjusted. (In most cases multiple
beams are delivered at the same time, in one shot, with the treatment organized as a sequence of ’shots’.)
We let bj denote the level of beam j, for j = 1, . . . , n. These must satisfy 0 ≤ bj ≤ B max , where B max
is the maximum possible beam level. The exposure area is divided into P m voxels, labeled i = 1, . . . , m.
The dose di delivered to voxel i is linear in the beam levels, i.e., di = n nj=1 Aij bj . Here A ∈ Rm×n
+ is
a (known) matrix that characterizes the beam patterns. We now describe a simple radiation treatment
planning problem.
A (known) subset of the voxels, T ⊂ {1, . . . , m}, corresponds to the tumor or target region. We
require that a minimum radiation dose Dtarget be administered to each tumor voxel, i.e., di ≥ Dtarget
for i ∈ T . For all other voxels, we would like to have di ≤ Dother , where Dother is a desired maximum
dose for non-target voxels. This is generally not feasible, so instead we settle for minimizing the penalty
(di − Dother )+ ,
X
E=
i∈T
/
where (·)+ denotes the nonnegative part of its argument (i.e., (z)+ = max{0, z}). We can interpret E as
the total nontarget excess dose.
Solve the problem instance with data generated by the file TreatmentPlanningData.m. Here we
have split the matrix A into Atarget, which contains the rows corresponding to the target voxels, and
Aother, which contains the rows corresponding to other voxels. Plot the dose histogram for the target
voxels, and also for the other voxels.
6
Solution:
(di − Dother )+
X
min f =
b1 ,...,bn
i∈T
/
di ≥ DPtarget (∀i ∈ T )
subject to d = n nj=1 Aij bj
i
0 ≤ bj ≤ B max (∀i ∈ {1, 2, . . . , n})
7
8