Robust approximate fitting
Section 6.4.2 Boyd & Vandenberghe "Convex Optimization" Original by Lieven Vandenberghe Adapted for Convex by Joelle Skaf - 10/03/05
Adapted for Convex.jl by Karanveer Mohan and David Zeng - 26/05/14 Original CVX code and plots here: http://web.cvxr.com/cvx/examples/cvxbook/Ch06_approx_fitting/html/fig6_15.html
Consider the least-squares problem: minimize $\|(A + tB)x - b\|_2$ where $t$ is an uncertain parameter in [-1,1] Three approximate solutions are found:
- nominal optimal (that is, letting t=0)
- stochastic robust approximation: minimize $\mathbb{E}\|(A+tB)x - b\|_2$ assuming $u$ is uniformly distributed on [-1,1]. (reduces to minimizing $\mathbb{E} \|(A+tB)x-b\|^2 = \|A*x-b\|^2 + x^TPx$ where $P = \mathbb{E}(t^2) B^TB = (1/3) B^TB$ )
- worst-case robust approximation: minimize $\mathrm{sup}_{-1\leq u\leq 1} \|(A+tB)x - b\|_2$ (reduces to minimizing $\max\{\|(A-B)x - b\|_2, \|(A+B)x - b\|_2\}$ ).
using Convex, LinearAlgebra, SCS
Input Data
m = 20;
n = 10;
A = randn(m, n);
(U, S, V) = svd(A);
S = diagm(exp10.(range(-1, stop = 1, length = n)));
A = U[:, 1:n] * S * V';
B = randn(m, n);
B = B / norm(B);
b = randn(m, 1);
x = Variable(n)
Variable
size: (10, 1)
sign: real
vexity: affine
id: 467…174
Case 1: nominal optimal solution
p = minimize(norm(A * x - b, 2))
solve!(p, SCS.Optimizer; silent_solver = true)
x_nom = evaluate(x)
10-element Vector{Float64}:
4.224395343408124
0.9298575790481313
-0.5618462535563971
-2.6889726203040114
0.7253064476409464
-0.38543421189059385
-0.2402933131796174
-0.6079615752853383
-2.641692301168017
0.19660353660032076
Case 2: stochastic robust approximation
P = 1 / 3 * B' * B;
p = minimize(square(pos(norm(A * x - b))) + quadform(x, Symmetric(P)))
solve!(p, SCS.Optimizer; silent_solver = true)
x_stoch = evaluate(x)
10-element Vector{Float64}:
2.829948856960337
0.32815964628979744
0.2471962891725972
-0.9401300661939861
2.023538572215875
0.9674482376795664
0.08282942429932831
-0.5616345069796489
-1.8392823186928018
0.26738986935901543
Case 3: worst-case robust approximation
p = minimize(max(norm((A - B) * x - b), norm((A + B) * x - b)))
solve!(p, SCS.Optimizer; silent_solver = true)
x_wc = evaluate(x)
10-element Vector{Float64}:
1.2728870404908568
-0.39301404320528305
0.9550155438005913
0.3240588517830519
2.2781170184883495
1.607312252090284
0.2590859253309028
0.03338750443394335
-2.0106794144245352
0.16891505989040606
Plot residuals:
parvals = range(-2, stop = 2, length = 100);
errvals(x) = [norm((A + parvals[k] * B) * x - b) for k in eachindex(parvals)]
errvals_ls = errvals(x_nom)
errvals_stoch = errvals(x_stoch)
errvals_wc = errvals(x_wc)
using Plots
plot(parvals, errvals_ls, label = "Nominal problem")
plot!(parvals, errvals_stoch, label = "Stochastic Robust Approximation")
plot!(parvals, errvals_wc, label = "Worst-Case Robust Approximation")
plot!(
title = "Residual r(u) vs a parameter u for three approximate solutions",
xlabel = "u",
ylabel = "r(u) = ||A(u)x-b||_2",
)
This page was generated using Literate.jl.