6. Solver Client¶
To run a solver from the Amplify SDK, you must create a solver client that abstracts each solver and specifies the connection point, API token, and execution parameters. The solver client also contains information about the solver’s capabilities, such as the types of variables, constraints, degree, and so on that it can handle. Amplify SDK uses this information to perform model conversions automatically, such as variable conversions, degree reduction, constraint implementation, and embedding in hardware topology.
6.1. Configuring solver client¶
Using the Amplify Annealing Engine (AE) as an example, let’s create the AmplifyAEClient client as follows.
from amplify import AmplifyAEClient
client = AmplifyAEClient()
Tip
Amplify AE provides a free API token when you register as a user.
Most parameters of the client class are initialized (or unset) with the solver’s default values after construction, so you can use them immediately after setting the required parameters for each client. The required parameters vary from client to client, but you must set an API token in the token attribute for most cloud solvers.
client.token = "YOUR_API_TOKEN"
For all clients, the solver’s execution parameters are retrieved and set to attributes in the parameters property. Because the setting items are as consistent as possible with the solver API, see the reference for each solver below for details.
For example, in Amplify AE, you can set the execution time as follows.
from datetime import timedelta
client.parameters.time_limit_ms = timedelta(milliseconds=1000) # 1000 milliseconds
Tip
Because each client has a different time unit and time format for time-related parameters, the Amplify SDK uses the datetime module for input and output.
The Amplify SDK can print parameters set in the client class as strings using the str or print() function.
>>> print(client)
{"url":"https://optigan.fixstars.com","token":"YOUR_API_TOKEN","compression":true,"solver":"Constraint","parameters":{"time_limit_ms":1000.0}}
Setting some parameters to None means they are unset, i.e., using the solver defaults.
client.parameters.time_limit_ms = None # reset to solver defaults
6.2. List of solver clients¶
The Amplify SDK supports the following solver clients.
PCBO-4th PUBO-4th QUBO GPU ☁️ Cloud
QUBO Ising QPU ☁️ Cloud Pegasus Graph Zephyr Graph
QUBO Ising Hybrid ☁️ Cloud
MIP QUBO Hybrid ☁️ Cloud
QUBO GPU ☁️ Cloud
QUBO GPU ☁️ Cloud
QUBO PUBO-4th Other GPU
QUBO VE ☁️ Cloud
Ising GPU ☁️ Cloud King Graph
MIP CPU 💻 Local
- PCBO-Nth PUBO-Nth QUBO Ising MIP Other
These represent the types of problems that the solver can directly handle.
PCBO-Nth This solver can handle objective functions and constraints that are \(N\)-th order polynomials in binary variables.
PUBO-Nth This solver can solve objective functions that are \(N\)-th order polynomials in binary variables. It cannot handle constraints.
QUBO This solver can solve for the objective function of a quadratic polynomial in binary variables. It cannot directly handle constraints, but some solvers support the input of equality and inequality constraints.
Ising This solver can solve for the objective function of a quadratic polynomial in an Ising variable. It cannot directly handle constraints, but some solvers support the input of equality and inequality constraints.
MIP This solver can solve mixed integer programming problems. It can directly handle binary, integer, and real variables. It generally targets first-order problems (linear programming problems), but some solvers can handle second-order problems, including QUBO.
Other This solver can handle problem formats other than those listed above.
Note
The Amplify SDK automatically performs transformations such as variable conversion, degree reduction, and constraint penalty function generation for problems the solver cannot handle directly. Therefore, users do not necessarily need to create problems in a format the solver can address directly. However, depending on the type of solver and the type of model input, it may not be supported or formulated accurately. See Model Conversions for more information.
- Graph
This represents a quadratic term that you can pass to the solver. Solvers without these tags have no restrictions on quadratic terms. Other solvers have restrictions on the quadratic terms in the input model and require an operation called graph embedding to solve arbitrary quadratic polynomials. The problem size the solvers can handle is about \(O\left( \sqrt N \right)\) in the worst case for \(N\) variables the solver can take. See “Graph Embedding” for details.
- CPU GPU VE QPU Hybrid
This indicates the type of computing device the machine is running on; VE indicates NEC SX-Aurora TSUBASA Vector Engine, and Hybrid indicates that the solver is a hybrid of QPU and other technologies.
- ☁️ Cloud 💻 Local
This indicates whether the solver is provided as a cloud service or must be installed on the user’s machine.