bqth29 / simulated-bifurcation-algorithm

Python CPU/GPU implementation of the Simulated Bifurcation (SB) algorithm to solve quadratic optimization problems (QUBO, Ising, TSP, optimal asset allocations for a portfolio, etc.).
MIT License
103 stars 25 forks source link

adapt best_only return when maximizing #28

Closed bqth29 closed 11 months ago

bqth29 commented 11 months ago

πŸ’¬ Pull Request Description

Following #27, an inspection of the code has been pursued. The problem originated from the fact that in best-only mode, the best objective value return was always retrieved from an argmin function, even if a maximization was carried out. This behavior was fixed by replacing the argmin by an argmax when maximizing.

βœ”οΈ Check list

Before you open the pull request, make sure the following requirements are met.

πŸš€ New features

No new feature was added.

🐞 Bug fixes

The highest objective value is returned in best-only mode when maximizing (previously, it was still the lowest value).

The bug mentioned in #27 has been added to the tests pool in the tests/ folder.

πŸ“£ Supplementary information

The bug that this PR fixes explains the curious pie charts from #27 since as the number of agents increased, the probability of finding a bad value increased as well. As the worst value was returned instead of the best one, the bad values were over represented in the algorithm's outputs. Hence the drop in performance when the number of agents was more important.

codecov[bot] commented 11 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Files Coverage Ξ”
...rcation/polynomial/base_multivariate_polynomial.py 100.00% <100.00%> (ΓΈ)
tests/models/test_qubo.py 100.00% <100.00%> (ΓΈ)

:loudspeaker: Thoughts on this report? Let us know!.