Model Converters

These tasks manipulate any input Potts task into a new format. Currently there are two Modifier Tasks, one that can convert any Potts model into an (effective) Ising model, and one that can minor-embed an Ising model task into a given graph, to meet requirements of any particular hardware accelerator.

Binarized

class PottsPlayground.Tasks.Binarized(PottsTask, ConstraintFactor=1)

Maps any Potts model to an Ising model by splitting every q-dimensional Spin into q 2-dimensional spins and adding soft one-hot constraints to each group of Ising spins.

IsingToPottsSemantics(IsingState)

if the Ising state is valid, this will return the Potts state for the associated Potts Model. Invalid states will also be processed into a valid Potts state, but the transformation is undefined. The returned Potts state can then be sent to the parent Potts Task for interpretation or visualization as a graph coloring solution, etc.

Parameters:

IsingState (1-D numpy int) – Vector of Ising bit states.

Returns:

A vector representing a Potts model state.

Return type:

1-D numpy int

PottsToIsingSemantics(PottsState)

Converts a Potts state from the source task into an eqivalent Ising state.

Parameters:

PottsState (1-D numpy int) – Vector of Potts spin states.

Returns:

A vector representing a Ising model state.

Return type:

1-D numpy int

__init__(PottsTask, ConstraintFactor=1)

Turns a Potts model into an Ising model. The resulting task is still a PottsTask, but all spins are binary. The task can still be annealed as a Potts model, but can additionally be annealed using dedicated Ising-model code that runs a little faster.

Parameters:
  • PottsTask – Any object correctly derived from the BaseTask class. Could even be another BinarizedTask, although that would not be productive.

  • ConstraintFactor (float) – Weight penalty for two Ising bits both being “hot” if they represent different values of the same Potts spin.

MinorEmbedded

class PottsPlayground.Tasks.MinorEmbedded(task, target_graph, ConstraintFactor=1)

Uses utilities from d-wave ocean libraries to minor embed and map from a q=2 potts model with arbitrary connectivity to a fixed-hardware topology ising model.

FuzzyMinorToState(minor_state)

Uses majority-vote to collapse the minor-embedded representation back into the source ising model.

Parameters:

minor_state – A vector of spin values, corresponding to spins in the target/physical Ising model.

Returns:

A vector of spin values, corresponding to spins in the source/logical Ising model.

StateToMinor(state)

Converts a state in the native Ising format to a state in the embedded format. This is useful for creating an initial condition for the embedded model that corresponds to an equal initial condition in the original model.

Parameters:

state – A vector of spin values, corresponding to spins in the source/logical Ising model.

Returns:

A vector of spin values, corresponding to spins in the target/physical Ising model.

__init__(task, target_graph, ConstraintFactor=1)

Creates the minor-embedded task. May take a long time, and success is not guarenteed, since minor-embedding is itself an NP hard problem.

Parameters:
  • task – An Ising-compatible Potts task (i.e. a Potts task with q=2 for all Spins)

  • target_graph – A NetworkX graph of the allowed Ising model connectivity.

  • ConstraintFactor (float) – Energy penalty for disagreements within each physical chain representing a single logical spin.