Skip to main content

JijSolver API Client

Jij 製の数理最適化ソルバーである JijSolver を 、Web API 経由で実行するための クライアントパッケージです。以下に使用方法を説明します。

Quick Start

アクセストークンの取得

JijSolver API を使用するには、事前にアクセストークンを取得する必要があります。無償版の利用申請方法は以下の通りです。

利用申請方法

  1. 以下リンク先のフォームから利用申請を行ってください。

    申請フォーム: JijSolverAPI 無償版 利用申請フォーム

  2. 申請されたメールアドレス宛に、アクセスに必要な情報(API サーバーのホスト名、アクセストークン)が届きます。

インストール

JijSolver API のクライアントパッケージをインストールします:

pip install jijsolver-api-client

環境変数の設定

上記利用申請により入手した、以下の値を環境変数に設定します:

  • JIJSOLVER_SERVER_HOST: API サーバーのホスト名

  • JIJSOLVER_ACCESS_TOKEN: アクセストークン

設定例

環境変数の設定例:

export JIJSOLVER_SERVER_HOST="API サーバーのホスト名"
export JIJSOLVER_ACCESS_TOKEN="アクセストークン"

または Python コード内で設定する例:

import os

os.environ["JIJSOLVER_SERVER_HOST"] = "API サーバーのホスト名"
os.environ["JIJSOLVER_ACCESS_TOKEN"] = "アクセストークン"

リクエスト実行例

実行例の中で JijModeling を使用するため、事前にインストールしておきます。

pip install jijmodeling

ナップサック問題を解く例:

import os
import logging
import jijsolver
import jijmodeling as jm

logging.basicConfig(level=logging.INFO)

# ナップサック問題を定義
v = jm.Placeholder("v", ndim=1)  # アイテムの価値
w = jm.Placeholder("w", ndim=1)  # アイテムの重さ
W = jm.Placeholder("W")          # ナップサックの容量
N = v.len_at(0, latex="N")       # アイテム数
x = jm.BinaryVar("x", shape=(N,))  # 決定変数
i = jm.Element("i", belong_to=(0, N))

problem = jm.Problem("Knapsack", sense=jm.ProblemSense.MAXIMIZE)
problem += jm.sum(i, v[i] * x[i])  # 目的関数:価値の最大化
problem += jm.Constraint("weight", jm.sum(i, w[i] * x[i]) <= W)  # 重量制約

# インスタンスデータ
instance_data = {
    "v": [10, 13, 18, 31, 7, 15],   # アイテムの価値
    "w": [11, 15, 20, 35, 10, 33],  # アイテムの重さ
    "W": 47,                        # ナップサックの容量
}

# OMMX インスタンスを作成
interpreter = jm.Interpreter(instance_data)
instance = interpreter.eval_problem(problem)

# APIにリクエストを実行
solution = jijsolver.solve(instance, time_limit_sec=2.0)

print(f"Value of the objective function: {solution.objective}")

API リファレンス

JijSolver API を使用して最適化問題を解きます。

パラメータ:

  • ommx_instance (Instance): OMMX インスタンス
  • time_limit_sec (float): 最大求解時間(秒)

戻り値:

  • Solution: OMMX ソリューション

例:

solution = jijsolver.solve(
    ommx_instance=problem_instance,
    time_limit_sec=2.0
)

Metadata

Release files for jijsolver-api-client 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jijsolver-api-client 0.1.1
File Size Uploaded
jijsolver_api_client-0.1.1.tar.gz 12.3 kB Details

Release files / jijsolver_api_client-0.1.1.tar.gz

Download URL jijsolver_api_client-0.1.1.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1c8a5a4b8e9920881790265a10ac984073ffe7a1b9935ba85e3607672221ff73
BLAKE2b-256 checksum
How to use checksums
6a8d66084534cc480034bcfa7faa78f6f3bd2359f9a56d2909321b91e4effe5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page