# JijSQASampler

Simulated Quantum Annealing (SQA) is one of the quantum-inspired algorithms that simulates quantum annealing. In this method, instead of performing quantum annealing for $H(s) = sH_p-\Gamma(1-s)\sum_i \sigma_i^x$, we use the simulated annealing method on the Hamiltonian as follows:

where $L$ is a quantity called the Trotter number, $\Gamma$ is the strength of the transverse magnetic field, and $\beta$ is the inverse temperature. Theoretically, this method gives results corresponding to quantum annealing when $L$ is sufficiently large. $s$ varies in the range $[0,1]$ according to $s^4(35-84s+70s^2-20s^3)$ which is proposed in [S. Morita and H. Nishimori, “Mathematical foundation of quantum annealing”. *J. Math. Phys.* 1 December 2008; 49 (12): 125210.].

In SQA, replicas are created by Trotter decomposition, as shown in the illustration below. Interactions between these replicas emulate quantum effects. Therefore, for many replicas (if $L$ is large), the behavior of SQA is expected to be close to the original quantum annealing, but it should be noted that the computational cost of the simulation is as large as the number of replicas.

Currently, JijSQASampler is provided with the intention of research use for comparison with quantum annealers. Therefore, the SQA parameters, such as `beta`

, `gamma`

and `trotter`

, are not well-tuned for the purpose of the optimization problem. If you wish to use Sampler to perform optimization calculations, please consider using other Samplers.

## Usage

Use the two classes provided by the `jijzept`

and run the method `sample_model`

in the `JijSQASampler`

class:

`JijSQASampler`

: a class to sample by the SQA method.`JijSQAParameters`

: a class to set parameters specifically for the SQA sampler.

`from jijzept import JijSQASampler, JijSQAParameters`

sampler = JijSQASampler(config="./config.toml")

parameters = JijSQAParameters(

beta=5,

gamma=1,

trotter=5,

)

response = sampler.sample_model(

problem=problem,

feed_dict=instance_data,

parameters=parameters,

search = True,

max_wait_time=300,

)

## What does JijZept automatically tune?

By setting the `search`

argument of the `sample_model`

method to `True`

, the weight coefficients for converting the mathematical model to Quadratic Unconstrained Binary Optimization (QUBO) are automatically adjusted.

## Parameters

`JijSQAParameters`

name | type | default | description |
---|---|---|---|

`num_reads` | `Optional[int]` | `None` | The number of samples. If `None` , `1` will be set. |

`num_sweeps` | `Optional[int]` | `None` | The number of Monte-Carlo steps. If `None` , `1000` will be set. |

`beta` | `Optional[float]` | `None` | Inverse tempareture. If `None` , this will be set automatically. |

`gamma` | `Optional[float]` | `None` | Strangth of transverse field. If `None` , this will be set automatically. |

`trotter` | `Optional[int]` | `None` | The number of Trotter. If `None` , this will be set automatically. |

`sparse` | `Optional[bool]` | `None` | If True, only non-zero matrix elements are stored, which will save memory. If `None` , `False` will be set. |

`needs_sqaure_constraints` | `Optional[dict[str, bool]]` | `None` | This dictionary object determines whether to square the constraint condition while incorporating it into the QUBO/HUBO penalty term. Here, the constraint's name is used as the key. If the value is set to `True` , the corresponding constraint is squared upon its addition to the QUBO/HUBO penalty term. If `None` , the value is set to `True` for linear constraints and to `False` for non-linear ones. |

`relax_as_penalties` | `Optional[dict[str, bool]]` | `None` | This dictionary object is designed to regulate the incorporation of constraint conditions into the QUBO/HUBO penalty term, with the constraint's name functioning as the key. The respective constraint is added to the QUBO/HUBO penalty term if the key's value is `True` . If the value is `False` , the constraint is excluded from the penalty term, though it remains subject to evaluation to verify if it meets the constraint conditions. If `None` , all constraint conditions have this value set to `True` . |

`JijSQASampler.sample_model`

name | type | default | description |
---|---|---|---|

`parameters` | `Optional[JijSQAParameters]` | `None` | Parameters for JijSQASampler. |

`search` | `bool` | `False` | If `True` , the parameter search will be carried out, which tries to find better values of multipliers for penalty terms. |

`num_search` | `int` | `15` | The number of parameter search iteration. This option works if `search` is `True` . |

`algorithm` | `Optional[Literal["v096", "v097-2", "v098"]]` | `None` | Algorithm for parameter search. The valid strings for algorithm are `"v096"` , `"v097-2"` , `"v098"` , users can specify the method used to the parameter search. If `None` , `"v098"` will be set. |

`max_wait_time` | `Optional[Union[int, float]]` | `None` | The number of timeout [sec] for post request. If `None` , `60` (one minute) will be set. Please note that this argument is for the JijZept timeout and not for configuring solver settings, such as solving time. |

`sync` | `bool` | `True` | If `True` , synchronous mode is enabled. |

`queue_name` | `Optional[str]` | `None` | Queue name |

## Note

Currently, JijSQASampler is provided with the intention of research use for comparison with quantum annealers. Therefore, the SQA parameters, such as beta and gamma, are not well-tuned for the purpose of the optimization problem. If you wish to use Sampler to perform optimization calculations, please consider using other Samplers.