AmplifyAEClient

class AmplifyAEClient

ベースクラス: BaseClient

Client of the Amplify Annealing Engine. It sends the model to the service of Fixstars and returns the solutions that the engine found.

Methods

__init__

solve

Send the objective function and the constraints to the engine.

Attributes

acceptable_degrees

Degrees of the polynomial that the engine accepts.

async_threshold_ms

Time above which the client sends the request asynchronously, in milliseconds.

compression

Whether the client compresses the body of the request.

objective_format

Format of the objective function in the request.

parameters

Parameters that the client sends with every request.

proxy

URL of the proxy that the client goes through, or None for no proxy.

solver

Solver of the engine that runs the request.

token

API token of the user.

url

URL of the service that the client sends to.

version

Version of the service.

write_request_data

Path of the file that receives a copy of the request, or None to write none.

write_response_data

Path of the file that receives a copy of the response, or None to write none.

class Parameters

Parameters that the client sends with every request.

__init__(*args, **kwargs)
__repr__(self) → str
戻り値の型:

str

__str__(self) → str
戻り値の型:

str

property duplicate_solutions

Whether the response holds the duplicate solutions.

The engine drops the duplicates by default.

戻り値の型:

bool | None

property num_gpus

Number of the GPUs that the engine uses.

The engine uses one GPU by default. 0 lets it use every GPU that the machine has. None leaves the choice to the engine.

戻り値の型:

int | None

例外:

ValueError -- The value is negative.

property penalty_weight_calibration

Whether the engine calibrates the weight of every penalty function.

The engine calibrates by default. It reads this parameter only when solver is Pubo or Qubo. The Constraint solver, which is the default, ignores it and gives a warning.

戻り値の型:

bool | None

property time_limit_ms

Limit of the execution time, in milliseconds.

The setter also takes a datetime.timedelta. The engine uses 10000 milliseconds when this parameter is None.

戻り値の型:

timedelta | None

例外:

ValueError -- The value is negative.

class Result

Raw response of the Amplify Annealing Engine.

class Solution

One solution in the response.

class Status

ベースクラス: Enum

Whether a solution satisfies the constraints of the request.

classmethod __contains__(value)

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls's members. 3) value is a pseudo-member (flags)

classmethod __getitem__(name)

Return the member matching name.

classmethod __iter__()

Return members in definition order.

classmethod __len__()

Return the number of members (no aliases)

__repr__(self) → str
戻り値の型:

str

__str__(self) → str
戻り値の型:

str

Feasible = 1
Infeasible = 0
Optimal = 2
__members__ = mappingproxy({'Infeasible': AmplifyAEClientSolutionStatus.Infeasible, 'Feasible': AmplifyAEClientSolutionStatus.Feasible, 'Optimal': AmplifyAEClientSolutionStatus.Optimal})
__name__ = 'Status'
__nb_enum__ = <capsule object NULL>
__qualname__ = 'AmplifyAEClient.Result.Solution.Status'
__init__(*args, **kwargs)
__repr__(self) → str
戻り値の型:

str

__str__(self) → str
戻り値の型:

str

property objective

Value of the objective function of the solution.

戻り値の型:

float

property status

Whether the solution satisfies the constraints.

戻り値の型:

Status

property time_stamp_ms

Time at which the engine found the solution, in milliseconds.

The time starts when the run starts.

戻り値の型:

timedelta

property values

Values of the variables of the solution.

The order follows the variables of the request, not the variables of the input model.

戻り値の型:

ndarray

__init__(*args, **kwargs)
__repr__(self) → str
戻り値の型:

str

__str__(self) → str
戻り値の型:

str

property execution_time_ms

Time that the engine spent on the request, in milliseconds.

戻り値の型:

timedelta

property num_flips

Number of the flips that all the GPUs ran, in total.

A flip makes the next state from the current one.

戻り値の型:

int

property num_gpus

Number of the GPUs that the engine used.

戻り値の型:

int

property num_samplings

Number of the solutions that the run gave.

A GPU returns the best state that a group of the flips found. That step is one sampling.

戻り値の型:

int

property queue_time_ms

Time that the request waited in the queue, in milliseconds.

戻り値の型:

timedelta

property solutions

Solutions that the engine found.

戻り値の型:

list[Solution]

property started_at

Time at which the engine started to run the request.

戻り値の型:

datetime

property submitted_at

Time at which the service received the request.

戻り値の型:

datetime

property version

Version of the engine that ran the request.

戻り値の型:

str

property warnings

Warnings that the service returned with the response.

戻り値の型:

list[str]

class Solver

ベースクラス: Enum

Solver of the Amplify Annealing Engine that runs the request.

classmethod __contains__(value)

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls's members. 3) value is a pseudo-member (flags)

classmethod __getitem__(name)

Return the member matching name.

classmethod __iter__()

Return members in definition order.

classmethod __len__()

Return the number of members (no aliases)

__repr__(self) → str
戻り値の型:

