xpress.problem
p = xpress.problem(*elements=None, name='', sense=xpress.minimize)
elements
|
Variables, constraints, SOSs, or objective function of the problem. These can be specified as single objects or lists and arrays thereof. They can be listed in the same order as would be added to the problem through
problem.addVariable,
problem.addConstraint,
problem.addSOS,
problem.setObjective, i.e. by making sure that the variables appearing in a constraint or objective function appear beforehand in the list.
|
name
|
Name of the problem, displayed on solve log or saved in the
.lp or
.mps file when saved with
problem.write.
|
sense
|
Optimization sense. Can be
xpress.minimize (default) or
xpress.maximize.
|
myproblem = xp.problem()
myproblem = xp.problem(name='My first problem')
m.optimize()
import xpress as xp m = xp.problem() m.read("example3.lp") solvestatus, solstatus = m.optimize() print("solve status:", solvestatus) print("solution status:", solstatus) print("solution:", m.getSolution())
import xpress as xp m = xp.problem() v1 = m.addVariable() x = [m.addVariable(lb=-1, ub=1, vartype=xp.integer) for i in range(10)] [...] # add constraints and objective m.optimize() print(m.getSolution ()) # prints a list with an optimal solution print("v1 is", m.getSolution(v1)) # only prints the value of v1 a = m.getSolution(x) # gets the values of all variables in the vector x b = m.getSolution(0:4) # gets the value of v1 and x[0], x[1], x[2]
© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.