amplify.Solver

class Solver

A class that provides an interface for solving input and logical models with a specified client. The solver class abstracts the hardware specifications of the Ising machines and provides an interface that integrates the differences among various Ising machine clients.

注釈

Acceptable clients are described in the references

__init__(client=None)

Constructor

パラメータ:
  • client (client, optional) -- Client object. Defaults to None.

  • chain_strength (float/optional) -- A parameter for controlling the quadratic interactions within the connected physical bits of a given solver for forming chains. It is set to 1.0 by default.

Example

from amplify import BinarySymbolGenerator, Solver
from amplify.client import FixstarsClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] * q[2] - q[0] * q[1] + q[2] + 1

client = FixstarsClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.timeout = 1000  # timeout 1second

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 q_2 - q_0 q_1 + q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = 0.0, q = [1. 1. 0.]']

Methods

__init__([client])

Constructor

solve(*args, **kwargs)

Solve a given input or logical model.

Attributes

chain_strength

A parameter for controlling the quadratic interactions within the connected physical bits of a given solver for forming chains.

client

A client class of Amplify SDK.

client_result

Gives the result class of the physical model, returned by the client used as the driver for the solver class.

deduplicate

Boolean value that specifies whether to output identical solutions found in the calculation.

embedding_time_limit

execution_time

The execution time in the most recent job, measured in milliseconds.

filter_solution

Boolean value that specifies whether the solutions are filtered based on given constraints.

logical_result

Gives the result class of the logical model.

sort_solution

Boolean value that specify whether the output solutions are sorted in order of best solution first.

property chain_strength

A parameter for controlling the quadratic interactions within the connected physical bits of a given solver for forming chains. Set to 1.0 by default.

Type:

float

property client

A client class of Amplify SDK. Select one client class from reference of clients.

property client_result

Gives the result class of the physical model, returned by the client used as the driver for the solver class. For more details, see the result class of the client used for the driver. For example, FixstarsClientResult if Amplify Annealing Engine client is used.

property deduplicate

Boolean value that specifies whether to output identical solutions found in the calculation. When set to True, only one of multiple identical solutions will be output. When set to False, all of multiple identical solutions will be output. Set to True by default.

Type:

bool

property execution_time

The execution time in the most recent job, measured in milliseconds.

Type:

int

property filter_solution

Boolean value that specifies whether the solutions are filtered based on given constraints. Set to True by default. If set to False, the solutions that do not satisfy the constraint condtions will also be output.

Type:

bool

property logical_result

Gives the result class of the logical model. The result of the logical model is the one before the filtering based on constraints.

Type:

LogicalResult

solve(*args, **kwargs)

Solve a given input or logical model.

Overloads:

  • solve(model)

  • solve(poly)

  • solve(matrix, constant)

  • solve(constraint)

パラメータ:
戻り値:

Solver's result class whose type is depending on the client. See Client for each client's ClientResult class for further details.

戻り値の型:

SolverResult

property sort_solution

Boolean value that specify whether the output solutions are sorted in order of best solution first. Set to True by default. If set to False, solutions are output in the order given by the Ising machine used as the driver.

Type:

bool