Client ====== .. role:: raw-html(raw) :format: html This section describes the Ising machine clients. Client Class Overview ---------------------- The client class provides an interface for getting and setting hardware parameters of each Ising machine, as well as for executing it. The typical use of the client class is to give the client class object as a driver to the solver class :class:`~amplify.Solver`, so that the solver class can solve logical models using the corresponding Ising machine. See :doc:`solver` or :ref:`execution example of each client ` for more details and examples. .. note:: Although the client class can also be used as a solver for the physical model (see :ref:`physical model solver ` for more information), it is recommended to use the solver class. There are two types of parameters that the client class can set: * Settings of access information and execution of the Ising machines These are provided as the attributes of the client class. It sets configurations such as the URL of the access point and API token. Some clients have settings related to data compression and data transmission methods. * Execution parameters of the Ising machines It sets the execution parameters according to the API specifications of the machines. It is provided by the attribute :attr:`~amplify.client.FixstarsClient.parameters` of the client class. .. seealso:: Please refer to :doc:`reference/client` for more information on the client classes and their related classes. .. _client-fixstars: Fixstars -------- Amplify AE Client Class ^^^^^^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`Fixstars client reference ` for more information. +-----------------------------------------------------+-----------------------------------------------------+ | Name | Fixstars Amplify Annealing Engine | +=====================================================+=====================================================+ | Client class | :class:`~amplify.client.FixstarsClient` | +-----------------------------------------------------+-----------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FixstarsClientParameters` | +-----------------------------------------------------+-----------------------------------------------------+ | Execution result class | :class:`~amplify.client.FixstarsClientResult` | +-----------------------------------------------------+-----------------------------------------------------+ | Execution time class | :class:`~amplify.client.FixstarsClientResultTiming` | +-----------------------------------------------------+-----------------------------------------------------+ | Physical graph | Fully connected coupling | +-----------------------------------------------------+-----------------------------------------------------+ | Number of physical bits | 262144 or greater | +-----------------------------------------------------+-----------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 131072 | +-----------------------------------------------------+-----------------------------------------------------+ | API endpoint (default) | https://optigan.fixstars.com/ | +-----------------------------------------------------+-----------------------------------------------------+ Attributes of Amplify AE Client Class ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.FixstarsClient.num_bits` - Get the maximum number of executable variables. * - :attr:`~amplify.client.FixstarsClient.parameters` - Get the execution parameters :class:`~amplify.client.FixstarsClientParameters`. * - :attr:`~amplify.client.FixstarsClient.version` - Get the version string of the Amplify Annealing Engine. * - :attr:`~amplify.client.FixstarsClient.url` - Get or set the API URL. * - :attr:`~amplify.client.FixstarsClient.proxy` - Get or set the proxy server address. * - :attr:`~amplify.client.FixstarsClient.token` - Get or set the API token. * - :attr:`~amplify.client.FixstarsClient.write_request_data` - Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. * - :attr:`~amplify.client.FixstarsClient.write_response_data` - Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. * - :attr:`~amplify.client.FixstarsClient.compression` - Specify whether to compress the transmitted data. Defaults to ``True``. Example of Amplify AE Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import FixstarsClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = FixstarsClient() client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" client.parameters.timeout = 1000 # Timeout is 1 second solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] D-Wave ------ .. note:: To use D-Wave Sampler and Leap Hybrid Solver, `dwave-system `_ package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows: .. code-block:: bash $ pip install amplify[extra] D-Wave Client Classes ^^^^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`D-Wave client reference ` for more information. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ | Name | D-Wave Sampler (Ocean SDK) | +===================================================+========================================================================================================+ | Client class | :class:`~amplify.client.ocean.DWaveSamplerClient` | +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.ocean.DWaveSamplerClientQuantumSolverParametersOcean` | +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.ocean.DWaveSamplerClientResult` | +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.ocean.DWaveSamplerClientResultTiming` | +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ | Physical graph | `Zephyr graph`_ (Advantage2_prototype1.1), `Pegasus graph`_ (Advantage_system4.1, Advantage_system6.3) | +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ | Number of physical bits | 563 (Advantage2_prototype1.1), 5627 (Advantage_system4.1), 5614 (Advantage_system6.3) | +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 52 (Advantage2_prototype1.1), 177 (Advantage_system4.1), 175 (Advantage_system6.1) | +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ | API endpoint (default) | https://cloud.dwavesys.com/sapi | +---------------------------------------------------+--------------------------------------------------------------------------------------------------------+ .. _Zephyr graph: https://docs.ocean.dwavesys.com/en/stable/concepts/topology.html#zephyr .. _Pegasus graph: https://docs.ocean.dwavesys.com/en/stable/concepts/topology.html#pegasus .. _Chimera graph: https://docs.ocean.dwavesys.com/en/stable/concepts/topology.html#chimera +---------------------------------------------------+----------------------------------------------------------------------------------+ | Name | Leap Hybrid Solver (Ocean SDK) | +===================================================+==================================================================================+ | Client class | :class:`~amplify.client.ocean.LeapHybridSamplerClient` | +---------------------------------------------------+----------------------------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.ocean.LeapHybridSamplerClientLeapHybridSolverParameters` | +---------------------------------------------------+----------------------------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.ocean.LeapHybridSamplerClientResult` | +---------------------------------------------------+----------------------------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.ocean.LeapHybridSamplerClientResultTiming` | +---------------------------------------------------+----------------------------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+----------------------------------------------------------------------------------+ | Number of physical bits | 1000000 | +---------------------------------------------------+----------------------------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 1000000 | +---------------------------------------------------+----------------------------------------------------------------------------------+ | API endpoint (default) | https://cloud.dwavesys.com/sapi | +---------------------------------------------------+----------------------------------------------------------------------------------+ Attributes of D-Wave Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. **D-Wave Sampler Client** .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`num_bits` - Get the maximum number of executable variables. :raw-html:`
` :raw-html:`
` :D-Wave Sampler: N/A :Leap Hybrid Solver: 1000000 * - :attr:`parameters` - Get the execution parameters. :raw-html:`
` :raw-html:`
` :D-Wave Sampler: :class:`~amplify.client.ocean.DWaveSamplerClientQuantumSolverParametersOcean` :Leap Hybrid Solver: :class:`~amplify.client.ocean.LeapHybridSamplerClientLeapHybridSolverParameters` * - :attr:`proxy` - Get or set the proxy server address. * - :attr:`solver` - Get or set the name of the solver to be executed. :raw-html:`
` :raw-html:`
` :D-Wave Sampler: ``Advantage2_prototype1.1``, ``"Advantage_system4.1"``, ``"Advantage_system6.3"`` :Leap Hybrid Solver: ``"hybrid_binary_quadratic_model_version2"``, ``"hybrid_binary_quadratic_model_version2p"`` * - :attr:`solver_names` - Get the list of available solver names. * - :attr:`token` - Get or set the API token. * - :attr:`url` - Get or set the API URL. * - :attr:`version` - Get the solver name with its version string. Example of D-Wave Client ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. _client-dwave_sampler: **D-Wave Sampler Client** .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client.ocean import DWaveSamplerClient client = DWaveSamplerClient() client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Specify the solver (the available solver names can be obtained by `solver_names`) client.solver = "Advantage_system4.1" client.parameters.num_reads = 100 # Number of executions gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] By setting ``token``, the list of the available solver names related to the token can be obtained as follows: >>> client.solver_names ['Advantage_system4.1', 'Advantage_system6.3', 'Advantage2_prototype1.1'] **D-Wave Leap Hybrid Solver Client** .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client.ocean import LeapHybridSamplerClient client = LeapHybridSamplerClient() client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Specify the solver (the available solver names can be obtained by `solver_names`) client.solver = "hybrid_binary_quadratic_model_version2" client.parameters.time_limit = 3 # Time limit is 3 seconds gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] Similar to :obj:`~amplify.client.DwaveSamplerClient`, the available solver names can be obtained as follows: >>> client.solver_names ['hybrid_binary_quadratic_model_version2'] .. _client-fujitsu: Fujitsu ------- Fujitsu Client Classes ^^^^^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`Fujitsu client reference ` for more information. +---------------------------------------------------+------------------------------------------------------------+ | Name | FujitsuDASolver | +===================================================+============================================================+ | Client class | :class:`~amplify.client.FujitsuDASolverClient` | +---------------------------------------------------+------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDASolverClientParameters` | +---------------------------------------------------+------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDASolverClientResult` | +---------------------------------------------------+------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDASolverClientResultTiming` | +---------------------------------------------------+------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+------------------------------------------------------------+ | Number of physical bits | 1024 | +---------------------------------------------------+------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 1024 | +---------------------------------------------------+------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+------------------------------------------------------------+ +---------------------------------------------------+------------------------------------------------------------------+ | Name | FujitsuDASolver (Expert Mode) | +===================================================+==================================================================+ | Client class | :class:`~amplify.client.FujitsuDASolverExpertClient` | +---------------------------------------------------+------------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDASolverExpertClientParameters` | +---------------------------------------------------+------------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDASolverExpertClientResult` | +---------------------------------------------------+------------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDASolverExpertClientResultTiming` | +---------------------------------------------------+------------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+------------------------------------------------------------------+ | Number of physical bits | 1024 | +---------------------------------------------------+------------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 1024 | +---------------------------------------------------+------------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+------------------------------------------------------------------+ +---------------------------------------------------+--------------------------------------------------------------+ | Name | FujitsuDAPTSolver | +===================================================+==============================================================+ | Client class | :class:`~amplify.client.FujitsuDAPTSolverClient` | +---------------------------------------------------+--------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDAPTSolverClientParameters` | +---------------------------------------------------+--------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDAPTSolverClientResult` | +---------------------------------------------------+--------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDAPTSolverClientResultTiming` | +---------------------------------------------------+--------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+--------------------------------------------------------------+ | Number of physical bits | 1024 | +---------------------------------------------------+--------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 1024 | +---------------------------------------------------+--------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+--------------------------------------------------------------+ +---------------------------------------------------+---------------------------------------------------------------------+ | Name | FujitsuDAMixedModeSolver | +===================================================+=====================================================================+ | Client class | :class:`~amplify.client.FujitsuDAMixedModeSolverClient` | +---------------------------------------------------+---------------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDAMixedModeSolverClientParameters` | +---------------------------------------------------+---------------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDAMixedModeSolverClientResult` | +---------------------------------------------------+---------------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDAMixedModeSolverClientResultTiming` | +---------------------------------------------------+---------------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+---------------------------------------------------------------------+ | Number of physical bits | 1024 | +---------------------------------------------------+---------------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 1024 | +---------------------------------------------------+---------------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+---------------------------------------------------------------------+ +---------------------------------------------------+-------------------------------------------------------------+ | Name | FujitsuDA2Solver | +===================================================+=============================================================+ | Client class | :class:`~amplify.client.FujitsuDA2SolverClient` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDA2SolverClientParameters` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDA2SolverClientResult` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDA2SolverClientResultTiming` | +---------------------------------------------------+-------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+-------------------------------------------------------------+ | Number of physical bits | 8192 | +---------------------------------------------------+-------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 8192 | +---------------------------------------------------+-------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+-------------------------------------------------------------+ +---------------------------------------------------+-------------------------------------------------------------------+ | Name | FujitsuDA2Solver (Expert Mode) | +===================================================+===================================================================+ | Client class | :class:`~amplify.client.FujitsuDA2SolverExpertClient` | +---------------------------------------------------+-------------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDA2SolverExpertClientParameters` | +---------------------------------------------------+-------------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDA2SolverExpertClientResult` | +---------------------------------------------------+-------------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDA2SolverExpertClientResultTiming` | +---------------------------------------------------+-------------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+-------------------------------------------------------------------+ | Number of physical bits | 8192 | +---------------------------------------------------+-------------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 8192 | +---------------------------------------------------+-------------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+-------------------------------------------------------------------+ +---------------------------------------------------+---------------------------------------------------------------+ | Name | FujitsuDA2PTSolver | +===================================================+===============================================================+ | Client class | :class:`~amplify.client.FujitsuDA2PTSolverClient` | +---------------------------------------------------+---------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDA2PTSolverClientParameters` | +---------------------------------------------------+---------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDA2PTSolverClientResult` | +---------------------------------------------------+---------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDA2PTSolverClientResultTiming` | +---------------------------------------------------+---------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+---------------------------------------------------------------+ | Number of physical bits | 8192 | +---------------------------------------------------+---------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 8192 | +---------------------------------------------------+---------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+---------------------------------------------------------------+ +---------------------------------------------------+----------------------------------------------------------------------+ | Name | FujitsuDA2MixedModeSolver | +===================================================+======================================================================+ | Client class | :class:`~amplify.client.FujitsuDA2MixedModeSolverClient` | +---------------------------------------------------+----------------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDA2MixedModeSolverClientParameters` | +---------------------------------------------------+----------------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDA2MixedModeSolverClientResult` | +---------------------------------------------------+----------------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDA2MixedModeSolverClientResultTiming` | +---------------------------------------------------+----------------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+----------------------------------------------------------------------+ | Number of physical bits | 8192 | +---------------------------------------------------+----------------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 8192 | +---------------------------------------------------+----------------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+----------------------------------------------------------------------+ +---------------------------------------------------+-------------------------------------------------------------+ | Name | FujitsuDA3SolverClient | +===================================================+=============================================================+ | Client class | :class:`~amplify.client.FujitsuDA3SolverClient` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDA3SolverClientParameters` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDA3SolverClientResult` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDA3SolverClientResultTiming` | +---------------------------------------------------+-------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+-------------------------------------------------------------+ | Number of physical bits | 100000 | +---------------------------------------------------+-------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 100000 | +---------------------------------------------------+-------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+-------------------------------------------------------------+ +---------------------------------------------------+-------------------------------------------------------------+ | Name | FujitsuDA4SolverClient | +===================================================+=============================================================+ | Client class | :class:`~amplify.client.FujitsuDA4SolverClient` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.FujitsuDA4SolverClientParameters` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.FujitsuDA4SolverClientResult` | +---------------------------------------------------+-------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.FujitsuDA4SolverClientResultTiming` | +---------------------------------------------------+-------------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+-------------------------------------------------------------+ | Number of physical bits | 100000 | +---------------------------------------------------+-------------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 100000 | +---------------------------------------------------+-------------------------------------------------------------+ | API endpoint (default) | https://api.aispf.global.fujitsu.com/da/ | +---------------------------------------------------+-------------------------------------------------------------+ Attributes of Fujitsu Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`num_bits` - Get the maximum number of executable variables. * - :attr:`parameters` - Get the execution parameters. :raw-html:`
` :raw-html:`
` :FujitsuDASolver: :class:`~amplify.client.FujitsuDASolverClientParameters` :FujitsuDASolver (Expert Mode): :class:`~amplify.client.FujitsuDASolverExpertClientParameters` :FujitsuDAPTSolver: :class:`~amplify.client.FujitsuDAPTSolverClientParameters` :FujitsuDAMixedModeSolver: :class:`~amplify.client.FujitsuDAMixedModeSolverClientParameters` :FujitsuDA2Solver: :class:`~amplify.client.FujitsuDA2SolverClientParameters` :FujitsuDA2Solver (Expert Mode): :class:`~amplify.client.FujitsuDA2SolverExpertClientParameters` :FujitsuDA2PTSolver: :class:`~amplify.client.FujitsuDA2PTSolverClientParameters` :FujitsuDA2MixedModeSolver: :class:`~amplify.client.FujitsuDA2MixedModeSolverClientParameters` :FujitsuDA3Solver: :class:`~amplify.client.FujitsuDA3SolverClientParameters` :FujitsuDA4Solver: :class:`~amplify.client.FujitsuDA4SolverClientParameters` * - :attr:`url` - Get or set the API URL. * - :attr:`proxy` - Get or set the proxy server address. * - :attr:`token` - Get or set the API token. * - :attr:`write_request_data` - Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. * - :attr:`write_response_data` - Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. * - :attr:`version` - Get the API version string of the Fujitsu Digital Annealer. * - :attr:`~amplify.client.FujitsuDA3SolverClient.set_penalty_binary_polynomial` - Specify whether to use penalty quadratic polynomial for :class:`~amplify.client.FujitsuDA3SolverClient` / :class:`~amplify.client.FujitsuDA4SolverClient`. Defaults to ``True``. * - :attr:`~amplify.client.FujitsuDA3SolverClient.set_one_way_one_hot_groups` - Specify whether to use one-dimensional one-hot constraint information for :class:`~amplify.client.FujitsuDA3SolverClient` / :class:`~amplify.client.FujitsuDA4SolverClient`. Defaults to ``False``. * - :attr:`~amplify.client.FujitsuDA3SolverClient.set_two_way_one_hot_groups` - Specify whether to use two-dimensional one-hot constraint information for :class:`~amplify.client.FujitsuDA3SolverClient` / :class:`~amplify.client.FujitsuDA4SolverClient`. Defaults to ``False``. * - :attr:`~amplify.client.FujitsuDA3SolverClient.set_inequalities` - Specify whether to use linear inequality constraints for :class:`~amplify.client.FujitsuDA3SolverClient` / :class:`~amplify.client.FujitsuDA4SolverClient`. Defaults to ``True``. Example of Fujitsu Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **FujitsuDA2PTSolverClient** .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import FujitsuDA2PTSolverClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = FujitsuDA2PTSolverClient() client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" client.parameters.number_iterations = 1000 solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] .. note:: Please refer to the corresponding parts of the Schemes of `Digital Annealer API reference (QUBO API V2) `_ for details on the parameters of FujitsuDA and FujitsuDA2 clients. .. _client-fujitsu-da3: **FujitsuDA3SolverClient** .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import FujitsuDA3SolverClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = FujitsuDA3SolverClient() client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" client.parameters.time_limit_sec = 1 # Time limit is 1 second solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]', 'energy = 0.0, q = [1. 0. 0.]', 'energy = 0.0, q = [0. 1. 1.]', 'energy = 1.0, q = [0. 0. 0.]'] .. note:: Please refer to FujitsuDA3Solver Schemas of `Digital Annealer API reference (QUBO API V3) `_ for details of :class:`~amplify.client.FujitsuDA3SolverClient` parameters. .. _client-fujitsu-da4: **FujitsuDA4SolverClient** .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import FujitsuDA4SolverClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = FujitsuDA4SolverClient() client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" client.parameters.time_limit_sec = 1 # Time limit is 1 second solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]', 'energy = 0.0, q = [1. 0. 0.]', 'energy = 0.0, q = [0. 1. 1.]', 'energy = 1.0, q = [0. 0. 0.]'] .. note:: Please refer to FujitsuDA4Solver Schemas of `Digital Annealer API reference (QUBO API V4) `_ for details of :class:`~amplify.client.FujitsuDA4SolverClient` parameters. .. _client-toshiba: Toshiba ------- Toshiba Client Class ^^^^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`Toshiba client reference ` for more information. +---------------------------------------------------+----------------------------------------------------+ | Name | Toshiba SQBM+ | +===================================================+====================================================+ | Client class | :class:`~amplify.client.ToshibaClient` | +---------------------------------------------------+----------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.ToshibaClientParameters` | +---------------------------------------------------+----------------------------------------------------+ | Execution result class | :class:`~amplify.client.ToshibaClientResult` | +---------------------------------------------------+----------------------------------------------------+ | Execution time class | :class:`~amplify.client.ToshibaClientResultTiming` | +---------------------------------------------------+----------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+----------------------------------------------------+ | Number of physical bits | 100000 | +---------------------------------------------------+----------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 100000 | +---------------------------------------------------+----------------------------------------------------+ | API endpoint (default) | N/A | +---------------------------------------------------+----------------------------------------------------+ +---------------------------------------------------+---------------------------------------------------------+ | Name | Toshiba SQBM+ (version 2.0.0 ~) | +===================================================+=========================================================+ | Client class | :class:`~amplify.client.ToshibaSQBM2Client` | +---------------------------------------------------+---------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.ToshibaSQBM2ClientParameters` | +---------------------------------------------------+---------------------------------------------------------+ | Execution result class | :class:`~amplify.client.ToshibaSQBM2ClientResult` | +---------------------------------------------------+---------------------------------------------------------+ | Execution time class | :class:`~amplify.client.ToshibaSQBM2ClientResultTiming` | +---------------------------------------------------+---------------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+---------------------------------------------------------+ | Number of physical bits | 100000 | +---------------------------------------------------+---------------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 100000 | +---------------------------------------------------+---------------------------------------------------------+ | API endpoint (default) | N/A | +---------------------------------------------------+---------------------------------------------------------+ Attributes of Toshiba Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.ToshibaClient.num_bits` - Get the maximum number of executable variables. * - :attr:`~amplify.client.ToshibaClient.parameters` - Get the execution parameters. * - :attr:`~amplify.client.ToshibaClient.url` - Get or set the API URL. * - :attr:`~amplify.client.ToshibaClient.proxy` - Get or set the proxy server address. * - :attr:`~amplify.client.ToshibaClient.token` - Get or set the API token. * - :attr:`~amplify.client.ToshibaClient.write_request_data` - Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. * - :attr:`~amplify.client.ToshibaClient.write_response_data` - Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. * - :attr:`~amplify.client.ToshibaClient.version` - Get the API version string of the Toshiba SBM/SQBM+. Attributes of ToshibaSQBM2Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Attributes that are only available in ToshibaSQBM2Client are as follows. .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.ToshibaSQBM2Client.request_data_type` - Get or set the request data format. Two types of data types are supported. ``'HDF5'`` and ``'MatrixMarket'``. Default is ``'HDF5'``. Example of Toshiba Client ^^^^^^^^^^^^^^^^^^^^^^^^^^ **ToshibaClient** .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import ToshibaClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = ToshibaClient() client.url = "http://xxx.xxx.xxx.xxx:xxxx/" client.parameters.loops = 0 # not specify the number of loops (only timeout will be used) client.parameters.timeout = 1 # Timeout is 1 second solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] .. note:: Please refer to `Simulated Bifurcation Machine (SBM) User Manual `_ for details of Toshiba SBM. .. _client-toshiba-sqbm2: **ToshibaSQBM2Client** .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import ToshibaSQBM2Client gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = ToshibaSQBM2Client() client.url = "http://xxx.xxx.xxx.xxx:xxxx/" client.parameters.loops = 0 # not specify the number of loops (only timeout will be used) client.parameters.timeout = 1 # timeout 1 second solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] .. _client-hitachi: Hitachi ------- Hitachi Client Class ^^^^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`Hitachi client reference ` for more information. +---------------------------------------------------+----------------------------------------------------+ | Name | Hitachi CMOS annealing machine (type 4: GPU) | +===================================================+====================================================+ | Client class | :class:`~amplify.client.HitachiClient` | +---------------------------------------------------+----------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.HitachiClientParameters` | +---------------------------------------------------+----------------------------------------------------+ | Execution result class | :class:`~amplify.client.HitachiClientResult` | +---------------------------------------------------+----------------------------------------------------+ | Execution time class | :class:`~amplify.client.HitachiClientResultTiming` | +---------------------------------------------------+----------------------------------------------------+ | Physical graph | King Graph | +---------------------------------------------------+----------------------------------------------------+ | Number of physical bits | 262144 (512x512) | +---------------------------------------------------+----------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 512 | +---------------------------------------------------+----------------------------------------------------+ | API endpoint (default) | https://annealing−cloud.com/api/v2/ | +---------------------------------------------------+----------------------------------------------------+ Attributes of Hitachi Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.HitachiClient.num_bits` - Get the maximum number of executable variables. * - :attr:`~amplify.client.HitachiClient.parameters` - Get the execution parameters :class:`~amplify.client.HitachiClientParameters`. * - :attr:`~amplify.client.HitachiClient.url` - Get or set the API URL. * - :attr:`~amplify.client.HitachiClient.proxy` - Get or set the proxy server address. * - :attr:`~amplify.client.HitachiClient.token` - Get or set the API token. * - :attr:`~amplify.client.HitachiClient.write_request_data` - Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. * - :attr:`~amplify.client.HitachiClient.write_response_data` - Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. * - :attr:`~amplify.client.HitachiClient.version` - Get the API version string of the Hitachi CMOS annealing machine. Example of Hitachi Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **HitachiClient** .. code-block:: python from amplify import BinaryPoly, gen_symbols, Solver from amplify.client import HitachiClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = HitachiClient() client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" client.parameters.temperature_num_steps = 10 client.parameters.temperature_step_length = 100 client.parameters.temperature_initial = 100.0 client.parameters.temperature_target = 0.02 solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] .. note:: Please refer to `API reference V2 `_ for details of Hitachi CMOS annealing machine. .. _client-ntt-hiroshima: Hiroshima Univ. / NTT DATA -------------------------- ABS Client Class ^^^^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`ABS client reference ` for details. +---------------------------------------------------+-------------------------------------------------+ | Name | ABS QUBO Solver | +===================================================+=================================================+ | Client Class | :class:`~amplify.client.ABSClient` | +---------------------------------------------------+-------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.ABSClientParameters` | +---------------------------------------------------+-------------------------------------------------+ | Execution result class | :class:`~amplify.client.ABSClientResult` | +---------------------------------------------------+-------------------------------------------------+ | Execution time class | :class:`~amplify.client.ABSClientResultTiming` | +---------------------------------------------------+-------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+-------------------------------------------------+ | Number of physical bits | 32768 | +---------------------------------------------------+-------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 32768 | +---------------------------------------------------+-------------------------------------------------+ | API URL (default) | https://qubosolver.cs.hiroshima-u.ac.jp | +---------------------------------------------------+-------------------------------------------------+ Attributes of ABS Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.ABSClient.num_bits` - Get the maximum number of executable variables. * - :attr:`~amplify.client.ABSClient.parameters` - Get the execution parameters :class:`~amplify.client.ABSClientParameters` * - :attr:`~amplify.client.ABSClient.url` - Get or set the API URL * - :attr:`~amplify.client.ABSClient.proxy` - Get or set the proxy server address. * - :attr:`~amplify.client.ABSClient.user_name` - Get or set the user ID * - :attr:`~amplify.client.ABSClient.password` - Get or set the password * - :attr:`~amplify.client.FixstarsClient.write_request_data` - Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. * - :attr:`~amplify.client.FixstarsClient.write_response_data` - Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. * - :attr:`~amplify.client.ABSClient.version` - Get the version string of the ABS QUBO solver client. Example of ABS Client ^^^^^^^^^^^^^^^^^^^^^^^^ **ABSClient** .. code-block:: python from amplify import BinaryPoly, gen_symbols, Solver from amplify.client import ABSClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = ABSClient() client.user_name = "xxxx" client.password = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" client.parameters.timeout = 10 client.parameters.word_size = 16 client.parameters.arithmetic_precision = 32 solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] .. note:: Please refer to ``_ for details of ABS QUBO Solver. .. _client-gurobi: Gurobi ------ .. note:: To make use of Gurobi Client, the software and the license of Gurobi must be installed properly on your computer. Gurobi Client Class ^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`gurobi client reference ` for details. +---------------------------+---------------------------------------------------+ | Name | Gurobi Optimizer | +===========================+===================================================+ | Client Class | :class:`~amplify.client.GurobiClient` | +---------------------------+---------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.GurobiClientParameters` | +---------------------------+---------------------------------------------------+ | Execution result class | :class:`~amplify.client.GurobiClientResult` | +---------------------------+---------------------------------------------------+ | Execution time class | :class:`~amplify.client.GurobiClientResultTiming` | +---------------------------+---------------------------------------------------+ Attributes of Gurobi Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.GurobiClient.num_bits` - Get the maximum number of executable variables. * - :attr:`~amplify.client.GurobiClient.parameters` - Get the execution parameters :class:`~amplify.client.GurobiClientParameters` * - :attr:`~amplify.client.GurobiClient.gurobi_path` - Get or set the path to the dynamic library of Gurobi. * - :attr:`~amplify.client.GurobiClient.write_model` - Get or set the filepath where to save the model data input to Gurobi. Defaults to an empty string and the model data will not be saved. The valid file extensions are ``.mps``, ``.rew``, ``.lp``, and ``.rlp``. If the model is LP, ``.dua`` and ``.dlp`` files are also valid to output the dual problem. * - :attr:`~amplify.client.GurobiClient.write_solution` - Get or set the filepath where to save the solution output by Gurobi. Defaults to an empty string and the model data will not be saved. The valid file extensions are ``.sol`` and ``.json``. * - :attr:`~amplify.client.GurobiClient.version` - Get the version string of the Gurobi dynamic library. Example of Gurobi Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^ **GurobiClient** .. code-block:: python from amplify import BinaryPoly, gen_symbols, Solver from amplify.client import GurobiClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = GurobiClient() client.parameters.time_limit = 10 solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] .. note:: Please refer to `documents `_ for details of Gurobi Optimizer. .. _client-qiskit: IBM Qiskit ---------- Run `QAOA `_ with IBM Quantum or its simulator using Qiskit. .. note:: To use an actual quantum computer with Qiskit Client, make sure to obtain API token of `IBM Quantum `_ in advance. .. note:: To use the Qiskit client, `amplify.qaoa `_ package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows: .. code-block:: bash $ pip install amplify[extra] Qiskit Client Class ^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`qiskit client reference ` for details. +---------------------------+-------------------------------------------------------------+ | Name | Qiskit Classes | +===========================+=============================================================+ | Client Class | :class:`~amplify.client.QiskitClient` | +---------------------------+-------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.QiskitClientParameters` | +---------------------------+-------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.QiskitClientResult` | +---------------------------+-------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.QiskitClientResultTiming` | +---------------------------+-------------------------------------------------------------+ Attributes of Qiskit Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.QiskitClient.num_bits` - Get the maximum number of executable variables. * - :attr:`~amplify.client.QiskitClient.device` - Get or set the environment ("CPU", "GPU", "QPU") in which QAOA will run. * - :attr:`~amplify.client.QiskitClient.token` - Get or set the API token to connect to IBM Quantum. * - :attr:`~amplify.client.QiskitClient.backend` - Get or set the machine name (or simulation method name) on which QAOA will run * - :attr:`~amplify.client.QiskitClient.parameters` - Get the QAOA execution parameters :class:`~amplify.client.QiskitClientParameters` * - :attr:`~amplify.client.GurobiClient.version` - Get the version string of the ampllify.qaoa library. .. note:: To run a simulation using a GPU, the ``qiskit-aer`` package needs to be uninstalled and replaced with the ``qiskit-aer-gpu`` package, as follows: .. code-block:: console $ pip uninstall qiskit-aer $ pip install qiskit-aer-gpu Example of QiskitClient ^^^^^^^^^^^^^^^^^^^^^^^ Real quantum devices ~~~~~~~~~~~~~~~~~~~~ .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import QiskitClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = QiskitClient() client.device = "QPU" # Set "QPU" to use a real quantum device client.token = "xxxxxxxx" # API token is required to use a real quantum device # Set the machine name: If not specified, a "least busy" machine that # satisfies the required number of bits for execution is automatically selected. client.backend = "ibmq_bogota" # Settings of QAOA parameters client.parameters.reps = 10 # Depth of the circuit client.parameters.shots = 1024 # Number of samples client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result] ['energy = -1.0, q = [1. 0. 1.], frequency = 216', 'energy = 0.0, q = [0. 0. 1.], frequency = 56', 'energy = 0.0, q = [0. 1. 1.], frequency = 188', 'energy = 0.0, q = [1. 0. 0.], frequency = 235', 'energy = 1.0, q = [0. 1. 0.], frequency = 199', 'energy = 1.0, q = [1. 1. 1.], frequency = 41', 'energy = 1.0, q = [0. 0. 0.], frequency = 62', 'energy = 2.0, q = [1. 1. 0.], frequency = 27'] .. note:: Please refer to :class:`~amplify.client.QiskitClientParameters` for QAOA parameters in details. Ideal quantum circuit simulators ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python from amplify import BinaryPoly, BinarySymbolGenerator, Solver from amplify.client import QiskitClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = QiskitClient() client.device = "CPU" # Set "CPU" or "GPU" for simulations client.backend = "statevector" # Set the simulation method # Settings of QAOA parameters client.parameters.reps = 10 # Depth of the circuit client.parameters.shots = 1024 # Number of samples client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result] ['energy = -1.0, q = [1. 0. 1.], frequency = 250', 'energy = 0.0, q = [0. 1. 1.], frequency = 246', 'energy = 0.0, q = [1. 0. 0.], frequency = 250', 'energy = 1.0, q = [0. 1. 0.], frequency = 278'] .. note:: Please refer to `Qiskit document `_ for simulator method names. Simulators that mimic real machines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python from amplify import BinaryPoly, BinarySymbolGenerator, Solver from amplify.client import QiskitClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = QiskitClient() client.device = "CPU" # Set "CPU" or "GPU" for simulations client.token = "xxxxxxxx" # API token is required to use a real quantum device # Set the machine name: If not specified, a "least busy" machine that # satisfies the required number of bits for execution is automatically selected. client.backend = "ibmq_bogota" # Settings of QAOA parameters client.parameters.reps = 10 # Depth of the circuit client.parameters.shots = 1024 # Number of samples client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result] ['energy = -1.0, q = [1. 0. 1.], frequency = 250', 'energy = 0.0, q = [0. 1. 1.], frequency = 246', 'energy = 0.0, q = [1. 0. 0.], frequency = 250', 'energy = 1.0, q = [0. 1. 0.], frequency = 278'] Qulacs ------ Run `QAOA `_ with quantum simulator `Qulacs `_. .. note:: To use the Qulacs client, `amplify.qaoa `_ package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows: .. code-block:: bash $ pip install amplify[extra] Qulacs Client Class ^^^^^^^^^^^^^^^^^^^ Please refer to :ref:`qulacs client reference ` for details. +---------------------------+-------------------------------------------------------------+ | Name | Qulacs Classes | +===========================+=============================================================+ | Client Class | :class:`~amplify.client.QulacsClient` | +---------------------------+-------------------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.QulacsClientParameters` | +---------------------------+-------------------------------------------------------------+ | Execution result class | :class:`~amplify.client.QulacsClientResult` | +---------------------------+-------------------------------------------------------------+ | Execution time class | :class:`~amplify.client.QulacsClientResultTiming` | +---------------------------+-------------------------------------------------------------+ Attributes of Qulacs Client ^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.QulacsClient.num_bits` - Get the maximum number of executable variables. * - :attr:`~amplify.client.QulacsClient.parameters` - Get the QAOA execution parameters :class:`~amplify.client.QulacsClientParameters` * - :attr:`~amplify.client.QulacsClient.version` - Get the version string of the ampllify.qaoa library. Example of QulacsClient ^^^^^^^^^^^^^^^^^^^^^^^ **QulacsClient** .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import QulacsClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = QulacsClient() # Settings of QAOA parameters client.parameters.reps = 10 # Depth of the circuit client.parameters.shots = 1024 # Number of samples client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result] ['energy = -1.0, q = [1. 0. 1.], frequency = 0', 'energy = 0.0, q = [0. 0. 1.], frequency = 0', 'energy = 0.0, q = [0. 1. 1.], frequency = 30', 'energy = 0.0, q = [1. 0. 0.], frequency = 0', 'energy = 1.0, q = [0. 0. 0.], frequency = 2', 'energy = 1.0, q = [0. 1. 0.], frequency = 988', 'energy = 1.0, q = [1. 1. 1.], frequency = 0', 'energy = 2.0, q = [1. 1. 0.], frequency = 2'] .. _client-nec: NEC --- NEC Client Class ^^^^^^^^^^^^^^^^ Please refer to the user manual of the NEC Vector Annealing Service for more information. +---------------------------------------------------+------------------------------------------------+ | Name | NEC Vector Annealing Service | +===================================================+================================================+ | Client class | :class:`~amplify.client.NECClient` | +---------------------------------------------------+------------------------------------------------+ | Execution parameter class | :class:`~amplify.client.NECClientParameters` | +---------------------------------------------------+------------------------------------------------+ | Execution result class | :class:`~amplify.client.NECClientResult` | +---------------------------------------------------+------------------------------------------------+ | Execution time class | :class:`~amplify.client.NECClientResultTiming` | +---------------------------------------------------+------------------------------------------------+ | Physical graph | Fully connected coupling | +---------------------------------------------------+------------------------------------------------+ | Number of physical bits | 300000 | +---------------------------------------------------+------------------------------------------------+ | Number of logical bits (Fully connected coupling) | 300000 | +---------------------------------------------------+------------------------------------------------+ Attributes of NEC Client Class ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :widths: 15 30 :header-rows: 1 * - Name - Description * - :attr:`~amplify.client.NECClient.num_bits` - Get the maximum number of executable variables. * - :attr:`~amplify.client.NECClient.parameters` - Get the execution parameters :class:`~amplify.client.NECClientParameters`. * - :attr:`~amplify.client.NECClient.version` - Get the version string of the NEC Vector Annealing Service. * - :attr:`~amplify.client.NECClient.proxy` - Get or set the proxy server address. * - :attr:`~amplify.client.NECClient.token` - Get or set the API token. * - :attr:`~amplify.client.NECClient.set_onehot` - Specifies whether to set the onhot constraint parameter of VA. Defaults to ``False``. * - :attr:`~amplify.client.NECClient.set_andzero` - Specifies whether to set the andzero constraint parameter of VA. Defaults to ``False``. * - :attr:`~amplify.client.NECClient.set_orone` - Specifies whether to set the orone constraint parameter of VA. Defaults to ``False``. * - :attr:`~amplify.client.NECClient.set_maxone` - Specifies whether to set the maxone constraint parameter of VA. Defaults to ``False``. * - :attr:`~amplify.client.NECClient.set_minmaxone` - Specifies whether to set the minmaxone constraint parameter of VA. Defaults to ``False``. * - :attr:`~amplify.client.NECClient.write_request_data` - Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. * - :attr:`~amplify.client.NECClient.write_response_data` - Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. Example of NEC Client ^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python from amplify import BinarySymbolGenerator, Solver from amplify.client import NECClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 client = NECClient() client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" client.parameters.num_sweeps = 500 solver = Solver(client) result = solver.solve(f) >>> f 2 q_0 q_1 - q_0 - q_2 + 1 >>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result] ['energy = -1.0, q = [1. 0. 1.]'] .. _physical_model_solver: Physical Model Solver ---------------------- It is recommended to use a client class as the driver of the solver class for typical usage, but the client class can also be used as a solver for the physical model. .. note:: This function is intended for direct operation of each machine or for debugging purposes. All clients have :meth:`~amplify.client.FixstarsClient.solve` method. The followings are possible inputs. For matrix object input, the second argument corresponds to the constant term. * solve(:class:`~amplify.BinaryPoly`) * solve(:class:`~amplify.IsingPoly`) * solve(:class:`~amplify.BinaryIntPoly`) * solve(:class:`~amplify.IsingIntPoly`) * solve(:class:`~amplify.BinaryMatrix`, :class:`float` = ``0.0``) * solve(:class:`~amplify.IsingMatrix`, :class:`int` = ``0.0``) * solve(:class:`~amplify.BinaryIntMatrix` :class:`float` = ``0``) * solve(:class:`~amplify.IsingIntMatrix`, :class:`int` = ``0``) Possible input polynomials must be quadratic, and variable indices and interactions must match the specifications of each machine. The model needs to be a physical model, and the interactions between variables need to be consistent with the graph based on the hardware specifications. Depending on the graph, there may be restrictions on the interactions between variables. .. note:: Please refer to `D-Wave System Documentation `_ D-Wave machine's QPU topology. .. note:: Although Hitachi CMOS annealing machine is `specified by two-dimensional indices `_, Amplify SDK uses one-dimensional indices. Regarding to the coordinates of the King's graph :math:`x`, :math:`y`, note that one-dimensional variable index :math:`i = L x + y` is given. Here, :math:`L = 512` represents the length of one side of the King's graph. :meth:`~amplify.client.FixstarsClient.solve` method returns ``ClientResult`` class object, which is specific to the client in use. ``ClientResult`` class has the following common attributes. ``optional`` is provided only for some clients. * :attr:`~amplify.client.FixstarsClientResult.execution_parameters` (optional) : Get the execution parameters. * :attr:`~amplify.client.FixstarsClientResult.timing` : Get the execution time object. * :attr:`~amplify.client.FixstarsClientResult.solutions` : Get the list of the execution results. Each element has the following attributes: * :attr:`~amplify.client.ClientSolution.energy` : Get the energy value (evaluated value of physical model). * :attr:`~amplify.client.ClientSolution.values` : Get the list of the values of physical variables. * :attr:`~amplify.client.ClientSolution.frequency` : Get the number of identical solutions.