This release is a pre-release and may not be stable for production use.
JijZept Solver
Jij 製の数理最適化ソルバーである JijZept Solver を 、Web API 経由で実行するための クライアントパッケージです。以下に使用方法を説明します。 / Client package for executing JijZept Solver, Jij's mathematical optimization solver, via Web API. The following explains how to use it.
Quick Start
アクセストークンの取得 / Obtaining Access Token
JijZept Solver(無償WebAPI版) を使用するには、事前にアクセストークンを取得する必要があります。無償版の利用申請方法は以下の通りです。 / To use JijZept Solver (Free Web API version), you need to obtain an access token in advance. The application method for the free version is as follows.
利用申請方法 / Application Method
-
以下リンク先のフォームから利用申請を行ってください。 / Please apply for usage from the form at the following link.
申請フォーム / Application Form: JijZept Solver(無償WebAPI版) 利用申請フォーム / JijZept Solver (Free Web API version) Usage Application Form
-
申請されたメールアドレス宛に、アクセスに必要な情報(API サーバーのホスト名、アクセストークン)が届きます。 / The information required for access (API server hostname, access token) will be sent to the email address you applied with.
インストール / Installation
JijZept Solver のクライアントパッケージをインストールします。2.x 系はベータ版のため --pre の指定が必要です。 / Install the JijZept Solver client package. The --pre flag is required while the 2.x series is in beta:
pip install --pre jijzept-solver
環境変数の設定 / Environment Variable Setup
上記利用申請により入手した、以下の値を環境変数に設定します / Set the following values obtained from the above application as environment variables:
-
JIJZEPT_SOLVER_SERVER_HOST: API サーバーのホスト名 / API server hostname -
JIJZEPT_SOLVER_ACCESS_TOKEN: アクセストークン / Access token
設定例 / Configuration Examples
環境変数の設定例 / Environment variable configuration example:
export JIJZEPT_SOLVER_SERVER_HOST="API サーバーのホスト名 / API server hostname"
export JIJZEPT_SOLVER_ACCESS_TOKEN="アクセストークン / Access token"
または Python コード内で設定する例 / Or example of setting within Python code:
import os
os.environ["JIJZEPT_SOLVER_SERVER_HOST"] = (
"API サーバーのホスト名 / API server hostname"
)
os.environ["JIJZEPT_SOLVER_ACCESS_TOKEN"] = "アクセストークン / Access token"
リクエスト実行例 / Request Execution Example
実行例の中で JijModeling を使用するため、事前にインストールしておきます(この例は jijmodeling 2.x の API を使用しています)。 / Install JijModeling in advance as it is used in the execution example (the example uses the jijmodeling 2.x API).
pip install jijmodeling
ナップサック問題を解く例 / Example of solving a knapsack problem:
import logging
import jijzept_solver
import jijmodeling as jm
logging.basicConfig(level=logging.INFO)
# ナップサック問題を定義 / Define knapsack problem
problem = jm.Problem("Knapsack", sense=jm.ProblemSense.MAXIMIZE)
v = problem.Float("v", ndim=1) # アイテムの価値 / Item values
w = problem.Float("w", ndim=1) # アイテムの重さ / Item weights
W = problem.Float("W") # ナップサックの容量 / Knapsack capacity
x = problem.BinaryVar("x", shape=v.len_at(0)) # 決定変数 / Decision variables
# 目的関数:価値の最大化 / Objective function: maximize value
problem += (v * x).sum()
# 重量制約 / Weight constraint
problem += problem.Constraint("weight", (w * x).sum() <= W)
# インスタンスデータから OMMX インスタンスを作成 / Create OMMX instance from data
instance = problem.eval(
{
"v": [10, 13, 18, 31, 7, 15], # アイテムの価値 / Item values
"w": [11, 15, 20, 35, 10, 33], # アイテムの重さ / Item weights
"W": 47, # ナップサックの容量 / Knapsack capacity
}
)
# APIにリクエストを実行 / Execute API request
solution = jijzept_solver.solve(instance, time_limit=2.0)
print(f"Value of the objective function: {solution.objective}")
API リファレンス / API Reference
JijZept Solver を使用して最適化問題を解きます。 / Solve optimization problems using JijZept Solver.
パラメータ: / Parameters:
instance(Instance): 解きたい問題の OMMX インスタンス / The OMMX instance to solve.time_limit(float, optional): 求解の制限時間(秒)。省略した場合は、API プランの上限時間が適用されます。API プランの上限を超える値はエラーになります。 / Time limit in seconds. If omitted, the maximum time limit of the API plan is applied. Values exceeding the API plan maximum are rejected.gap_limit(float, optional): 相対最適性ギャップの許容値。例: 0.01 は 1%(デフォルト 0.0001)。 / Relative optimality gap tolerance, e.g. 0.01 for 1% (default 0.0001).presolve(bool, optional): presolve(前処理)を有効にするかどうか(デフォルト: 有効)。 / Enable presolve (default: enabled).structure(Structure, optional): 問題の構造情報。構造に応じた推奨オプションのプリセットも適用されます。明示的に指定した引数はプリセットより優先されます。 / Structure describing problem structure. Also applies the structure's recommended option preset; explicitly passed arguments override the preset.initial_state(State, optional): ソルバーが探索を開始する初期解(ommx.v1.State)。初期解には、この API を通じて JijZept Solver が生成した解を使用することを推奨します。 / Optional initial solution asommx.v1.State. When usinginitial_state, we recommend a solution generated by JijZept Solver through this API.
戻り値: / Return Value:
Solution: OMMX ソリューション / OMMX solution
例: / Example:
solution = jijzept_solver.solve(instance, time_limit=2.0)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jijzept_solver-2.0.0b1.tar.gz.
File metadata
- Download URL: jijzept_solver-2.0.0b1.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
788be59c1b9010c4b3132f3eacfaa2ec3b148afb7055fe299e8aa5e50a69b92d
|
|
| MD5 |
3bd4e9014129773150b8e4c273aac1e4
|
|
| BLAKE2b-256 |
e95e17e3125398a1b32b8e40ee001ea63d7e7ce263a811d61f7ab25b117ef0db
|
Provenance
The following attestation bundles were made for jijzept_solver-2.0.0b1.tar.gz:
Publisher:
release_client.yml on Jij-Inc/JijZeptSolverAPI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jijzept_solver-2.0.0b1.tar.gz -
Subject digest:
788be59c1b9010c4b3132f3eacfaa2ec3b148afb7055fe299e8aa5e50a69b92d - Sigstore transparency entry: 2298189419
- Sigstore integration time:
-
Permalink:
Jij-Inc/JijZeptSolverAPI@f9a6b572ffa6caba57d53ecb14a7dafd9188890e -
Branch / Tag:
refs/tags/client-v2.0.0b1 - Owner: https://github.com/Jij-Inc
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release_client.yml@f9a6b572ffa6caba57d53ecb14a7dafd9188890e -
Trigger Event:
push
-
Statement type:
File details
Details for the file jijzept_solver-2.0.0b1-py3-none-any.whl.
File metadata
- Download URL: jijzept_solver-2.0.0b1-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d25676f4ea00807d2d260fc16007e8498a026a703f378943ac21f951e49dad0
|
|
| MD5 |
eebe42e7e69c2d420d0129b0fa90544b
|
|
| BLAKE2b-256 |
1f2da805dc7ef8d1380ffcb1da26c6e5c89ad2e45aa47ef61ef3b734ccfb8512
|
Provenance
The following attestation bundles were made for jijzept_solver-2.0.0b1-py3-none-any.whl:
Publisher:
release_client.yml on Jij-Inc/JijZeptSolverAPI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jijzept_solver-2.0.0b1-py3-none-any.whl -
Subject digest:
9d25676f4ea00807d2d260fc16007e8498a026a703f378943ac21f951e49dad0 - Sigstore transparency entry: 2298189461
- Sigstore integration time:
-
Permalink:
Jij-Inc/JijZeptSolverAPI@f9a6b572ffa6caba57d53ecb14a7dafd9188890e -
Branch / Tag:
refs/tags/client-v2.0.0b1 - Owner: https://github.com/Jij-Inc
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release_client.yml@f9a6b572ffa6caba57d53ecb14a7dafd9188890e -
Trigger Event:
push
-
Statement type: