MISInstance#
- class iqm.applications.mis.MISInstance(graph, penalty=1)[source]#
Bases:
ISInstance
The instance class for maximum independent set problems.
The maximum independent set problem refers to finding the largest subset of nodes of a graph, such that no nodes in the subset are connected by an edge. It is completely equivalent to finding the largest clique on the complement graph. The class is initialized by initializing its parent class
ISInstance
with a simple objective function (aiming at maximizing the number of “selected” nodes).- Parameters:
penalty (float | int) – The penalty to be incurred per each edge present in the solution, sometimes referred to as \(\lambda\) in the literature. The higher it is, the less likely the algorithm is to include an edge in the solution. It needs to be set above 1 to insure that the solution is a maximum independent set. It’s typically set at 2. At 1, the correct solution will be degenerate with non-independent sets.
Attributes
The best quality for the MIS problem, calculated using the Bron-Kerbosch algorithm.
Methods
fix_constraint_violation_bitstring
(bit_str)Postprocessing function that fixes a single bitstring, making it satisfy the constraints.
- property best_quality: float#
The best quality for the MIS problem, calculated using the Bron-Kerbosch algorithm.
Instead of brute-forcing over all possible bitstrings, this uses an exhaustive algorithm that finds the best solution more efficiently (although it also has exponential scaling).
- fix_constraint_violation_bitstring(bit_str)[source]#
Postprocessing function that fixes a single bitstring, making it satisfy the constraints.
It works in the following way:
Get the subgraph induced by the bitstring
bit_str
.Find the node with the highest degree.
Remove the node from the subgraph (i.e., flip the corresponding bit from “1” to “0”).
Repeat 2-3 until the subgraph contains no edges.
Return the bitstring corresponding to the remaining subgraph (which is an independent subset of the original graph).
For
penalty = 1
, this guarantees that the output bitstring has energy at least as low as the input bitstring. Forpenalty > 1
, the energy is expected to be even lower.