I am new to cvxpy and would be grateful for your help with the following issue. I wrote the following simple optimization code:
import cvxpy as cvx
import numpy as np
m = 4
n = 3
c = np.array([[2, 3, 0], [4, 0, 5], [2, 3, 4], [5, 0, 3]])
s = np.array([[10, 25, 18, 15]])
d = np.array([[15, 20, 16]])
X = cvx.Variable(m, n)
objective = cvx.Minimize(cvx.sum_entries(cvx.mul_elemwise(c, X)))
col_sums = cvx.sum_entries(X, axis=0)
row_sums = cvx.sum_entries(X, axis=1)
constraints = [X >= 0, col_sums <= d,
row_sums.T == s, X[0][2]==0,
X[1][1] == 0, X[3][1] == 0]
prob = cvx.Problem(objective, constraints)
print "Optimal value", prob.solve()
print "Optimal var"
print X.value # A numpy matrix.
Unfortunately, when I run the code, it produces the following error:
runfile('C:/Users/yavigol/Dropbox/Education/GT Optimization/W5/HW5code.py', wdir='C:/Users/yavigol/Dropbox/Education/GT Optimization/W5')
Traceback (most recent call last):
File "<ipython-input-1-0cb639eae2e3>", line 1, in <module>
runfile('C:/Users/yavigol/Dropbox/Education/GT Optimization/W5/HW5code.py', wdir='C:/Users/yavigol/Dropbox/Education/GT Optimization/W5')
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/yavigol/Dropbox/Education/GT Optimization/W5/HW5code.py", line 41, in <module>
col_sums = cvx.sum_entries(X, axis=0)
TypeError: __init__() got an unexpected keyword argument 'axis'
What is wrong with the code and what would be the best way to correct it? Thank you in advance!