Usage of `SecondOrderCone`: Supply value of t
DanielDoehring opened this issue · 1 comments
I have a constraint of the form
$$ \Vert A \boldsymbol x + \boldsymbol b \Vert_2 \leq 1 $$ which seems to be a perfect fit for the COSMO.Constraint
together with SecondOrderCone
with dim
of the argument of the norm (in my case
Unfortunately, there are no examples how to use theSecondOrderCone
cone without using JuMP
. I would like to avoid JuMP
since it seems unnecessary overhead for my problem and also complicates (if not completely prevents) the use of higher precision types then Float64
.
Hi Daniel,
COSMO's native constraints are of the form
where
The second-order cone is defined as
Therefore, to get your norm constraint into the right form, we define the vector
(0, hat_A ) x + (1, hat_b) =
Example
To solve the problem
where A = [sqrt(2)/4, 0; 0, \sqrt(2)/4] and b = [sqrt(2)/4; sqrt(2)/4], I would write the constraints natively like this:
using COSMO, SparseArrays, LinearAlgebra, Test
q = [-1; -1.];
P = spzeros(2, 2);
A = [sqrt(2)/4 0; 0 sqrt(2)/4];
b = [√2/4; √2/4]
# We model the norm constraint using `COSMO.SecondOrderCone` as the convex set:
Aa = [0. 0; A]
ba = [1; b]
constraint1 = COSMO.Constraint(Aa, ba, COSMO.SecondOrderCone(3));
# Next, we define the settings object, the model and then assemble everything:
settings = COSMO.Settings(verbose=true);
model = COSMO.Model();
assemble!(model, P, q, constraint1, settings = settings);
res = COSMO.optimize!(model);
The solution should be