set diagonal elements of cvxpy.variable(10,10) to zero.

382 views
Skip to first unread message

nikhil m

unread,
Dec 21, 2013, 11:16:55 AM12/21/13
to cvx...@googlegroups.com
I am working with the cvxpy module and would like to include a constraint in my objective function where in the diagonal elements of my cvxpy.Variable(10,10) is set to zero. I would like to know how this can be achieved in cvxpy module. 

caglar

unread,
Jan 9, 2014, 10:07:56 PM1/9/14
to cvx...@googlegroups.com
You can use something like this constr_eq=cvx.equals(cvx.diag(v_Cov),0.0)

For completeness, here is a simple max entropy example which is useless without additional constraints.

import cvxpy as cvx

kD=10
v_Cov=cvx.variable(kD,kD,structure='symmetric')

constr_eq=cvx.equals(cvx.diag(v_Cov),0.0)
constr_sdp=cvx.belongs(v_Cov,cvx.semidefinite_cone)
obj=kD*cvx.log(cvx.det_rootn(v_Cov))

params_all=[]
constrs_all=[constr_eq]
constrs_all+=[constr_sdp]

prog=cvx.program(cvx.maximize(obj),constrs_all,params_all)

prog.solve() 
Reply all
Reply to author
Forward
0 new messages