qiskit_addon_opt_mapper.applications.SKModel

class SKModel(num_sites, rng_or_seed=None)[source]

Bases: OptimizationApplication

Optimization application of the “Sherrington Kirkpatrick (SK) model” [1].

The SK Hamiltonian over n spins is given as: \(H(x)=-1/\sqrt{n} \sum_{i<j} w_{i,j}x_ix_j\), where \(x_i\in\{\pm 1\}\) is the configuration of spins and \(w_{i,j}\in\{\pm 1\}\) is a disorder chosen independently and uniformly at random. Notice that there are other variants of disorders e.g., with \(w_{i,j}\) chosen from the normal distribution with mean 0 and variance 1.

References

[1]: Dmitry Panchenko. “The Sherrington-Kirkpatrick model: an overview”, https://arxiv.org/abs/1211.1094

Init method.

Parameters:
  • num_sites (int) – number of sites

  • rng_or_seed (Generator | int | None) – NumPy pseudo-random number generator or seed for np.random.default_rng(<seed>) or None. None results in usage of np.random.default_rng().

__init__(num_sites, rng_or_seed=None)[source]

Init method.

Parameters:
  • num_sites (int) – number of sites

  • rng_or_seed (Generator | int | None) – NumPy pseudo-random number generator or seed for np.random.default_rng(<seed>) or None. None results in usage of np.random.default_rng().

Methods

__init__(num_sites[, rng_or_seed])

Init method.

disorder()

Generate a new disorder of the SK model.

interpret(result)

Interpret a result as configuration of spins.

sample_most_likely(state_vector)

Compute the most likely binary string from state vector.

to_optimization_problem()

Represent as an optimization problem.

Attributes

graph

Getter of the graph representation.

num_sites

Getter of the number of sites.

nx_graph

Getter of the graph in Networkx format.

disorder()[source]

Generate a new disorder of the SK model.

Return type:

None

property graph: PyGraph

Getter of the graph representation.

Returns:

A graph for a problem.

interpret(result)[source]

Interpret a result as configuration of spins.

Parameters:

result (ndarray) – The calculated result of the problem.

Returns:

configuration of spins

Return type:

list[int]

property num_sites: int

Getter of the number of sites.

Returns:

Number of sites.

property nx_graph: Graph

Getter of the graph in Networkx format.

Returns:

A graph for a problem

static sample_most_likely(state_vector)[source]

Compute the most likely binary string from state vector.

Parameters:

state_vector (QuasiDistribution | Statevector | ndarray | dict) – state vector or counts or quasi-probabilities.

Returns:

binary string as numpy.ndarray of ints.

Raises:

ValueError – if state_vector is not QuasiDistribution, Statevector, np.ndarray, or dict.

Return type:

ndarray

to_optimization_problem()[source]

Represent as an optimization problem.

Convert an SK model problem instance into a OptimizationProblem.

Returns:

The OptimizationProblem created from the SK problem instance.

Return type:

OptimizationProblem