Skip to main content

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)=sHpΓ(1s)iσixH(s) = sH_p-\Gamma(1-s)\sum_i \sigma_i^x, we use the simulated annealing method on the Hamiltonian as follows:

H~=sLHp12βlogcoth(Γ(1s)βLil=1Lσikzσik+1z)\tilde{H} = \frac{s}{L}H_p - \frac{1}{2\beta}\log \coth\left(\frac{\Gamma(1-s)\beta}{L}\sum_i\sum_{l=1}^L\sigma^z_{ik}\sigma^z_{ik+1}\right)

where LL 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 LL is sufficiently large. ss varies in the range [0,1][0,1] according to s4(3584s+70s220s3)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 LL 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

nametypedefaultdescription
num_readsOptional[int]NoneThe number of samples. If None, 1 will be set.
num_sweepsOptional[int]NoneThe number of Monte-Carlo steps. If None, 1000 will be set.
betaOptional[float]NoneInverse tempareture. If None, this will be set automatically.
gammaOptional[float]NoneStrangth of transverse field. If None, this will be set automatically.
trotterOptional[int]NoneThe number of Trotter. If None, this will be set automatically.
sparseOptional[bool]NoneIf True, only non-zero matrix elements are stored, which will save memory. If None, False will be set.
needs_sqaure_constraintsOptional[dict[str, bool]]NoneThis 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_penaltiesOptional[dict[str, bool]]NoneThis 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

nametypedefaultdescription
parametersOptional[JijSQAParameters]NoneParameters for JijSQASampler.
searchboolFalseIf True, the parameter search will be carried out, which tries to find better values of multipliers for penalty terms.
num_searchint15The number of parameter search iteration. This option works if search is True.
algorithmOptional[Literal["v096", "v097-2", "v098"]]NoneAlgorithm 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_timeOptional[Union[int, float]]NoneThe 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.
syncboolTrueIf True, synchronous mode is enabled.
queue_nameOptional[str]NoneQueue 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.