Skip to main content

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

  1. 以下リンク先のフォームから利用申請を行ってください。 / 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

  2. 申請されたメールアドレス宛に、アクセスに必要な情報(API サーバーのホスト名、アクセストークン)が届きます。 / The information required for access (API server hostname, access token) will be sent to the email address you applied with.

インストール / Installation

JijZept Solver のクライアントパッケージをインストールします / Install the JijZept Solver client package:

pip install 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 を使用するため、事前にインストールしておきます。 / Install JijModeling in advance as it is used in the execution example.

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
v = jm.Placeholder("v", ndim=1)  # アイテムの価値 / Item values
w = jm.Placeholder("w", ndim=1)  # アイテムの重さ / Item weights
W = jm.Placeholder("W")          # ナップサックの容量 / Knapsack capacity
N = v.len_at(0, latex="N")       # アイテム数 / Number of items
x = jm.BinaryVar("x", shape=(N,))  # 決定変数 / Decision variables
i = jm.Element("i", belong_to=(0, N))

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

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

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

# APIにリクエストを実行 / Execute API request
solution = jijzept_solver.solve(instance, solve_limit_sec=2.0)

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

API リファレンス / API Reference

JijZept Solver を使用して最適化問題を解きます。 / Solve optimization problems using JijZept Solver.

パラメータ: / Parameters:

  • ommx_instance (Instance): OMMX インスタンス / OMMX instance
  • solve_limit_sec (float): 内部ソルバーの最大求解時間(秒)(データ読み込みや前処理・後処理、通信等の時間は含みません) / The maximum time allowed for the internal solver to run (in seconds) (excludes data loading, pre/post-processing, and communication time).
  • time_limit_sec (float, deprecated): solve_limit_sec の非推奨エイリアスです。将来のリリースで削除予定のため、代わりに solve_limit_sec を使用してください。 / Deprecated alias for solve_limit_sec. This will be removed in a future release. Use solve_limit_sec instead.
  • initial_ommx_state (State, optional): ソルバーが探索を開始する初期解。 / The initial state from which the solver starts its search.
  • seed (int, optional): ソルバーが使用する乱数シード。 / The random seed used by the solver.
  • terminate_if_optimal (bool, optional): 最適解を発見し証明した時点で終了するかどうか。 / Whether to stop as soon as an optimal solution is found and proven.
  • terminate_if_infeasible (bool, optional): 問題が infeasible と証明された時点で終了するかどうか。 / Whether to stop as soon as the problem is proven to be infeasible.

戻り値: / Return Value:

  • Solution: OMMX ソリューション / OMMX solution

例: / Example:

solution = jijzept_solver.solve(
    ommx_instance=problem_instance,
    solve_limit_sec=2.0
)

Metadata

Release files for jijzept-solver 1.4.0

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

Source distribution (sdist)

Source distribution for jijzept-solver 1.4.0
File Size Uploaded
jijzept_solver-1.4.0.tar.gz 22.4 kB Details

Release files / jijzept_solver-1.4.0.tar.gz

Download URL jijzept_solver-1.4.0.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
99d5d55b540e95346cd1cc410e23d7d003f205efa8bdc14e81161b9f01d48e08
BLAKE2b-256 checksum
How to use checksums
0d1e47d6686a5ee1489c0aa7ffba189a690605adf99a03bda190ecf4fc3a59ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.4.0 This release

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

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