fix for problem with LpProblem.deepcopy()

This commit is contained in:
stu
2014-10-02 11:53:00 +13:00
parent 2bbb382f8d
commit 45a01ede08
2 changed files with 1 additions and 3 deletions

View File

@@ -1133,7 +1133,7 @@ class LpProblem(object):
def deepcopy(self):
"""Make a copy of self. Expressions are copied by value"""
lpcopy = LpProblem(name = self.name, sense = self.sense)
if lpcopy.objective is not None:
if self.objective is not None:
lpcopy.objective = self.objective.copy()
lpcopy.constraints = {}
for k,v in self.constraints.items():

View File

@@ -505,7 +505,6 @@ def pulpTest122(solver):
prob += -y+z == 7, "c3"
prob.extend((w >= -1).makeElasticSubProblem(penalty = 1.1))
print("\t Testing elastic constraints (penalty unchanged)")
prob.writeLP('debug.lp')
pulpTestCheck(prob, solver, [LpStatusOptimal],
{x:4, y:-1, z:6, w:-1.0})
@@ -524,7 +523,6 @@ def pulpTest123(solver):
prob += -y+z == 7, "c3"
prob.extend((w >= -1).makeElasticSubProblem(penalty = 0.9))
print("\t Testing elastic constraints (penalty unbounded)")
prob.writeLP('debug.lp')
if solver.__class__ in [COINMP_DLL, GUROBI, CPLEX_CMD, CPLEX_PY, YAPOSIB]:
# COINMP_DLL Does not report unbounded problems, correctly
pulpTestCheck(prob, solver, [LpStatusInfeasible])