Solving a problem
Simply call solve() to solve an optimization problem that was either built or read from a file. The type of solver is determined based on the type of problem: if at least one integer variable was declared, then the problem will be solved as a mixed integer (linear, quadratically constrained, or nonlinear) problem, while if all variables are continuous the problem is solved as a continuous optimization problem. If the problem is nonlinear in that it contains non-quadratic, non-conic nonlinear constraints, then the appropriate nonlinear solver of the Xpress Optimization suite will be called. Note that in case of a nonconvex quadratic problem, the Xpress Nonlinear solver will be applied as the Xpress Optimizer solver cannot handle such problems.
m.solve ()
The status of a problem after solution can be inquired via the functions getProbStatus() and getProbStatusString() as follows:
import xpress as xp m = xp.problem () m.read ("example3.lp") m.solve () print ("problem status: ", m.getProbStatus ()) print ("problem status, explained: ", m.getProbStatusString ())
The meaning of the returned value is explained in the Optimizer's reference manual. Note that the value and string returned by the above functions reflect the type of problem as input by the user, not the way the problem was last solved. If the user creates a MILP and then solves it as an LP with the flag "l", then both getProbStatus() and getProbStatusString() yield the status of the MILP rather than the LP relaxation. At all effects, the call p.getProbStatus() returns p.attributes.lpstatus if p has continuous variables and p.attributes.mipstatus if p has integer variables.
The output of the solver when reading and solving a problem is the same as with other interfaces of the Xpress Optimizer. The verbosity level is determined by the control outputlog, which is 1 by default. To turn off the solver's output, it should be set to zero (see Chapter Controls and Attributes for how to set a control).