openjij.sampler.sampler#

This module defines the abstract sampler (BaseSampler).

Classes#

BaseSampler

Base sampler class of python wrapper for cxxjij simulator.

Functions#

measure_time(func)

Decorator for measuring calculation time.

Module Contents#

class openjij.sampler.sampler.BaseSampler[source]#

Bases: dimod.Sampler

Inheritance diagram of openjij.sampler.sampler.BaseSampler

Base sampler class of python wrapper for cxxjij simulator.

remove_unknown_kwargs(**kwargs) Dict[str, Any]#

Remove with warnings any keyword arguments not accepted by the sampler.

Parameters:

**kwargs – Keyword arguments to be validated.

Return type:

Dict[str, Any]

Returns: Updated kwargs dict.

Examples

>>> import warnings
>>> sampler = dimod.RandomSampler()
>>> with warnings.catch_warnings():
...     warnings.filterwarnings('ignore')
...     try:
...         sampler.remove_unknown_kwargs(num_reads=10, non_param=3)
...     except dimod.exceptions.SamplerUnknownArgWarning:
...        pass
{'num_reads': 10}
sample(bqm, **parameters)[source]#

Sample from a binary quadratic model.

Parameters:
  • bqm (openjij.BinaryQuadraticModel) – Binary Qudratic Model

  • **parameters – See the implemented sampling for additional keyword definitions.

Returns:

results

Return type:

openjij.sampler.response.Response

sample_ising(h, J, **parameters)[source]#

Sample from an Ising model using the implemented sample method.

Parameters:
  • h (dict) – Linear biases

  • J (dict) – Quadratic biases

Returns:

results

Return type:

openjij.sampler.response.Response

sample_qubo(Q, **parameters)[source]#

Sample from a QUBO model using the implemented sample method.

Parameters:

Q (dict or numpy.ndarray) – Coefficients of a quadratic unconstrained binary optimization

Returns:

results

Return type:

openjij.sampler.response.Response

parameters#
properties#
openjij.sampler.sampler.measure_time(func)[source]#

Decorator for measuring calculation time.

Parameters:

func – decorator function