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 toNone
.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
A parameter for controlling the quadratic interactions within the connected physical bits of a given solver for forming chains.
A client class of Amplify SDK.
Gives the result class of the physical model, returned by the client used as the driver for the solver class.
Boolean value that specifies whether to output identical solutions found in the calculation.
embedding_time_limit
The execution time in the most recent job, measured in milliseconds.
Boolean value that specifies whether the solutions are filtered based on given constraints.
Gives the result class of the logical model.
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:
- 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 toFalse
, all of multiple identical solutions will be output. Set toTrue
by default.- Type:
- property execution_time
The execution time in the most recent job, measured in milliseconds.
- Type:
- property filter_solution
Boolean value that specifies whether the solutions are filtered based on given constraints. Set to
True
by default. If set toFalse
, the solutions that do not satisfy the constraint condtions will also be output.- Type:
- 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:
- solve(*args, **kwargs)
Solve a given input or logical model.
Overloads:
solve(model)
solve(poly)
solve(matrix, constant)
solve(constraint)
- パラメータ:
model (
BinaryQuadraticModel
,BinaryIntQuadraticModel
,IsingQuadraticModel
orIsingIntQuadraticModel
) --Input quadratic model.
poly (
BinaryPoly
,BinaryIntPoly
,IsingPoly
orIsingIntPoly
) --Input polynomial. It is internally converted to a Quadratic Model.
matrix (
BinaryMatrix
,BinaryIntMatrix
,IsingMatrix
orIsingIntMatrix
) --Input matrix. It is internally converted to a Quadratic Model.
constant (
int
orfloat
, optional) --A constant value added to the above matrix. The type is according to the coefficients of the matrix.
constraint (
BinaryConstraint
,BinaryConstraintTerm
,BinaryConstraints
,BinaryIntConstraint
,BinaryIntConstraintTerm
orBinaryIntConstraints
) --Input constraint(s).
- 戻り値:
Solver's result class whose type is depending on the client. See Client for each client's ClientResult class for further details.
- 戻り値の型:
SolverResult