Skip to content

Commit

Permalink
Bug fix (#1)
Browse files Browse the repository at this point in the history
Fixed a bug affecting conversion of complex valued cone LPs
  • Loading branch information
martinandersen authored Feb 14, 2017
1 parent 49158a6 commit 2e441d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
author='Martin S. Andersen, Lieven Vandenberghe',
author_email='[email protected], [email protected]',
url='http://cvxopt.github.io/chompack/',
download_url='https://github.com/cvxopt/chompack/archive/v2.3.0.tar.gz',
download_url="https://github.com/cvxopt/chompack/archive/%s.tar.gz"%(versioneer.get_version()),
license = 'GNU GPL version 3',
package_dir = {"chompack": "src/python"},
packages = ["chompack","chompack.pybase"],
Expand Down
20 changes: 13 additions & 7 deletions src/python/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,25 +277,31 @@ def convert_block(G, h, dim, **kwargs):

IV = [] # list of (row, value) tuples
J = []
ncon = 0
for j in range(len(constraints)):
iv = []
if len(constraints[j]) == 2:
ii, jj = constraints[j]
iv.extend([(ii, 1.0), (jj, -1.0)])
iv = sorted([(ii, 1.0), (jj, -1.0)],key=lambda x: x[0])
jl = 2*[ncon]
ncon += 1
elif len(constraints[j]) == 4:
i1,j1,i2,j2 = constraints[j]
iv.extend([(i1, 1.0), (i2, 1.0), (j1, -1.0), (j2, -1.0)])
iv = sorted([(i1, 1.0), (i2, 1.0), (j1, -1.0), (j2, -1.0)],key=lambda x: x[0])
jl = 4*[ncon]
ncon += 1
if tc == 'z':
iv.extend([(i1, complex(0.0,1.0)), (i2, complex(0.0,-1.0)),
(j1, complex(0.0,-1.0)), (j2, complex(0.0,1.0))])
iv.sort(key=lambda x: x[0])
iv.extend(sorted([(i1, complex(0.0,1.0)), (i2, complex(0.0,-1.0)),
(j1, complex(0.0,-1.0)), (j2, complex(0.0,1.0))],key=lambda x: x[0]))
jl.extend(4*[ncon])
ncon += 1
IV.extend(iv)
J.extend(len(iv)*[j])
J.extend(jl)

# build G_converted
if IV: I, V = zip(*IV)
else: I, V = [], []
G_coupling = spmatrix(V, I, J, (N, len(constraints)), tc = tc)
G_coupling = spmatrix(V, I, J, (N, ncon), tc = tc)

# generate indices for reverse mapping (block_to_sparse)
idx = []
Expand Down

0 comments on commit 2e441d6

Please sign in to comment.