openjij.model.king_graph#
Functions#
|
Generate KingGraph model. |
|
KingGraph factory |
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 biasesquadratic (
dict
) – quadratic biasesoffset (
float
) – offsetking_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)