'NotImplementedType' object is not iterable

42 views
Skip to first unread message

Xu Siyuan

unread,
Jun 1, 2021, 4:33:54 PM6/1/21
to cvxpy
How to manipulate expression?

I know here it is totally unnecessary, but I am trying to use this method to a matrix opt problem. 

Here is the code

x = cp.Variable(3)

# Create two constraints.
constraints = [x[0]<=1, x[1]<=1, x[2]<=3] 

term1 = cp.Expression()

for i in range(3):
    term1 += cp.log(x[i])
# Form objective.
obj = cp.Maximize(term1)

It does allow me to generate a term1.

Again, here it is unnecessary, because cp.sum is available. But I am applying this to a higher dimension, or for different i, I have different multipliers or stuff. What should I define term1 as? 

Steven Diamond

unread,
Jun 5, 2021, 3:11:43 PM6/5/21
to cvxpy
You should have "term1 = 0".
Reply all
Reply to author
Forward
0 new messages