Added New Annealing Solver Type for Discrete Optimization Problems: sa_disc_type
#8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The existing OpenFSAM is very powerful and can solve many different kinds of optimization problems, but one class of problems seems to have been left out: discrete optimization problems! (Finding the ground state of the Ising model, the Quadratic Unconstrained Binary Optimization problem, MAX-2-SAT, etc.) To address this, I've written a new annealing type called
sa_disc_type
to be used for such problems.The
sa_disc_type
extendssa_type_base
and adds a few important object properties:var_values
: An array that allows the end user to specify the domain for their discrete objective functionnum_perturb
: Borrowed from thesa_cont_type
, it specifies the number of parameters to perturb when seeking a new neighbouring state. Defaults to only changing one parameter at a time.The new function
get_neigh_disc
finds a new neighbouring state by perturbingnum_perturb
parameters of the energy function. (It is flexible enough to allow for any number of possible domain values, not just functions with binary parameters.)To complement this additional type, I've added an example that initializes and optimizes the Ising model.
The README has also been updated to accommodate the new type.
Side Note
Note that the
sa_comb_type
can technically be used to solve these discrete optimization problems, but the implementation is rather ugly. It requires setting an initial state which contains as many values as there are distinct values in the domain. (In the case of a problem with n binary parameters, this means 2n values.) Then, in the energy function, only the first n values must be used when calculating the performance of the given state. This technique comes with the additional downside that only one parameter can be perturbed in each iteration.