problem.getPoolSolution
x = problem.getPoolSolution(num, *variables)
|
num
|
The index of the solution in the pool, from
0 to
problem.attributes.poolsize
-1. Solutions are ordered from best to worst objective value, so index
0 is the solution with the best objective value found. May be passed positionally or as the keyword
num; when passed as a keyword, every positional argument selects a value.
|
|
variables
|
(optional) variable objects, indices or names whose solution values will be returned. If none is provided, a list of solution values for all variables in the problem will be returned.
|
|
x
|
A list of solution values if
*variables contains more than one variable or is not provided, a single solution value otherwise.
|
import xpress as xp
p = xp.problem()
x = p.addVariables(5, vartype=xp.binary)
p.addConstraint(xp.Sum(x) <= 2)
p.setObjective(xp.Sum((5 - i) * x[i] for i in range(5)), sense=xp.ObjSense.MAXIMIZE)
p.controls.poolenumstrategy = xp.PoolEnumStrategy.FULL # enumerate beyond the optimum
p.controls.poollimit = 20 # keep up to 20 solutions
p.optimize()
for i in range(p.attributes.poolsize):
print(i, p.getPoolSolObjVal(i), p.getPoolSolution(i, x))
The solution is always returned in the input space, even if the problem is currently presolved.
Solutions collected in the pool carry no dual information, so there is no pool counterpart of problem.getDuals or problem.getRedCosts.
The solution pool cannot be accessed from within a callback.
For efficiency reasons it is preferable that one call to getPoolSolution is made per pool index, as the whole vector is obtained at each call and only the desired portion is returned.
Unlike problem.getSolution, and in keeping with problem.getCallbackSolution, the returned value is always a flat list (or a single value): nested arguments are flattened, and expressions and dictionaries are not accepted.
© 2001-2026 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.
