Client details¶
The Amplify SDK provides client classes for the solvers that you can run from the SDK. The client classes wrap each solver’s API and provide an interface for configuring the solver and setting execution parameters and methods for requesting the API.
Solvers are available in various formats, including WEB API, executable files, and library APIs, but can be handled consistently through the solver client classes of the Amplify SDK. In addition, the Amplify SDK uses a common interface in the client class to allow abstraction of solver execution and analysis of results, in addition to model transformation and graph embedding processes.
This page describes the common interfaces provided by the solver clients, and we describe the functions and features specific to each solver client in their respective subpages.
Client class¶
The client class provides the following three general types of interfaces.
Setting solver execution parameters.
Retrieving client settings and solver information.
Calling solver-provided APIs
The common interface for the solver clients is as follows. Interfaces that are only valid for some solvers are classified by the tag assigned to each solver in the list of solver clients. For solver-specific interfaces, see the subpage for each solver.
- Execution parameters:
parameters:objectReturns a parameter class for retrieving and setting the solver execution parameters.
The type of parameter class varies from solver to solver but is designed to retrieve and set all possible execution parameters. For more parameter information, see the individual solver subpages and the solver API reference.
- Solver information:
acceptable_degrees:amplify.AcceptableDegreesRetrieves the degree of the problem that the solver can handle. See “Variable Conversion and Degree Reduction” for details.
version:strRetrieves the solver version information.
For remote solvers, you may need to set a token to use this interface since the API may be queried. For local solvers, this retrieves the version information for the executable or library.
- Quadratic polynomial graph structure Graph:
graph:GraphObtains the solver-specific graph structure. See “Graph Embedding” for details.
- WEB API Connection setting ☁️ Cloud:
url:strGets and sets the solver endpoint URL.
token:strGets and sets the authentication information such as API token.
proxy:strGets and sets a proxy server to use for the connection. See “Proxy Server Settings” for details.
- Path to executable file and library 💻 Local:
library_path:os.PathLikeSpecifies the file path of the solver library.
- Save sent and received data ☁️ Cloud 💻 Local:
write_request_data:os.PathLikeSaves the query data sent to the solver to the specified file path. Data format varies by solver.
write_response_data:os.PathLikeSaves the response data received from the solver to the specified file path. The data format is different for each solver.
- Solver execution:
solve(...):The
solve(...)method is implemented in each solver client as a function to execute the solver. This is a wrapper function for the solver API.Note
Usually, the user does not need to call this method directly. Use the
solve()function instead.The API can be called with a polynomial (
Poly), matrix (Matrix), or constraint (ConstraintorConstraintList) argument, or both, depending on what is available to the solver API. However, unlike the globalsolve()function, no model transformation or graph embedding is performed. Therefore, if a variable type, order, or constraint condition is given that the solver cannot handle, an exception will be thrown.The return type of the
solve(...)method is different for each solver. For example, in the case of Amplify AE (AmplifyAEClient), it is an instance of the classamplify.AmplifyAEClient.Result. This class is classified so that the data structure of the response data returned by the solver is modified as little as possible.
Interaction with solve() function¶
After performing the model conversion and graph embedding, the solve() function calls the solver client’s solve(...) method to execute the solver and analyze the returned data to obtain information about the solution and execution time.
The instance of the Result class returned by the solve() function stores the data returned by the solver, the response time, and the execution time in the following attributes.
Attribute |
Data type |
Details |
|---|---|---|
|
Result of solver client execution (response data) |
|
Solver internal execution time |
||
Solver response time |