Closed bqth29 closed 11 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
f0f5653
) 100.00% compared to head (5854566
) 100.00%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Shall we keep Binary, Integer and Spin polynomials but in the models module?
💬 Pull Request Description
This PR allows polynomials to be created from mathematical expressions that can be more natural than matrices for small dimension problems.
The logic behind the creation of polynomial instances was completely redesigned and now relies on a new tool called
PolynomialMap
which is an object that maps a degree of an homogeneous polynomial to the associated coefficients tensor, given that the number of dimensions of the tensor is the same as degree and that all these dimensions are equal.Finally, the domain of optimization is no longer beared by the polynomial instance but only provided when casting the polynomial to an Ising model.
✔️ Check list
Before you open the pull request, make sure the following requirements are met.
🚀 New features
Define a polynomial instance and/or a SB model from a SymPy expression.
🐞 Bug fixes
None
📣 Supplementary information
The
IsingCore
class has been moved to the newly createdcore
module and renamed in thecore.Ising
class.⚠️ Breaking change
This PR introduces a breaking change (first PR for version
1.3.0
). When this is merged, some old features will no longer be available or calling some functions/method will be different. Please be careful if you update your version ofsimulated_bifurcation
and try to run an old code that was written for versions1.2.0
or1.2.1
.Deleted classes
The following classes were deleted and replaced by
QuadraticPolynomial
:BaseMultivariateQuadraticPolynomial
SpinPolynomial
SpinQuadraticPolynomial
BinaryPolynomial
BinaryQuadraticPolynomial
IntegerPolynomial
IntegerQuadraticPolynomial
The enum
OptimizerMode
has been replaced bySimulatedBifurcationEngine
which now bears the activation function and the heated property.New methods signatures
The
optimize
,maximize
orminimize
methods/functions' parameterinput_type
has been renamed indomain
for this name make it clearer what its purpose is.Because the polynomial instances no longer carry their input type, calling the methods
optimize
,maximize
orminimize
on a polynomial instance now requires adomain
parameter.Similarly, building a polynomial instance no longer requires an
input_type
, and the parametersdtype
anddevice
are now keyword-only (because an arbitrary number of tensors can be passed).Finally, all parameters of the
sb.optimize
,sb.maximize
andsb.minimize
functions (except the input polynomial that can be an arbitrary sequence of tensors/array or a sympy expression) are also keyword-only from now on.On the backend side, the
SimulatedBifurcationOptimizer
class constructor now only takes aSimulatedBifurcationEngine
enum object (enum
parameter) instead of themode
andheated
parameters.Moved classes
The
IsingCore
class has been moved to the newly createdcore
module and renamed in thecore.Ising
class. It must be imported usingfrom simulated_bifurcation.core.ising import Ising
instead offrom simulated_bifurcation.ising_core import IsingCore