Fixing issue with file names that have spaces, and issue with SCIP not writing 0-valued variables to .sol file.

This commit is contained in:
Ryan J. O'Neil
2015-12-29 08:08:58 -05:00
parent ccf7c9c95c
commit 07a2ea11af

View File

@@ -2573,8 +2573,8 @@ class SCIP_CMD(LpSolver_CMD):
lp.writeLP(tmpLp)
proc = [
'scip', '-c', 'read %s' % tmpLp, '-c', 'optimize',
'-c', 'write solution %s' % tmpSol, '-c', 'quit'
'scip', '-c', 'read "%s"' % tmpLp, '-c', 'optimize',
'-c', 'write solution "%s"' % tmpSol, '-c', 'quit'
]
proc.extend(self.options)
if not self.msg:
@@ -2588,7 +2588,14 @@ class SCIP_CMD(LpSolver_CMD):
raise PulpSolverError("PuLP: Error while executing "+self.path)
lp.status, values = self.readsol(tmpSol)
lp.assignVarsVals(values)
# Make sure to add back in any 0-valued variables SCIP leaves out.
finalVals = {}
for v in lp.variables():
finalVals[v.name] = values.get(v.name, 0.0)
lp.assignVarsVals(finalVals)
if not self.keepFiles:
for f in (tmpLp, tmpSol):
try: