modeling a power cone

66 views
Skip to first unread message

Jack1

unread,
Sep 9, 2019, 2:44:09 PM9/9/19
to YALMIP
Given a vector decision variable x and vectors a, b of real scalars, I am trying to model the following quantity to be used inside an optimization objective:
x = sdpvar(5,1); a = rand(5,1); b = rand(5,1);
b
'*(abs(x - a).^(3/2))
and I get the following output:
Nonlinear scalar (real, homogeneous, 5 variables)
Coeffiecient range: 0.09754 to 0.96489

I am wondering if Yalmip would represent the above quantity (i.e., in absolute value raised to (3/2)) as a power cone once Mosek is used as the solver? [mosek documentation: linked]
And if it would be ok for me to proceed with a cvx. optimization? Thank you.



Jack1

unread,
Sep 9, 2019, 4:18:45 PM9/9/19
to YALMIP
I get the following error when I optimize:

sol = 
  struct with fields:
    solvertime: 0
          info: 'Solver not applicable (mosek)'
       problem: -4
    yalmiptime: 8.418

 maybe I can express the objective I have in another format? thank you. 

Jack1

unread,
Sep 9, 2019, 4:35:15 PM9/9/19
to YALMIP
Not sure if cpower might come in handy here? But, do I need to do a cpower for each variable difference (with a) and product (with b) and then sum all of these together? 

Johan Löfberg

unread,
Sep 10, 2019, 1:47:23 AM9/10/19
to YALMIP
power via ^ or .^ leads to general nonlinear program (except for quadratics). To get conic programming modelling, you have to use cpower. The case you show complies with convexity propagation rules and will thus work

YALMIP does not support power cone in mosek. Instead, cpower is implemented using an socp model for rational powers


Message has been deleted

Jack1

unread,
Sep 10, 2019, 7:24:26 AM9/10/19
to YALMIP
Thank you for your reply. So, should I just use cpower on my expression separated by my rational power of 3/2? But, how do I go about tossing this into an optimization objective and solving the problem with additional linear, quadratic objective terms and constraints using the mosek solver? If possible, I would appreciate a small working example for my expression above?

Jack1

unread,
Sep 10, 2019, 7:28:03 AM9/10/19
to YALMIP
Something like
cpower(b'*abs(x - a), 3/2)
? But, not sure if this does the operation element by element which is what I am after. Thanks again.

Johan Löfberg

unread,
Sep 10, 2019, 7:29:30 AM9/10/19
to yal...@googlegroups.com
you simply use cpower and abs as you've written it and yalmip will automatically convert the model to an socp, and call mosek if that is the solver you are using

optimize(x^2 <= 1,cpower(abs(x-4),3/2) + abs(x))

Johan Löfberg

unread,
Sep 10, 2019, 7:34:23 AM9/10/19
to YALMIP
cpower acts elementwise

Jack1

unread,
Oct 20, 2019, 2:30:41 PM10/20/19
to YALMIP
Also, is there any reason as to why yalmip's cpower takes much longer to convert the model to socp than cvx's power_pos(x,p) fcn [http://cvxr.com/cvx/doc/funcref.html]? I need this conversion many times and so would have helped me immensely if cpower was faster. Thank you. 

Johan Löfberg

unread,
Oct 20, 2019, 2:42:17 PM10/20/19
to YALMIP
you would have to supply an example to see where the bottle-neck is for your specific case

Jack1

unread,
Oct 20, 2019, 3:07:38 PM10/20/19
to YALMIP
Here is a simple example for yalmip and cvx:

tic
x
= sdpvar(3000,1);
optimize
(norm(x,2) <= 1,ones(1,3000)*cpower(abs(x-4),3/2))
toc


tic
cvx_begin
    variable y
(3000);
    minimize
( ones(1,3000)*pow_pos(abs(y-4),3/2) );    
    subject to
        norm
(y,2) <= 1;
cvx_end
toc

The first one takes quite some time. Is it because my decision variable is very large? Thank you. 

Johan Löfberg

unread,
Oct 21, 2019, 1:55:27 AM10/21/19
to YALMIP
yes that is nasty. I have no quick fix, will have to dig deep into that one

Jack1

unread,
Oct 22, 2019, 2:32:23 PM10/22/19
to YALMIP
Would you be able to suggest some ways that I can try to minimize element-wise deviation? 
For instance, given decision variable and a known vector b, I would like to minimize the element-wise deviation between them --> so, I tried adding 
sum(x-b) == 0
as a constraint. The solution was infeasible so I tried to relax the lower+upper bounds, but, the same issue persisted. 
Any advice on this would be much appreciated.

Johan Löfberg

unread,
Oct 22, 2019, 2:35:48 PM10/22/19
to YALMIP
norm(x-b,p)<=tolerance for standard norms such as 2, inf, 1 would be the vanilla way

Jack1

unread,
Oct 22, 2019, 4:02:32 PM10/22/19
to YALMIP
Thank you for getting back! Ideally, I would like my optimized variable x to respect the same sign and relative magnitudes (element-wise) of the quantity b that I am optimizing. Any advice on how I could do so would be greatly appreciated, thank you

Johan Löfberg

unread,
Oct 22, 2019, 4:10:28 PM10/22/19
to YALMIP
same sign simply means you want to add x(find(b>0))>=0 and x(find(b<0))<=0, and the relative size probably means you want to use weights when you measure the deviation using the norm

Jack1

unread,
Oct 22, 2019, 5:59:22 PM10/22/19
to YALMIP
Thank you -- tried using the find fcn. but running into infeasbility issues. Any other suggestion would be very appreciative

Johan Löfberg

unread,
Oct 23, 2019, 1:30:25 AM10/23/19
to YALMIP
well then you have to add slacks or any hack you find reasonable
Reply all
Reply to author
Forward
0 new messages