This commit is contained in:
Stuart Mitchell
2012-05-17 21:32:22 +12:00
parent d182a03ad0
commit 2d05105ccf
4 changed files with 28 additions and 9 deletions

View File

@@ -1 +1 @@
1.5.1 1.5.2

View File

@@ -680,7 +680,7 @@ class LpAffineExpression(_DICT_TYPE):
term = " + %s" % self.constant term = " + %s" % self.constant
if self._count_characters(line) + len(term) > LpCplexLPLineSize: if self._count_characters(line) + len(term) > LpCplexLPLineSize:
result += ["".join(line)] result += ["".join(line)]
line = [term] line += [term]
else: else:
line += [term] line += [term]
result += ["".join(line)] result += ["".join(line)]
@@ -859,7 +859,7 @@ class LpConstraint(LpAffineExpression):
c = 0 # Supress sign c = 0 # Supress sign
term = " %s %.12g" % (LpConstraintSenses[self.sense], c) term = " %s %.12g" % (LpConstraintSenses[self.sense], c)
if self._count_characters(line)+len(term) > LpCplexLPLineSize: if self._count_characters(line)+len(term) > LpCplexLPLineSize:
line = "".join(line) result += ["".join(line)]
line = [term] line = [term]
else: else:
line += [term] line += [term]

View File

@@ -1222,9 +1222,9 @@ class COIN_CMD(LpSolver_CMD):
aCopy.strong = self.strong aCopy.strong = self.strong
return aCopy return aCopy
def actualSolve(self, lp): def actualSolve(self, lp, **kwargs):
"""Solve a well formulated lp problem""" """Solve a well formulated lp problem"""
return self.solve_CBC(lp) return self.solve_CBC(lp, **kwargs)
def available(self): def available(self):
"""True if the solver is available""" """True if the solver is available"""

View File

@@ -8,10 +8,11 @@ def pulpTestCheck(prob, solver, okstatus, sol = {},
duals = None, duals = None,
slacks = None, slacks = None,
eps = 10**-3, eps = 10**-3,
status = None): status = None,
**kwargs):
if status is None: if status is None:
status = prob.solve(solver) status = prob.solve(solver, **kwargs)
if status not in okstatus: if status not in okstatus:
prob.writeLP("debug.lp") prob.writeLP("debug.lp")
prob.writeMPS("debug.mps") prob.writeMPS("debug.mps")
@@ -215,6 +216,22 @@ def pulpTest017(solver):
print "\t Testing LpVariable (not LpAffineExpression) objective" print "\t Testing LpVariable (not LpAffineExpression) objective"
pulpTestCheck(prob, solver, [LpStatusOptimal]) pulpTestCheck(prob, solver, [LpStatusOptimal])
def pulpTest018(solver):
# Long name in lp
prob = LpProblem("test013", LpMinimize)
x = LpVariable("x"*90, 0, 4)
y = LpVariable("y"*90, -1, 1)
z = LpVariable("z"*90, 0)
w = LpVariable("w"*90, 0)
prob += x + 4*y + 9*z, "obj"
prob += x+y <= 5, "c1"
prob += x+z >= 10, "c2"
prob += -y+z == 7, "c3"
prob += w >= 0, "c4"
if solver.__class__ in [COIN_CMD]:
print "\t Testing Long lines in LP"
pulpTestCheck(prob, solver, [LpStatusOptimal], {x:4, y:-1, z:6, w:0},
use_mps=False)
def pulpTest020(solver): def pulpTest020(solver):
# MIP # MIP
@@ -520,9 +537,11 @@ def pulpTest123(solver):
def pulpTestSolver(solver, msg = 0): def pulpTestSolver(solver, msg = 0):
tests = [pulpTest001, tests = [
pulpTest010, pulpTest011, pulpTest012, pulpTest013, pulpTest014, pulpTest001,
pulpTest010, pulpTest011, pulpTest012, pulpTest013, pulpTest014,
pulpTest015, pulpTest016, pulpTest017, pulpTest015, pulpTest016, pulpTest017,
pulpTest018,
pulpTest020, pulpTest020,
pulpTest030, pulpTest030,
pulpTest040, pulpTest040,