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
112 stars 26 forks source link

Use of `optimize` method #82

Open bqth29 opened 1 month ago

bqth29 commented 1 month ago

The optimize method is necessary to mutualize code for maximization and minimization. However, it could be made private because its use may be ambiguous.

For instance, the minimize parameter being set to True by default makes the method equivalent to minimize, except if the user explicitly asks for this parameter to be False. Besides, being called minimize, it seems to imply that minimization is the normal optimization sense whereas it is purely abritrary.

Two actions can be taken to tackle this issue:

  1. either make optimize methods/functions private so the user can only use maximize / minimize, making the API more intuitive and less ambiguous
  2. either replace the minimize parameter by a sense or optimization_sense which has no default value (like domain) and which is either an enum of a Literal (min/max)
bqth29 commented 1 month ago

Even if we choose option 1, replacing the minimize parameter might still be a good idea for clarity's sake