0

I want to get a solution of one optimization problem, and use it to warm start another problem.

from pyscipopt import Model
model = Model("Example") 
x = model.addVar("x")
y = model.addVar("y", vtype="INTEGER")
model.setObjective(x + y)
model.addCons(2*x - y >= 0)
model.optimize()
model.writeBestSol(filename="origprob.sol", write_zeros=False)

This leads to the following error. Any ideas how to solve this?

OSError: [Errno 9] Bad file descriptor

optimal-br
  • 49
  • 5

1 Answers1

1

This error points to a general issue while writing the file. It's not possible to diagnose this further without additional information. Did you verify that you can write to the current directory? Is the file maybe already open in some other program, blocking the file access?

You should probably open an issue on PySCIPOpt GitHub.

mattmilten
  • 6,242
  • 3
  • 35
  • 65
  • Okay thank you. Also, let's say I solve an optimization problem, and want to use that solution directly for some other problem, is there some other way (other than writing to and then reading from a file) which I can use to warm start the second problem? – optimal-br Mar 12 '22 at 18:06
  • That depends on how those problems are related. Most likely you will need to map the variables from one model to the other and then construct the start solution accordingly. – mattmilten Mar 14 '22 at 23:50