amplify.client.GurobiClient
- class GurobiClient
A class for using Gurobi client.
- __init__(self: amplify.client.GurobiClient) None
Methods
__init__
(self)solve
(*args, **kwargs)Solves a given polynomial or matrix model.
tune
(*args, **kwargs)Tune parameters for a given model.
Attributes
The filepath to the shared library file of gurobi.
The maximum number of available variables.
Obtains the parameter class of
GurobiClient
.Get the version string of the Gurobi dynamic library.
Set or get the file path to save the model.
Set or get the file path to save the solution.
- property parameters
Obtains the parameter class of
GurobiClient
.- Type:
- solve(*args, **kwargs)
Solves a given polynomial or matrix model.
Overloads:
- solve(poly)
- solve(matrix, constant)
- パラメータ:
poly (
BinaryPoly
,BinaryIntPoly
,IsingPoly
orIsingIntPoly
) --Input polynomial model
matrix (
BinaryMatrix
,BinaryIntMatrix
,IsingMatrix
orIsingIntMatrix
) --Input matrix model
constant (
int
orfloat
, optional) --A constant value to be added to the above matrix. The type is set in accordance with the coefficients of the matrix.
- 戻り値:
A result class that provides information about execution.
- 戻り値の型:
Example
from amplify import BinarySymbolGenerator from amplify.client import GurobiClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 # BinaryPoly type input model client = GurobiClient() client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" client.parameters.time_limit = 1 # time_limit 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.]']
- tune(*args, **kwargs)
Tune parameters for a given model.
Overloads:
- tune(poly)
- tune(matrix, constant)
- tune(model)
- パラメータ:
model (
BinaryQuadraticModel
,BinaryIntQuadraticModel
,IsingQuadraticModel
orIsingIntQuadraticModel
) --Input quadratic model.
poly (
BinaryPoly
,BinaryIntPoly
,IsingPoly
orIsingIntPoly
) --Input polynomial model
matrix (
BinaryMatrix
,BinaryIntMatrix
,IsingMatrix
orIsingIntMatrix
) --Input matrix model
constant (
int
orfloat
, optional) --A constant value to be added to the above matrix. The type is set in accordance with the coefficients of the matrix.
- 戻り値:
Example
from amplify import BinarySymbolGenerator from amplify.client import GurobiClient gen = BinarySymbolGenerator() q = gen.array(3) f = 2 * q[0] * q[1] - q[0] - q[2] + 1 # BinaryPoly type input model client = GurobiClient() client.parameters.time_limit = 10 # time_limit 10 second prmfile = client.tune(f) if prmfile is not None: client.parameters.prmfile = prmfile client.solve(f)
- property write_model
Set or get the file path to save the model. The default value is an empty string, so saving is disabled. Valid extentions are .mps, .rew, .lp, or .rlp for writing the model itself, .dua or .dlp for writing the dualized model (only pure LP).
- Type: