=================================== FAILURES ===================================
_______________________ test_incumbent_get_set_solutions _______________________
[gw1] linux -- Python 3.14.6 /opt/conda/envs/test/bin/python3.14
def test_incumbent_get_set_solutions():
> _run_incumbent_solutions(include_set_callback=True)
tests/linear_programming/test_python_API.py:461:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
include_set_callback = True
def _run_incumbent_solutions(include_set_callback):
# Callback for incumbent solution
class CustomGetSolutionCallback(GetSolutionCallback):
def __init__(self, user_data):
super().__init__()
self.n_callbacks = 0
self.solutions = []
self.user_data = user_data
def get_solution(
self, solution, solution_cost, solution_bound, user_data
):
assert user_data is self.user_data
self.n_callbacks += 1
assert len(solution) > 0
assert len(solution_cost) == 1
assert len(solution_bound) == 1
self.solutions.append(
{
"solution": solution.tolist(),
"cost": float(solution_cost[0]),
"bound": float(solution_bound[0]),
}
)
class CustomSetSolutionCallback(SetSolutionCallback):
def __init__(self, get_callback, user_data):
super().__init__()
self.n_callbacks = 0
self.get_callback = get_callback
self.user_data = user_data
def set_solution(
self, solution, solution_cost, solution_bound, user_data
):
assert user_data is self.user_data
self.n_callbacks += 1
assert len(solution_bound) == 1
if self.get_callback.solutions:
solution[:] = self.get_callback.solutions[-1]["solution"]
solution_cost[0] = float(
self.get_callback.solutions[-1]["cost"]
)
prob = Problem()
x = prob.addVariable(vtype=VType.INTEGER)
y = prob.addVariable(vtype=VType.INTEGER)
prob.addConstraint(2 * x + 4 * y >= 230)
prob.addConstraint(3 * x + 2 * y <= 190)
prob.setObjective(5 * x + 3 * y, sense=sense.MAXIMIZE)
user_data = {"source": "test_incumbent_solutions"}
get_callback = CustomGetSolutionCallback(user_data)
set_callback = (
CustomSetSolutionCallback(get_callback, user_data)
if include_set_callback
else None
)
settings = SolverSettings()
settings.set_mip_callback(get_callback, user_data)
if include_set_callback:
settings.set_mip_callback(set_callback, user_data)
settings.set_parameter("time_limit", 1)
prob.solve(settings)
> assert get_callback.n_callbacks > 0
E assert 0 > 0
E + where 0 = <test_python_API._run_incumbent_solutions.<locals>.CustomGetSolutionCallback object at 0xefbc5f1d0350>.n_callbacks
tests/linear_programming/test_python_API.py:444: AssertionError
Describe the bug
While testing cuopt on GB300, I observed the following test failure:
Steps/Code to reproduce bug
Run
conda-python-testson GB300Expected behavior
All tests should pass
Additional context
https://github.com/NVIDIA/cuopt/actions/runs/30637311299/job/91192795962?pr=1565