Describe the bug
The cost returned by the run report of OptimizationSolver doesn't match the cost computed on manually for QUBO.
To reproduce current behavior
Steps to reproduce the behavior:
Run this code with Loihi backend
from lava.lib.optimization.problems.problems import QUBO
from lava.lib.optimization.solvers.generic.solver import OptimizationSolver
import numpy as np
**Expected behavior**
The values printed in the last three lines should be identical.
**Environment (please complete the following information):**
- Device: Intel cloud
- OS: Linux
- Lava version: 0.6.1
##Tasks
- [x] [AP, 1ih] Replicate bug
- [x] [AP, 1ih] Rule-out cause at high level API (OptimizationSolver)
- [x] [GG, 4ih] Rule-out cause at low level layers (as deep as needed)
- [ ] [GG, 2ih] Solve bug and add test to catch future errors
- [ ] [AP/GG, 3ih]Prepare for release
This is due to the fact that for mixed Dense matrices, only even numbers are allowed. To fix this, we need an input validation stage, maybe including an automatic scaling of the QUBO matrix.
Describe the bug The cost returned by the run report of OptimizationSolver doesn't match the cost computed on manually for QUBO.
To reproduce current behavior Steps to reproduce the behavior:
Q = np.array([[11, -5, 2, 0, -6], [-5, -13, -1, -3, 10], [2, -1, 0, 2, 10], [0, -3, 2, 2, -1], [-6, 10, 10, -1, -3]])
problem = QUBO(Q) solver = OptimizationSolver(problem)
solution = solver.solve(timeout=50, target_cost=-10000, hyperparameters={ }, backend="Loihi2", )
report = solver.last_run_report
print(report["cost"]) print(report["best_state"] @ Q @ report["best_state"]) print(problem.evaluate_cost(report["best_state"]))