Skip to content

Commit

Permalink
Fixing some issues with running examples directly
Browse files Browse the repository at this point in the history
  • Loading branch information
tkralphs committed May 5, 2019
1 parent ad81e5a commit 0b1bf57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import setuptools

setup(name='coinor.cuppy',
version='0.9.1',
version='0.9.2',
description='Cutting Plane Methods in Python (CuPPy)',
long_description='''A collection of 'naive' implementations of basic
cutting plane algorithms in Python. The collection contains a generator
Expand Down
24 changes: 14 additions & 10 deletions src/cuppy/milpInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ def __init__(self, module_name = None, file_name = None,
lp += x <= lp.variablesUpper
lp += x >= lp.variablesLower
lp.objective = lp.objective
self.A = None
self.b = None
self.c = None
self.sense = '<='
numVars = lp.nCols
else:
Expand All @@ -65,13 +62,23 @@ def __init__(self, module_name = None, file_name = None,
self.c = mip.c if hasattr(mip, 'c') else None
self.sense = mip.sense[1] if hasattr(mip, 'sense') else None
self.integerIndices = mip.integerIndices if hasattr(mip, 'integerIndices') else None
x_u = CyLPArray(mip.x_u) if hasattr(mip, 'x_u') else None
numVars = mip.numVars if hasattr(mip, 'numVars') else None
self.x_sep = mip.x_sep if hasattr(mip, 'x_sep') else None
if numVars is None and mip.A is not None:
numVars = len(mip.A)

if numVars is None:
raise "Must specify number of variables when problem is not"
if numVars is None:
raise "Must specify number of variables when problem is not"
else:
self.A = A
self.b = b
self.c = c
self.points = points
self.rays = rays
self.sense = sense
self.integerIndices = integerIndices
x_u = None

lp = CyClpSimplex()
if self.A is not None:
Expand All @@ -90,15 +97,12 @@ def __init__(self, module_name = None, file_name = None,
x = lp.addVariable('x', numVars)

lp += x >= x_l
try:
x_u = CyLPArray(getattr(mip, 'x_u'))
if x_u is not None:
lp += x <= x_u
except:
x_u = None
lp += (A * x <= b if self.sense == '<=' else
A * x >= b)
c = CyLPArray(self.c)
if self.sense is not None and mip.sense[0] == 'Max':
if self.sense is not None and self.sense[0] == 'Max':
lp.objective = -c * x
else:
lp.objective = c * x
Expand Down

0 comments on commit 0b1bf57

Please sign in to comment.