common.title

Docs
Quantum Circuit
TYTAN CLOUD

QUANTUM GAMING


autoQAOA
Desktop RAG

Overview
Terms of service

Privacy policy

Contact
Research

Sign in
Sign up
common.title

量子マシンへのジョブ投稿のテンプレート

Yuichiro Minato

2021/03/16 02:13

#量子コンピュータ

こちらのテンプレートを取り込んで実行

こちらのテンプレートを自分のクラウドにimportしてもらえるとすぐに使えます。

import json
import urllib.request

API_KEY = "YOUR_API_KEY"

API_ENDPOINT = "https://cloudapi.blueqat.com/v1/"


def post_request(path, body):
    headers = {
        'Content-Type': 'application/json',
        'X-Api-Key': API_KEY,
    }
    req = urllib.request.Request(
        API_ENDPOINT + path, json.dumps(body).encode(), headers)
    with urllib.request.urlopen(req) as res:
        body = res.read()
    return json.loads(body)


def get_quantum_tasks(index):
    path = "quantum-tasks/list"
    body = {
        "index": index,
    }
    return post_request(path, body)


def get_quantum_task(id):
    path = "quantum-tasks/get"
    body = {
        "id": id,
    }
    return post_request(path, body)


def create_quantum_task(qubo, chain_strength, num_reads):
    path = "quantum-tasks/create"
    body = {
        "qubo": qubo,
        "chain_strength": chain_strength,
        "num_reads": num_reads,
    }
    return post_request(path, body)


def get_credit():
    path = "credit/get"
    return post_request(path, {})


# request example
print("get_quantum_tasks")
list = get_quantum_tasks(0)
print(list)

print("get_credit")
credit = get_credit()
print("{} credits available.".format(credit["amount"]))

print("create_quantum_task")
chain_strength = 8
num_reads = 10
qubo = [[-10.,  20.,   5.,   0.,   2.,   0.,   3.,   0.],
        [0., -10.,   0.,   5.,   0.,   2.,   0.,   3.],
        [0.,   0., -10.,  20.,   1.,   0.,   5.,   0.],
        [0.,   0.,   0., -10.,   0.,   1.,   0.,   5.],
        [0.,   0.,   0.,   0., -10.,  20.,   2.,   0.],
        [0.,   0.,   0.,   0.,   0., -10.,   0.,   2.],
        [0.,   0.,   0.,   0.,   0.,   0., -10.,  20.],
        [0.,   0.,   0.,   0.,   0.,   0.,   0., -10.]]
print(create_quantum_task(qubo, chain_strength, num_reads))

list = get_quantum_tasks(0)
id = list[0]["id"]
print("get_quantum_task")
print(get_quantum_task(id))

© 2025, blueqat Inc. All rights reserved