Skip to main content

Python Interface for Jij-Zept

Project description

JijZept Quick Start

How to get started with JijZept

The minimal sample code as follows:

from jijzept import JijSASampler

# define QUBO
qubo = {(0,0): -1, (0, 1): -1, (1, 0): 2}

sampler = JijSASampler(config='config.toml')
result = sampler.sample_qubo(qubo)

print(result)

Write a configuration file for connecting to JijZept in config.toml and put it in the config argument of the Sampler constructor.
The configuration file should be written in TOML format as follows.

[default]
url = "***"
token = "****"

Copy and paste the assigned API endpoint into the url and your token into token in the configure file.

またデフォルトでは同期モード になっているため、APIに投げて計算が終わるで待ってから解を得ることになります。

同期モードをオフにして非同期でJijZeptを使うには以下の手順で答えを得ることができます。

async mode

非同期モードでAPIを使いたい場合は、.sample_* の引数で、async=False にして同期モードをオフにする必要があります。

サンプルコード

from jijzept import JijSASampler
from jijzept import api

# define qubo
qubo = {(0, 0): -1, (0, 1): -1, (1, 0): 2}

sampler = JijSASampler(config='config.toml')
# set sync=False
response = sampler.sample_qubo(qubo, sync=False)

# get result
response = response.get_result(config='config.toml')


if response.status == api.SUCESS:
    print(response)
elif response.status == api.PENDING:
    print('Solver status: PENDING')
else:
    print('Error')

非同期モードでも .sample_* の返り値は 同期モードと同じくSampleSet クラスです。   ですが、解が入っていない可能性があります(非同期モードでも一度だけ解を取りに行っているので計算時間が短いと解をもっている可能性もあります)。

解を取りに行くためのコードが

response = response.get_result(config='config.toml')

です。.get_resultの引数configに認証情報を記述した設定ファイルを指定するのを忘れないでください。
また.get_resultは返り値をもつ非破壊メソッドです。

計算が終了したかどうかはget_resultの返り値の.status変数で確認することができます。

from jijzept import api
if response.status == api.SUCESS:
    print(response)
elif response.status == api.PENDING:
    print('Solver status: PENDING')
else:
    print('Error')

Available solvers

  • JijSASampler

    • Hardware: CPU
    • Algorihtm: (Standard) Simulated annealing
    • Problem Type: Binary quadratic model (Ising or QUBO)
  • JijSQASampler

    • Hardware: CPU
    • Algorithm: (Standard) Simulated quantum annealing
    • Problem Type: Binary quadratic model (Ising or QUBO)
  • JijSBMSampler

    • Hardware: GPU
    • Algorithm: TOSHIBA SBM
  • JijDWaveSampler

    • Hardware: D-Wave QPU
    • Algorithm: Quantum annealing

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jijzept-1.10.2.tar.gz (29.1 kB view hashes)

Uploaded Source

Built Distribution

jijzept-1.10.2-py3-none-any.whl (148.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page