--- sd_hide_title: true --- # D-Wave Systems (clients-DWaveSamplerClient)= ## D-Wave Sampler [D-Wave Systems](https://www.dwavesys.com/) の提供する量子アニーリングマシン (QPU) です。QUBO あるいは イジング変数の二次多項式で表された組合せ最適化問題を入力できます。 ```{tip} Fixstars Amplify の[ユーザ登録](https://amplify.fixstars.com/register)を行い無償のお試し API トークンを入手するか、自身の D-Wave Systems のアカウントで API トークンを入手してください。 ``` :**ソルバー仕様**: ```{list-table} :width: 100% :widths: 1 2 * - クライアントクラス - {py:class}`amplify.DWaveSamplerClient` * - [実行パラメータ](amplify.DWaveSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [実行結果](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [実行時間](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["timing"]["qpu_access_time"]` * - API 方式 - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - 実行パラメータリファレンス - [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,バイナリ変数,イジング変数,整数変数,実数変数 目的関数,2次{sup}`*`,2次{sup}`*`,\-,\- 等式制約,\-,\-,\-,\- 不等式制約,\-,\-,\-,\- ``` \*: バイナリ変数とイジング変数の両方が同時に含まれる問題には対応していません。 :**クライアントクラス**: [クライアントクラスの共通インターフェース](#client-common-interface) に加えて以下のアトリビュートを持ちます。 ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - アトリビュート - データ型 - 詳細 * - {py:attr}`~amplify.DWaveSamplerClient.solver` - {py:class}`str` - 使用する D-Wave Sampler の名前を取得・設定します * - {py:attr}`~amplify.DWaveSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - 設定されたトークンで仕様可能な D-Wave Sampler の名前の一覧を取得します * - {py:attr}`~amplify.DWaveSamplerClient.properties` - {py:class}`dict` - 使用するソルバーのプロパティを取得します ({py:attr}`dwave.system.samplers.DWaveSampler.properties` と同じ結果が返ります) ``` :**設定例**: ```{testcode} from amplify import DWaveSamplerClient client = DWaveSamplerClient() # API トークンを設定 client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # 使用するソルバーを指定 # (client.solver_names に含まれる名前のいずれかを指定) client.solver = "Advantage_system4.1" # 実行回数を 1000 に設定 client.parameters.num_reads = 1000 ``` ````{seealso} {py:attr}`amplify.DWaveSamplerClient.parameters` に設定可能なアトリビュートは、[{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) を参照してください。 次のようにして {py:attr}`~amplify.DWaveSamplerClient.properties` から取得することも可能です (出力は {py:attr}`~amplify.DWaveSamplerClient.solver` によって変わります)。 ```python >>> client.properties["parameters"] {'anneal_offsets': 'Anneal offsets for each working qubit, formatted as a list, with NaN specified for unused qubits.', 'anneal_schedule': "Annealing schedule formatted as a piecewise linear list of floating-point pairs of 't' and 's'.", 'annealing_time': 'Quantum annealing duration, in microseconds, as a positive floating point number.', ...} ``` ```` :**実行例**: ```python from amplify import Model, VariableGenerator, solve # 決定変数と目的関数を定義 g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # モデルを作成 model = Model(f) # ソルバーを実行 result = solve(model, client) ``` 使用するソルバーを取得 (未指定の場合は自動的に決定): ```python >>> client.solver 'Advantage_system4.1' ``` 現在使用可能なソルバーの一覧を取得: ```python >>> client.solver_names ['Advantage_system6.4', 'Advantage2_prototype2.3', 'Advantage_system4.1'] ``` (clients-LeapHybridSamplerClient)= ## Leap's Hybrid BQM Sampler [D-Wave Systems](https://www.dwavesys.com/) の提供する量子アニーリングマシン (QPU) と古典アルゴリズムで動作するハイブリッドソルバーです。QUBO あるいは イジング変数の二次多項式で表された組合せ最適化問題を入力でき、[D-Wave Sampler](#DWaveSamplerClient) よりも大規模な問題の入力に対応しています。 ```{tip} Fixstars Amplify の[ユーザ登録](https://amplify.fixstars.com/register)を行い無償のお試し API トークンを入手するか、自身の D-Wave Systems のアカウントで API トークンを入手してください。 ``` :**ソルバー仕様**: ```{list-table} :width: 100% :widths: 1 2 * - クライアントクラス - {py:class}`amplify.LeapHybridSamplerClient` * - [実行パラメータ](amplify.LeapHybridSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [実行結果](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [実行時間](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["run_time"]` * - API 方式 - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - 実行パラメータリファレンス - [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,バイナリ変数,イジング変数,整数変数,実数変数 目的関数,2次,2次,\-,\- 等式制約,\-,\-,\-,\- 不等式制約,\-,\-,\-,\- ``` :**クライアントクラス**: [クライアントクラスの共通インターフェース](#client-common-interface) に加えて以下のアトリビュートを持ちます。 ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - アトリビュート - データ型 - 詳細 * - {py:attr}`~amplify.LeapHybridSamplerClient.solver` - {py:class}`str` - 使用する Leap's Hybrid BQM Sampler の名前を取得・設定します * - {py:attr}`~amplify.LeapHybridSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - 設定されたトークンで仕様可能な Leap's Hybrid BQM Sampler の名前の一覧を取得します * - {py:attr}`~amplify.LeapHybridSamplerClient.properties` - {py:class}`dict` - 使用するソルバーのプロパティを取得します ({py:attr}`dwave.system.samplers.LeapHybridSampler.properties` と同じ結果が返ります) ``` :**設定例**: ```{testcode} from amplify import LeapHybridSamplerClient client = LeapHybridSamplerClient() # API トークンを設定 client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # 使用するソルバーを取得 # (未指定であれば自動的に決定される) # print(client.solver) # 使用可能なソルバーの一覧を取得 # print(client.solver_names) # 使用するソルバーを指定 # (client.solver_names に含まれる名前のいずれかを指定) client.solver = "hybrid_binary_quadratic_model_version2" # 実行時間を 3 秒に設定 client.parameters.time_limit = 3 ``` ````{seealso} {py:attr}`amplify.LeapHybridSamplerClient.parameters` に設定可能なアトリビュートは、[{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) を参照してください。 次のようにして {py:attr}`~amplify.LeapHybridSamplerClient.properties` から取得することも可能です (出力は {py:attr}`~amplify.LeapHybridSamplerClient.solver` によって変わります)。 ```python >>> client.properties["parameters"] {'time_limit': 'Maximum requested runtime in seconds.'} ``` ```` :**実行例**: ```python from amplify import Model, VariableGenerator, solve # 決定変数と目的関数を定義 g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # モデルを作成 model = Model(f) # ソルバーを実行 result = solve(model, client) ``` 使用するソルバーを取得 (未指定の場合は自動的に決定): ```python >>> client.solver 'hybrid_binary_quadratic_model_version2' ``` 現在使用可能なソルバーの一覧を取得: ```python >>> client.solver_names ['hybrid_binary_quadratic_model_version2'] ``` (clients-LeapHybridCQMSamplerClient)= ## Leap's Hybrid CQM Sampler [D-Wave Systems](https://www.dwavesys.com/) の提供する量子アニーリングマシン (QPU) と古典アルゴリズムで動作するハイブリッドソルバーです。QUBO あるいは イジング変数、整数変数、実数変数の目的関数と1つ以上の制約条件で表された組合せ最適化問題を入力できます。 ```{tip} Fixstars Amplify の[ユーザ登録](https://amplify.fixstars.com/register)を行い無償のお試し API トークンを入手するか、自身の D-Wave Systems のアカウントで API トークンを入手してください。 ``` :**ソルバー仕様**: ```{list-table} :width: 100% :widths: 1 2 * - クライアントクラス - {py:class}`amplify.LeapHybridCQMSamplerClient` * - [実行パラメータ](amplify.LeapHybridCQMSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [実行結果](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [実行時間](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["run_time"]` * - API 方式 - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - 実行パラメータリファレンス - [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,バイナリ変数,イジング変数,整数変数,実数変数 目的関数,2次,2次,2次,1次 等式制約,2次,2次,2次,1次 不等式制約,2次,2次,2次,1次 ``` :**クライアントクラス**: [クライアントクラスの共通インターフェース](#client-common-interface) に加えて以下のアトリビュートを持ちます。 ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - アトリビュート - データ型 - 詳細 * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver` - {py:class}`str` - 使用する Leap's Hybrid BQM Sampler の名前を取得・設定します * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - 設定されたトークンで仕様可能な Leap's Hybrid BQM Sampler の名前の一覧を取得します * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.properties` - {py:class}`dict` - 使用するソルバーのプロパティを取得します ({py:attr}`dwave.system.samplers.LeapHybridCQMSampler.properties` と同じ結果が返ります) ``` :**設定例**: ```{testcode} from amplify import LeapHybridCQMSamplerClient client = LeapHybridCQMSamplerClient() # API トークンを設定 client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # 使用するソルバーを指定 # (client.solver_names に含まれる名前のいずれかを指定) client.solver = "hybrid_constrained_quadratic_model_version1p" # 実行時間を 3 秒に設定 client.parameters.time_limit = 3 ``` ````{seealso} {py:attr}`amplify.LeapHybridCQMSamplerClient.parameters` に設定可能なアトリビュートは、[{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) を参照してください。 次のようにして {py:attr}`~amplify.LeapHybridCQMSamplerClient.properties` から取得することも可能です (出力は {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver` によって変わります)。 ```python >>> client.properties["parameters"] {'time_limit': 'Maximum requested runtime in seconds.'} ``` ```` :**実行例**: ```python from amplify import Model, VariableGenerator, solve # 決定変数と目的関数を定義 g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # モデルを作成 model = Model(f) # ソルバーを実行 result = solve(model, client) ``` 使用するソルバーを取得 (未指定の場合は自動的に決定): ```python >>> client.solver 'hybrid_constrained_quadratic_model_version1p' ``` 現在使用可能なソルバーの一覧を取得: ```python >>> client.solver_names ['hybrid_constrained_quadratic_model_version1p'] ``` ソルバーのバージョンを取得: ```python >>> client.version '1.12' ```