Reading and writing a problem
After creating an empty problem, one can read a problem from a file via the read method, which only takes the file name as its argument. An already-built problem can be written to a file with the write method. Its arguments are similar to those in the Xpress Optimizer API function XPRSwriteprob, to which we refer.
import xpress as xp
m = xp.problem()
m.read("example2.lp")
m.solve()
print(m.getSolution())
m2 = xp.problem()
v1 = xp.var()
v2 = xp.var(vartype=xp.integer)
m2.addVariable(v1, v2)
m2.addConstraint(v1 + v2 <= 4)
m2.setObjective(v1**2 + v2)
m2.write("twovarsproblem", "lp")
