I am trying to implement the concrete example of formula (11.20) Boyd & Vandenberghe, page 580.
Therefore, we have computed a point that satisfies many (m − r) of the inequalities, i.e., we have identified a large subset of inequalities that is feasible.
I set five inequalities that is five interior of five ellipses. I made four ellipses at most share with one area as the following picture, the red spots are centers of ellipses ,respectively.
So I guess the optimal point would fall into the blue area.
Clear["Global`*"]
Hf = (RotationMatrix[#2] .
Transpose[#1 // DiagonalMatrix //
Inverse] . (#1 // DiagonalMatrix // Inverse) .
Transpose[RotationMatrix[#2]]) &;
Jf = (-(Hf @@ {#1, #2} . #3) - ((Hf @@ {#1, #2} //
Transpose) . #3)) &;
Cf = ( #3 . (Hf @@ {#1, #2}) . #3 - 1) &;
(* epllise parameters as scaling, rotating and moving from a unit \
circle*)
ellipse1 = {{0.5, 0.2}, Pi/12, {1.5, 1}};
ellipse2 = {{1, 0.5}, Pi/2, {0, 0}};
ellipse3 = {{1.5, 1.0}, Pi/6, {1., -0.2}};
ellipse4 = {{1.5, 1.0}, Pi/3, {1.2, 0.5}};
ellipse5 = {{1.0, 0.6}, Pi/6, {0, 0.5}};
ellipse = {ellipse1, ellipse2, ellipse3, ellipse4, ellipse5};
H = Hf @@@ ellipse;
J = Jf @@@ ellipse;
Const = Cf @@@ ellipse;
exprs = Table[{x, y} . H[[i]] . {x, y} + Transpose[J[[i]]] . {x, y} +
Const[[i]], {i, 1, Length[ellipse]}];
Show[ContourPlot[exprs, {x, -2, 3}, {y, -2, 2}, Axes -> True,
AxesOrigin -> {0,0},
Epilog -> {Red, AbsolutePointSize[5],
Point@(Take[ellipse, All, {3}]~Flatten~1)}]]
Use ConvexOptimization to solve the optimal problem.
dimx = 2 ;(*domain is xy plane *)
dims = Length[
epllise]; (* dimension of slack 's' variable for every inequality *)
\
numIneq =
Length[epllise] +
dims;(*number of inequalities of 'fi' and inequalities for slack \
variables *)
numEq = 0; (*no equality constraint*)
(*fi[s_List,x_List,i_Integer/;(i>0 && i<= \
numIneq/2)]:=x.H[[i]].x+Transpose[J[[i]]].x+Const[[i]]-s[[i]]*)
var[1] = Array[ss, 5];
var[2] = Array[xx, 2];
ConvexOptimization[
Sum[var[1][[i]], {i, 1, 5}], {Table[
var[2] . H[[i]] . var[2] + Transpose[J[[i]]] . var[2] +
Const[[i]] - var[1][[i]] \[VectorLess] 0, {i, 1, 5}],
var[1] \[VectorGreaterEqual] -0.0001}, Flatten[{var[1], var[2]}]]
It is noticeable if set $s\succcurlyeq0$ would allow the point on the boudary of ellipse to be optimal, so I set $s\succcurlyeq -0.0001 $ or anyone negative close to zero.
Then I get the optimal result.
{ss[1] -> 1.39408, ss[2] -> 1.90769, ss[3] -> -0.000100014,
ss[4] -> -0.0000999987, ss[5] -> -0.000099999, xx[1] -> 0.754975,
xx[2] -> 0.792299}
Then I plot the optimal point $xx$
Show[ContourPlot[exprs, {x, -2, 3}, {y, -2, 2}, Axes -> True,
AxesOrigin -> {0,0},
Epilog -> {Red, AbsolutePointSize[5],
Point@( (Take[ellipse, All, {3}]~Flatten~1))}],
Graphics[{PointSize[Large], Blue, Point@{0.754975, 0.792299}}]]
So the problem is obvious - the point is not optimal.
There are two small problems. How to get the value of $xx$? The other is if I use self-defined function $fi$ and put it into ConvexOptimization, it fails to solve.
fi[s_List, x_List, i_Integer] :=
x . H[[i]] . x + Transpose[J[[i]]] . x + Const[[i]] - s[[i]]
var[1] = Array[ss, 5];
var[2] = Array[xx, 2];
ConvexOptimization[
Sum[var[1][[i]], {i, 1, 5}], {Table[
fi[var[1], var[2]] \[VectorLess] 0, {i, 1, 5}],
var[1] \[VectorGreaterEqual] -0.0001}, Flatten[{var[1], var[2]}]]
Report
ConvexOptimization::ctuf: The function fi[{ss1,ss2,ss3,ss[4],ss[5]},{xx1,xx2}] is neither convex or concave so the curvature of the constraint fi[{ss1,ss2,ss3,ss[4],ss[5]},{xx1,xx2}][VectorLess]0 cannot be determined.
Thank you for any and all suggestions.
DirectSearch:-Search(ss[1] + ss[2] + ss[3] + ss[4] + ss[5], {
<=(-1. - ss[2] + xx[1]*(0. + 4.*xx[1]) + xx[2]*(0. + 1.*xx[2]), 0),
<=(-0.41666666666666674 - ss[5] + 0.769800358919501*xx[1] + xx[1]*(1.4444444444444444*xx[1] -
$\endgroup$0.7698003589195009*xx[2]) - 2.333333333333333*xx[2] + xx[2]*(-0.7698003589195012*xx[1] + 2.333333333333333*xx[2]), 0),
<=(-0.2859971773572847 - ss[3] - 1.262891711531604*xx[1] + xx[1]*(0.5833333333333333*xx[1] - 0.24056261216234406*xx[2]) + 0.8255696687691325*xx[2] + (-0.24056261216234406*xx[1] + 0.8611111111111109*xx[2])*xx[2], 0),
<=(0.09715819873851994 - ss[4] - 1.826104054504322*xx[1] + xx[1]*(0.8611111111111109*xx[1] - 0.24056261216234406*xx[2]) - 0.005983064143707528*xx[2] + (-0.24056261216234406*xx[1] + 0.5833333333333333*xx[2])*xx[2], 0),
<=(19.00841657532924 - ss[1] -...
$\endgroup$...xx[1]*(5.406733260263393*xx[1] - 5.249999999999998*xx[2]) - 31.436533479473205*xx[2] + xx[2]*(-5.249999999999998*xx[1] + 23.5932667397366*xx[2]), 0)}, penaltymethod = true, feasibilitytolerance = 0.1);
and obtained an error communication "Error, (in DirectSearch:-Search) cannot find feasible initial point; specify a new one " $\endgroup$