Creating a problem
Create an empty optimization problem myproblem as follows:
myproblem = xp.problem()
A name can be assigned to a problem upon creation:
myproblem = xp.problem(name="My first problem")
The problem has no variables or constraint at this point. The synopsis of the xpress.problem method is as follows:
xpress.problem(*args, name='noname', sense=xpress.minimize)
The only two named arguments are name and sense and they denote the problem name and the optimization sense, respectively. The argument args is a list composed as follows:
- zero or more variables declared with xpress.var or xpress.vars;
- zero or more constraints created from functions of the variables;
- at most one function in the variables;
- at most one string.
Note that indicator constraints (see Section Indicator constraints) cannot be added directly in the problem declaration but need to be added using problem.addIndicator.
The following is an example of the compact declaration: variables x and y are declared first, then the problem declaration is passed these variables and followed by two constraints and a function to be used as objective function. Note that because no optimization sense is given, minimization is assumed.
import xpress as xp x = xp.var() y = xp.var(lb=-1, ub=1) prob = xp.problem(x, y, 2*x + y >= 1, x + 2*y >= 1, x + y, name='myproblem')
All operations for adding/deleting variables, constraint, SOS and others are allowed on problems declared this way; note that setting a new objective function with problem.setObjective resets the optimization sense, and sets it to xpress.minimize if none is given.
© 2001-2019 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.