I want to solve an optimisation problem using cvxpy
.
Suppose I want to use log_sum_exp
function to build a constraint like this:
m >= log(1 + exp(m+z))
The syntax of cvxpy
allows me to create a vector variable x = [z,m]
of dimension 2
and apply matrix multiplication to create a vector of expressions 0, z+m
:
import cvxpy
x = cvxpy.Variable(2)
coeff = np.array([
[0,0],
[1,1]
])
constraints = [ x[1] >= cvxpy.log_sum_exp(coeff * x)]
When coding like this, I lose some part of the logic because I want different names for different parts of my variable array. Is there some way to use the log_sum_exp
transform more explicitly, like
z = cvxpy.Variable()
m = cvxpy.Variable()
constraints = [ m >= cvxpy.log_sum_exp([0, m+z]) ]
?
I couldn't find any hints in the official docs. Thanks!