Initializing help system before first use

problem.getPoolSlacks

Purpose
Obtains the slack values of one of the solutions collected in the solution pool during optimization with problem.optimize, problem.mipOptimize or problem.nlpOptimize.
Synopsis
slacks = problem.getPoolSlacks(num, *constraints)
Arguments
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.
constraints 
(optional) constraint objects whose slacks will be returned. If none is provided, a list of slacks for all constraints in the problem will be returned.
Return value
slacks 
A list of slack values if *constraints contains more than one constraint object or is not provided, a single slack value otherwise.
Example
import xpress as xp
p = xp.problem()
x = p.addVariables(5, vartype=xp.binary)
knapsack = xp.Sum(x) <= 2
p.addConstraint(knapsack)
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.optimize()
for i in range(p.attributes.poolsize):
    print(i, p.getPoolSolObjVal(i), p.getPoolSlacks(i, knapsack))
Further information

The slacks are always returned in the input space, even if the problem is currently presolved.

The solution pool cannot be accessed from within a callback.


Related topics

© 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.