Metadata-Version: 2.4
Name: jijsolver_api_client
Version: 0.1.1
Summary: A client for JijSolver API.
Author-email: "Jij Inc." <info@j-ij.com>
License: JijSolver API Client Terms of Use
        
        Please read these terms and conditions carefully before using JijSolver API Client.
        
        1. Interpretation and Definitions
        
        The words in which the initial letter is capitalized have meanings defined under the following conditions. The following definitions shall have the same meaning regardless of whether they appear in the singular or in the plural.
        
        For these Terms and Conditions:
        
        (a) "JijSolver" means a mathematical optimization solver provided by Jij Inc.
        (b) "JijSolver API" means a Web API provided by Jij Inc. for executing JijSolver.
        (c) "JijSolver API Client" represents software for accessing JijSolver API. This term includes sample programs provided by us.
        (d) Company (referred to as either "the Company", "We", "Us" or "Our" in this Agreement) refers to Jij Inc., #403, CIC, 3-3-6 Shibaura, Minato-ku, Tokyo, 108-0023, JAPAN.
        (e) "Access Information" means the API host name and access token issued for using JijSolver API.
        
        2. Acknowledgment
        
        These are the Terms and Conditions governing the use of JijSolver API Client and the agreement that operates between the User and the Company.
        These Terms and Conditions set out the rights and obligations of all users regarding the use of JijSolver API Client.
        
        Your use of JijSolver API Client is conditioned on Your acceptance of and compliance with these Terms and Conditions. These Terms and Conditions apply to all users who use JijSolver API Client.
        
        3. Copyright
        
        (a) All intellectual property rights, including copyrights (the rights outlined in Articles 27 and 28 of the Copyright Act of Japan), trademarks, patents, etc., related to JijSolver, JijSolver API and JijSolver API Client belong to the Company or third parties who have granted licenses to us and are not transferred to you by agreeing to these Terms of Use. 
        (b) This license does not entitle you to receive provision or disclosure of source code for any part of JijSolver API Client. However, this does not apply to sample programs, OSS, etc., that we voluntarily release to the public or that we are required to release based on a license from third parties.
        
        4. JijSolver API
        
        You must enter into a separate JijSolver API service agreement to access the JijSolver API using the JijSolver API Client.
        
        5. Prohibitions
        
        (a) Analyzing the structure, functions of JijSolver, JijSolver API and JijSolver API Client by reverse engineering, decompiling, disassembling, or other means or to obtain the source code of JijSolver API Client.
        (b) Duplicating or adapting all or part of the client software contained in the Software without the Company's prior consent.
        (c) Publishing a copy of the JijSolver API Client on a computer network that can be accessible by a third party.
        (d) Disclosing access information to a third party or publishing them.
        (e) Other use beyond the scope permitted by these Terms of Use.
        
        6.  Limitation of liability
        
        (a) The Company does not guarantee the accuracy, effectiveness, or optimality of the calculation results of JijSolver, JijSolver API, and JijSolver API Client.
        (b) The Company shall not be liable for any failure of the Software to operate when the User uses or uses the Software for the User's customer by incorporating or linking it with the User-provided Software.
        (c) The User shall be responsible for confirming and examining the suitability of the relevant foreign laws and regulations applicable to the use of the Software. The Company shall not be liable for any legal liabilities related to the appropriate foreign laws and regulations.
        
        Enacted 13 June 2025.
        
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: ommx<2.0.0,>=1.8.0
Requires-Dist: grpcio<2.0.0,>=1.69.0
Requires-Dist: certifi>=2025.0.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: requests; extra == "dev"
Dynamic: license-file

# JijSolver API Client

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

## Quick Start

### アクセストークンの取得

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

#### 利用申請方法

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

   **申請フォーム**: [JijSolverAPI 無償版 利用申請フォーム](https://docs.google.com/forms/d/e/1FAIpQLScLTRxXGaN7egRkoYcq2ZvFoFXRyYInsmPXlyxk9pF11E9--g/viewform)

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

### インストール

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

```bash
pip install jijsolver-api-client
```

### 環境変数の設定

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

- **`JIJSOLVER_SERVER_HOST`**: API サーバーのホスト名

- **`JIJSOLVER_ACCESS_TOKEN`**: アクセストークン

### 設定例

環境変数の設定例：

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

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

```python
import os

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

### リクエスト実行例

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

```python
pip install jijmodeling
```

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

```python

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 ソリューション

**例:**

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