openjij.model.king_graph#

Functions#

KingGraph([linear, quadratic, offset, king_graph, ...])

Generate KingGraph model.

make_KingGraph([linear, quadratic, king_graph])

KingGraph factory

make_KingGraph_from_JSON(obj)

KingGraph factory for JSON

Module Contents#

openjij.model.king_graph.KingGraph(linear=None, quadratic=None, offset=0.0, king_graph=None, vartype=SPIN, machine_type='')[source]#

Generate KingGraph model.

Parameters:
  • linear (dict) – linear biases

  • quadratic (dict) – quadratic biases

  • offset (float) – offset

  • king_graph

    represents ising or QUBO interaction. Each spins are decided by 2-d corrdinate x, y.

    • Quadratic term: [x1, y1, x2, y2, value]

    • Linear term: [x1, y1, x1, y1, value]

  • vartype – ‘SPIN’ or ‘BINARY’

  • machine_type (str) – choose ‘ASIC’ or ‘FPGA’

Returns:

generated KingGraphModel

Examples

The following code shows intialization of KingGraph:

>>> h = {}
>>> J = {(0, 1): -1.0, (1, 2): -3.0}
>>> king_graph = oj.KingGraph(machine_type="ASIC", linear=h, quadratic=J)

You can initialize it from king_interaction:

>>> king_interaction = [[0, 0, 1, 0, -1.0], [1, 0, 2, 0, -3.0]]
>>> king_graph = oj.KingGraph(machine_type="ASIC", king_graph=king_interaction)
openjij.model.king_graph.make_KingGraph(linear=None, quadratic=None, king_graph=None)[source]#

KingGraph factory

Returns:

generated KingGraph class

openjij.model.king_graph.make_KingGraph_from_JSON(obj)[source]#

KingGraph factory for JSON

Parameters:

obj (dict) – JSON object

Returns:

generated KingGraph class