iqm.applications.maxcut#
This module contains the maxcut problem instance class and related functions.
Contains the iterator function maxcut_generator()
which yields random instances of MaxCutInstance
, useful
for applications such as calculating the Q-score. Also contains two classical solvers for maxcut problems:
A simple and fast greedy algorithm.
A solver based on the standard Goemans-Williamson [1], fast and with a performance guarantee.
Example
from iqm.applications.maxcut import MaxCutInstance
from iqm.applications.maxcut import maxcut_generator
from iqm.applications.maxcut import goemans_williamson
from iqm.applications.maxcut import greedy_maxcut
for my_instance in maxcut_generator(graph_size, n_instances): # Generates problem instances.
gw_solution = goemans_williamson(my_instance) # Solution bitstring obtained from GW.
greedy_solution = greedy_maxcut(my_instance) # Solution bitstring obtained from greedy.
my_instance.cut_size(gw_solution) # Check the GW solution cut size.
my_maxcut_instance = MaxCutInstance(my_graph) # Problem instance from a graph.
Functions
|
Runs the Goemans-Williamson algorithm for maxcut, returning a solution bitstring. |
|
Standard greedy algorithm for maxcut problem class. |
|
The generator function for generating random maxcut problem instances. |
Classes
|
The maxcut instance class. |
|
The weighted maxcut instance class. |
Inheritance
