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: object

Returns 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.

Note

For all solver attributes, if None is available, it means it is not set. The Amplify SDK does not set or add the attributes to None for the query data. This procedure is to force the solver to use default values.

Solver information:
acceptable_degrees: amplify.AcceptableDegrees

Retrieves the degree of the problem that the solver can handle. See “Variable Conversion and Degree Reduction” for details.

version: str

Retrieves 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: Graph

Obtains the solver-specific graph structure. See “Graph Embedding” for details.

WEB API Connection setting ☁️ Cloud:
url: str

Gets and sets the solver endpoint URL.

token: str

Gets and sets the authentication information such as API token.

proxy: str

Gets 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.PathLike

Specifies the file path of the solver library.

Save sent and received data ☁️ Cloud 💻 Local:
write_request_data: os.PathLike

Saves the query data sent to the solver to the specified file path. Data format varies by solver.

write_response_data: os.PathLike

Saves 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 (Constraint or ConstraintList) argument, or both, depending on what is available to the solver API. However, unlike the global solve() 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 (FixstarsClient), it is an instance of the class amplify.FixstarsClient.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

amplify.Result.client_result

Client.Result

Result of solver client execution (response data)

amplify.Result.execution_time

datetime.timedelta

Solver internal execution time

amplify.Result.response_time

datetime.timedelta

Solver response time