cvxpy:'sum_entries' is not defined


cvxpy:'sum_entries' is not defined



I am trying to resolve a portfolio optimization problem in Python using CVXPY but getting an error sum_entries is not defined. I am using Anaconda 2.7 and Jupyter notebook. I have installed cvxpy, msgpack, argpack and cvxopt using conda pip install. Below is the snippet of the code. Any suggestions?


w=Variable(len(CovMatrix))
risk=quad_form(w,Sigma)
constraints=
constraints.append(w>=0)
constraints.append(sum_entries(w)==1)
prob=Problem(cvx.Minimize(risk),constraints)
prob.solve(solver='CVXOPT',verbose=True)



Here is the error I am getting:


NameError Traceback (most recent call last) <ipython-input-20-7f2f1e65a66e> in <module>() 4 constraints= 5 constraints.append(w>=0) ----> 6 constraints.append(sum_entries(w)==1) 7 8

prob=Problem(cvx.Minimize(risk),constraints) NameError: name





--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-20-7f2f1e65a66e> in <module>() 4 constraints= 5 constraints.append(w>=0) ----> 6 constraints.append(sum_entries(w)==1) 7 8 prob=Problem(cvx.Minimize(risk),constraints) NameError: name 'sum_entries' is not defined
– Sumit Malhotra
Jul 2 at 15:18




1 Answer
1



It should be cvx.sum_entries instead of sum_entries. Similarly, your Problem should be cvx.Problem.


cvx.sum_entries


sum_entries


Problem


cvx.Problem






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

JMeter fails on beanshell imports

Why in node-red my HTTP POST no receive payload from inject?

PHP contact form sending but not receiving emails