MISInstance#
Module: iqm.applications.mis
- class iqm.applications.mis.MISInstance(graph, penalty=1, allow_custom_var_names=False)[source]#
Bases:
ISInstanceThe 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
ISInstancewith a simple objective function (aiming at maximizing the number of “selected” nodes).- Parameters:
penalty (float) – 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.
allow_custom_var_names (bool) – Determines whether it’s allowed for
graphto have nodes labelled by anything other than consecutive integers starting at 0.
Attributes
The best quality for the MIS problem.
The worst bitstring for the MIS problem, determined trivially.
The lowest quality value among all possible bitstrings.
The best bitstrings for the MIS problem.
Methods
Postprocessing function that fixes a single bitstring, making it satisfy the constraints.
Solve the MIS problem using Bron-Kerbosch algorithm and save some properties of the solution.
- property best_quality: float#
The best quality for the MIS problem.
Can be calculated together with other properties of the solution using the exhaustive Bron-Kerbosch algorithm.
- property lowest_quality_bitstrings: set[str]#
The best bitstrings for the MIS problem.
Can be calculated together with other properties of the solution using the exhaustive Bron-Kerbosch algorithm.
- property lower_bound: float#
The lowest quality value among all possible bitstrings.
Can be calculated together with other properties of the solution using the exhaustive Bron-Kerbosch algorithm.
- solve_with_bron_kerbosch()[source]#
Solve the MIS problem using Bron-Kerbosch algorithm and save some properties of the solution.
- Return type:
None
- property highest_quality_bitstrings: set[str]#
The worst bitstring for the MIS problem, determined trivially.
The worst bitstring satisfying all constraints is always selecting no nodes.
- 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.
Inheritance
