amplify.client.ToshibaSQBM2Client

class ToshibaSQBM2Client

A class for using the Toshiba SQBM+ client in Fixstars Amplify SDK.

__init__(self: amplify.client.ToshibaSQBM2Client, token: str = '', url: str = '', proxy: str = '') None

Methods

__init__(self[, token, url, proxy])

solve(*args, **kwargs)

Solves a given polynomial or matrix model.

Attributes

num_bits

The maximum number of available variables.

parameters

The parameters of the Toshiba SQBM+ client in Fixstars Amplify SDK.

proxy

Set or get the address of proxy server.

request_data_type

Set or get the request data format.

solver

Set or get the type of solver used for solving.

token

Set or get the API token of the SQBM+ instance.

url

URL address of the SQBM+ instance.

version

Get the API version string of the Toshiba SQBM+.

write_request_data

Set or get the file path to save request data.

write_response_data

Set or get the file path to save request data.

property num_bits

The maximum number of available variables.

Type:

int

property parameters

The parameters of the Toshiba SQBM+ client in Fixstars Amplify SDK.

Type:

ToshibaSQBM2ClientParameters

property proxy

Set or get the address of proxy server.

Type:

str

property request_data_type

Set or get the request data format. Two types of data types are supported. 'HDF5' and 'MatrixMarket'’. Default is 'HDF5'.

type:

str

Note

When using 'HDF5', the output data by the write_request_data property is also binary data in HDF5 format. When using “MatrixMarket”, the output data is text format.

Note

If input containing linear constraints is given, the request is uniformly in HDF5 format. The specified value of request_data_type is ignored.

Example

from amplify import BinarySymbolGenerator
from amplify.client import ToshibaSQBM2Client

client = ToshibaSQBM2Client(token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)

client.request_data_type = "HDF5"  # Default value
client.write_request_data = "request_data.h5"

client.request_data_type = "MatrixMarket"
client.write_request_data = "request_data.txt"
solve(*args, **kwargs)

Solves a given polynomial or matrix model.

Overloads::

  • solve(poly)
  • solve(matrix, constant)
Parameters:
Returns:

A result class that provides information about execution.

Return type:

ToshibaSqbm2ClientResult

Example

from amplify import BinarySymbolGenerator
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://xx.xxx.xxx.xx:xxxx/"
client.parameters.timeout = 1  # timeout 1 second

result = client.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.]']
property solver

Set or get the type of solver used for solving. Three types are supported. 'auto', 'qubo' and 'qplib'. Default is 'auto'.

type:

str

Note

When using 'auto', the solver type is automatically selected according to the input model. If the input model contains linear constraints, the solver type is automatically set to 'qplib', otherwise it is set to 'qubo'. If you want to fix the solver regardless of input model, specify either 'qubo' or 'qplib'’.

Example

from amplify import BinarySymbolGenerator
from amplify.client import ToshibaSQBM2Client

client = ToshibaSQBM2Client(token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
client.solver = "qubo"
property token

Set or get the API token of the SQBM+ instance.

Type:

str

property url

URL address of the SQBM+ instance.

Type:

str

property version

Get the API version string of the Toshiba SQBM+.

Type:

str

property write_request_data

Set or get the file path to save request data. The default value is an empty string, so saving is disabled.

Type:

str

property write_response_data

Set or get the file path to save request data. The default value is an empty string, so saving is disabled.

Type:

str