openjij
Framework for the Ising model and QUBO.
Loading...
Searching...
No Matches
openjij.sampler.sqa_sampler.SQASampler Class Reference
Inheritance diagram for openjij.sampler.sqa_sampler.SQASampler:
Collaboration diagram for openjij.sampler.sqa_sampler.SQASampler:

Public Member Functions

 parameters (self)
 
 __init__ (self)
 
"openjij.sampler.response.Response" sample (self, Union["openjij.model.model.BinaryQuadraticModel", dimod.BinaryQuadraticModel] bqm, Optional[float] beta=None, Optional[float] gamma=None, Optional[int] num_sweeps=None, Optional[list] schedule=None, Optional[int] trotter=None, Optional[int] num_reads=None, Optional[Union[list, dict]] initial_state=None, Optional[str] updater=None, Optional[bool] sparse=None, Optional[bool] reinitialize_state=None, Optional[int] seed=None)
 
- Public Member Functions inherited from openjij.sampler.sampler.BaseSampler
 sample_ising (self, h, J, **parameters)
 
 sample_qubo (self, Q, **parameters)
 

Public Attributes

 schedule_info
 
- Public Attributes inherited from openjij.sampler.sampler.BaseSampler
 sample_ising
 
 sample_qubo
 

Protected Member Functions

 _convert_validation_schedule (self, schedule, beta)
 
 _get_result (self, system, model)
 
 _annealing_schedule_setting (self, model, beta=None, gamma=None, num_sweeps=None, schedule=None)
 
- Protected Member Functions inherited from openjij.sampler.sampler.BaseSampler
 _set_params (self, **kwargs)
 
 _sampling (self, **kwargs)
 
 _cxxjij_sampling (self, model, init_generator, algorithm, system, reinitialize_state=None, seed=None, offset=None)
 

Protected Attributes

 _default_params
 
 _params
 
 _make_system
 
 _algorithm
 

Additional Inherited Members

- Static Public Attributes inherited from openjij.sampler.sampler.BaseSampler
 properties = dict()
 

Detailed Description

Sampler with Simulated Quantum Annealing (SQA).

Inherits from :class:`openjij.sampler.sampler.BaseSampler`.
Hamiltonian

.. math::

    H(s) = s H_p + \\Gamma (1-s)\\sum_i \\sigma_i^x

where :math:`H_p` is the problem Hamiltonian we want to solve.

Args:
    beta (float): Inverse temperature.
    gamma (float): Amplitude of quantum fluctuation.
    trotter (int): Trotter number.
    num_sweeps (int): number of sweeps
    schedule (list): schedule list
    num_reads (int): Number of iterations.
    schedule_info (dict): Information about a annealing schedule.

Raises:
    ValueError: If the schedule violates as below.
    - not list or numpy.array.
    - schedule range is '0 <= s <= 1'.

Constructor & Destructor Documentation

◆ __init__()

openjij.sampler.sqa_sampler.SQASampler.__init__ (   self)

Member Function Documentation

◆ _annealing_schedule_setting()

openjij.sampler.sqa_sampler.SQASampler._annealing_schedule_setting (   self,
  model,
  beta = None,
  gamma = None,
  num_sweeps = None,
  schedule = None 
)
protected

◆ _convert_validation_schedule()

openjij.sampler.sqa_sampler.SQASampler._convert_validation_schedule (   self,
  schedule,
  beta 
)
protected

Referenced by openjij.sampler.sqa_sampler.SQASampler._annealing_schedule_setting().

Here is the caller graph for this function:

◆ _get_result()

openjij.sampler.sqa_sampler.SQASampler._get_result (   self,
  system,
  model 
)
protected

Reimplemented from openjij.sampler.sampler.BaseSampler.

Reimplemented in openjij.sampler.csqa_sampler.CSQASampler.

References openjij.sampler.sqa_sampler.SQASampler._get_result().

Referenced by openjij.sampler.sqa_sampler.SQASampler._get_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parameters()

openjij.sampler.sqa_sampler.SQASampler.parameters (   self)

◆ sample()

"openjij.sampler.response.Response" openjij.sampler.sqa_sampler.SQASampler.sample (   self,
Union[ "openjij.model.model.BinaryQuadraticModel", dimod.BinaryQuadraticModel ]  bqm,
Optional[float]   beta = None,
Optional[float]   gamma = None,
Optional[int]   num_sweeps = None,
Optional[list]   schedule = None,
Optional[int]   trotter = None,
Optional[int]   num_reads = None,
Optional[Union[list, dict]]   initial_state = None,
Optional[str]   updater = None,
Optional[bool]   sparse = None,
Optional[bool]   reinitialize_state = None,
Optional[int]   seed = None 
)
Sampling from the Ising model.

Args:
    bqm (openjij.BinaryQuadraticModel) binary quadratic model
    beta (float, optional): inverse tempareture.
    gamma (float, optional): strangth of transverse field. Defaults to None.
    num_sweeps (int, optional): number of sweeps. Defaults to None.
    schedule (list[list[float, int]], optional): List of annealing parameter. Defaults to None.
    trotter (int): Trotter number.
    num_reads (int, optional): number of sampling. Defaults to 1.
    initial_state (list[int], optional): Initial state. Defaults to None.
    updater (str, optional): update method. Defaults to 'single spin flip'.
    sparse (bool): use sparse matrix or not.
    reinitialize_state (bool, optional): Re-initilization at each sampling. Defaults to True.
    seed (int, optional): Sampling seed. Defaults to None.

Raises:
    ValueError:

Returns:
    :class:`openjij.sampler.response.Response`: results

Examples:

    for Ising case::

        >>> h = {0: -1, 1: -1, 2: 1, 3: 1}
        >>> J = {(0, 1): -1, (3, 4): -1}
        >>> sampler = openjij.SQASampler()
        >>> res = sampler.sample_ising(h, J)

    for QUBO case::

        >>> Q = {(0, 0): -1, (1, 1): -1, (2, 2): 1, (3, 3): 1, (4, 4): 1, (0, 1): -1, (3, 4): 1}
        >>> sampler = openjij.SQASampler()
        >>> res = sampler.sample_qubo(Q)

Reimplemented from openjij.sampler.sampler.BaseSampler.

References openjij.sampler.sa_sampler.SASampler._algorithm, openjij.sampler.sqa_sampler.SQASampler._algorithm, openjij.sampler.sqa_sampler.SQASampler._annealing_schedule_setting(), openjij.sampler.sampler.BaseSampler._cxxjij_sampling(), openjij.sampler.sa_sampler.SASampler._make_system, openjij.sampler.sqa_sampler.SQASampler._make_system, openjij.sampler.csqa_sampler.CSQASampler._params, openjij.sampler.sa_sampler.SASampler._params, openjij.sampler.sqa_sampler.SQASampler._params, openjij.sampler.sampler.BaseSampler._set_params(), openjij.sampler.sa_sampler.SASampler.schedule_info, and openjij.sampler.sqa_sampler.SQASampler.schedule_info.

Referenced by openjij.sampler.sampler.BaseSampler.sample_ising(), and openjij.sampler.sampler.BaseSampler.sample_qubo().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _algorithm

openjij.sampler.sqa_sampler.SQASampler._algorithm
protected

◆ _default_params

openjij.sampler.sqa_sampler.SQASampler._default_params
protected

◆ _make_system

openjij.sampler.sqa_sampler.SQASampler._make_system
protected

◆ _params

◆ schedule_info


The documentation for this class was generated from the following file: