Skip to content

Jij CPU SA Sampler

JijSAParameters dataclass

Manage Parameters for using JijSASampler.

Attributes:

Name Type Description
beta_min Optional[float]

Minimum (initial) inverse temperature. If None, this will be set automatically.

beta_max Optional[float]

Maximum (final) inverse temperature. If None, this will be set automatically.

num_sweeps Optional[int]

The number of Monte-Carlo steps. If None, 1000 will be set.

num_reads Optional[int]

The number of samples. If None, 1 will be set.

initial_state Optional[dict]

Initial state. If None, this will be set automatically.

updater Optional[str]

Updater algorithm. "single spin flip" or "swendsen wang". If None, "single spin flip" will be set.

sparse Optional[bool]

If True, only non-zero matrix elements are stored, which will save memory. If None, False will be set.

reinitialize_state Optional[bool]

If True, reinitialize state for each run. If None, True will be set.

seed Optional[int]

Seed for Monte Carlo algorithm. If None, this will be set automatically.

JijSASampler

Bases: JijZeptBaseSampler

Simulated Annealing (SA) sampler.

SA for QUBO and the Ising Model. This sampler is designed for verifying and testing models with small instances and is best suited for initial testing and exploration of your models.

sample_hubo(J, parameters=None, max_wait_time=None, sync=True, queue_name=None, **kwargs)

Sampling from higher unconstrained binary optimization model (HUBO).

To configure the solver, instantiate the JijSAParameters class and pass the instance to the parameters argument.

Parameters:

Name Type Description Default
J dict

Polynomial interactions.

required
parameters JijSAParameters | None

defaults None.

None
max_wait_time 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.

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
**kwargs

SA parameters using **kwargs. If both **kwargs and parameters are exist, the value of **kwargs takes precedence.

{}

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
sampler = jz.JijSASampler(config='config.toml')
J = {(0,): -1, (0, 1): -1, (0, 1, 2): 1}
response = sampler.sample_hubo(J)

sample_model(model, feed_dict, multipliers={}, fixed_variables={}, needs_square_dict=None, search=False, num_search=15, algorithm=None, parameters=None, max_wait_time=None, sync=True, queue_name=None, **kwargs)

Sample using JijModeling by means of the simulated annealing.

To configure the solver, instantiate the JijSAParameters class and pass the instance to the parameters argument.

Parameters:

Name Type Description Default
model problem

Mathematical expression of JijModeling.

required
feed_dict Dict[str, Union[Number, list, np.ndarray]]

The actual values to be assigned to the placeholders.

required
multipliers Dict[str, Number]

The actual multipliers for penalty terms, derived from constraint conditions.

{}
needs_square_dict Dict[str, bool]

If True, the corresponding constraint is squared when added as a penalty to the QUBO. When the constraint label is not added to the 'needs_square_dict', it defaults to True for linear constraints and False for non-linear constraints.

None
search bool

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

False
num_search int

The number of parameter search iteration. Defaults to set 15. This option works if search is True.

15
algorithm Optional[str]

Algorithm for parameter search. Defaults to None.

None
parameters JijSAParameters | None

defaults None.

None
max_wait_time 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.

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
**kwargs

SA parameters using **kwargs. If both **kwargs and parameters are exist, the value of **kwargs takes precedence.

{}

Returns:

Name Type Description
JijModelingResponse JijModelingResponse

Stores minimum energy samples and other information.

Examples:

import jijzept as jz
import jijmodeling as jm
n = jm.Placeholder('n')
x = jm.Binary('x', shape=n)
d = jm.Placeholder('d', shape=n)
i = jm.Element("i", n)
problem = jm.Problem('problem')
problem += jm.Sum(i, d[i] * x[i])
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_model(problem, feed_dict={'n': 5, 'd': [1,2,3,4,5]})

sample_qubo(qubo, constant=0, parameters=None, max_wait_time=None, sync=True, queue_name=None, **kwargs)

Sampling from QUBO.

To configure the solver, instantiate the JijSAParameters class and pass the instance to the parameters argument.

Parameters:

Name Type Description Default
qubo dict[tuple[int, int], float]

QUBO dictionary.

required
constant float

A float representing the constant energy offset in the QUBO problem.

0
parameters JijSAParameters | None

SA parameters, defaults None.

None
max_wait_time 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.

None
sync bool

Synchronous mode.

True
queue_name Optional[str]

Queue name.

None
**kwargs

SA parameters using **kwargs. If both **kwargs and parameters are exist, the value of **kwargs takes precedence.

{}

Returns:

Type Description
JijModelingResponse

An extended type of jijmodleing.SampleSet that stores sampling results.

Examples:

import jijzept as jz
Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (0, 1): -1, (1, 2): 1}
sampler = jz.JijSASampler(config='config.toml')
response = sampler.sample_qubo(Q)

Last update: 2023年5月24日