str

__str__(self) → str
戻り値の型:

str

Constraint = 0
Pubo = 1
Qubo = 2
__members__ = mappingproxy({'Constraint': AmplifyAEClientSolver.Constraint, 'Pubo': AmplifyAEClientSolver.Pubo, 'Qubo': AmplifyAEClientSolver.Qubo})
__name__ = 'Solver'
__nb_enum__ = <capsule object NULL>
__qualname__ = 'AmplifyAEClient.Solver'
__init__(self) → None
__init__(self, token: str = '', url: str = '', proxy: str | None = None) → None
パラメータ:
  • token (str) -- Defaults to ''.

  • url (str) -- Defaults to ''.

  • proxy (str | None) -- Defaults to None.

__repr__(self) → str
戻り値の型:

str

__str__(self) → str
戻り値の型:

str

solve(
self,
objective: Poly | Matrix,
dry_run: Literal[False] = False,
) → Result
solve(
self,
constraint: Constraint | ConstraintList,
dry_run: Literal[False] = False,
) → Result
solve(
self,
objective: Poly | Matrix,
constraint: Constraint | ConstraintList,
dry_run: Literal[False] = False,
) → Result
solve(self, objective: Poly | Matrix, dry_run: Literal[True]) → None
solve(self, constraint: Constraint | ConstraintList, dry_run: Literal[True]) → None
solve(
self,
objective: Poly | Matrix,
constraint: Constraint | ConstraintList,
dry_run: Literal[True],
) → None

Send the objective function and the constraints to the engine.

This method takes the polynomial that the engine accepts, so it runs no conversion of the model. Use solve() to solve a model that needs a conversion. It returns the raw response of the engine. When dry_run is True, the client only asks the service to check the request, and it returns None.

Overload 1.

Args:
  • objective (amplify.Poly | amplify.Matrix): The objective function that the engine minimizes.

  • dry_run (typing.Literal[False]): When True, ask the service to check the request, and return None. Defaults to False.

Returns:

amplify.AmplifyAEClient.Result:

Overload 2.

Args:
  • constraint (amplify.Constraint | amplify.ConstraintList): The constraints that the solution must satisfy.

  • dry_run (typing.Literal[False]): When True, ask the service to check the request, and return None. Defaults to False.

Returns:

amplify.AmplifyAEClient.Result:

Overload 3.

Args:
  • objective (amplify.Poly | amplify.Matrix): The objective function that the engine minimizes.

  • constraint (amplify.Constraint | amplify.ConstraintList): The constraints that the solution must satisfy.

  • dry_run (typing.Literal[False]): When True, ask the service to check the request, and return None. Defaults to False.

Returns:

amplify.AmplifyAEClient.Result:

Overload 4.

Args:
  • objective (amplify.Poly | amplify.Matrix): The objective function that the engine minimizes.

  • dry_run (typing.Literal[True]): When True, ask the service to check the request, and return None.

Overload 5.

Args:
  • constraint (amplify.Constraint | amplify.ConstraintList): The constraints that the solution must satisfy.

  • dry_run (typing.Literal[True]): When True, ask the service to check the request, and return None.

Overload 6.

Args:
  • objective (amplify.Poly | amplify.Matrix): The objective function that the engine minimizes.

  • constraint (amplify.Constraint | amplify.ConstraintList): The constraints that the solution must satisfy.

  • dry_run (typing.Literal[True]): When True, ask the service to check the request, and return None.

property acceptable_degrees

Degrees of the polynomial that the engine accepts.

solve() reads it to decide the conversion of the model.

戻り値の型:

AcceptableDegrees

property async_threshold_ms

Time above which the client sends the request asynchronously, in milliseconds.

The client polls the service when Parameters.time_limit_ms is above this value, and it waits for one response otherwise. The setter also takes a datetime.timedelta.

戻り値の型:

timedelta | None

例外:

ValueError -- The value is negative.

property compression

Whether the client compresses the body of the request.

The client compresses by default. Compression costs CPU time and it makes the request smaller.

戻り値の型:

bool

property objective_format

Format of the objective function in the request.

See ObjectiveFormat. The answer does not depend on this choice.

戻り値の型:

ObjectiveFormat

property parameters

Parameters that the client sends with every request.

戻り値の型:

Parameters

property proxy

URL of the proxy that the client goes through, or None for no proxy.

戻り値の型:

str | None

property solver

Solver of the engine that runs the request. See Solver.

戻り値の型:

Solver

property token

API token of the user.

The client needs it for every request. Its text never appears in the output of repr().

戻り値の型:

str

property url

URL of the service that the client sends to.

戻り値の型:

str

property version

Version of the service.

Reading this property sends a request to the service.

戻り値の型:

str

property write_request_data

Path of the file that receives a copy of the request, or None to write none.

Use it to inspect what the client sends.

戻り値の型:

Path | None

property write_response_data

Path of the file that receives a copy of the response, or None to write none.

戻り値の型:

Path | None