AmplifyAEClientΒΆ

class AmplifyAEClientΒΆ

Bases: 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ΒΆ
Return type:

str

__str__(self) → strΒΆ
Return type:

str

property duplicate_solutionsΒΆ

Whether the response holds the duplicate solutions.

The engine drops the duplicates by default.

Return type:

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.

Return type:

int | None

Raises:

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.

Return type:

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.

Return type:

timedelta | None

Raises:

ValueError – The value is negative.

class ResultΒΆ

Raw response of the Amplify Annealing Engine.

class SolutionΒΆ

One solution in the response.

class StatusΒΆ

Bases: 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ΒΆ
Return type:

str

__str__(self) → strΒΆ
Return type:

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ΒΆ
Return type:

str

__str__(self) → strΒΆ
Return type:

str

property objectiveΒΆ

Value of the objective function of the solution.

Return type:

float

property statusΒΆ

Whether the solution satisfies the constraints.

Return type:

Status

property time_stamp_msΒΆ

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

The time starts when the run starts.

Return type:

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.

Return type:

ndarray

__init__(*args, **kwargs)ΒΆ
__repr__(self) → strΒΆ
Return type:

str

__str__(self) → strΒΆ
Return type:

str

property execution_time_msΒΆ

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

Return type:

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.

Return type:

int

property num_gpusΒΆ

Number of the GPUs that the engine used.

Return type:

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.

Return type:

int

property queue_time_msΒΆ

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

Return type:

timedelta

property solutionsΒΆ

Solutions that the engine found.

Return type:

list[Solution]

property started_atΒΆ

Time at which the engine started to run the request.

Return type:

datetime

property submitted_atΒΆ

Time at which the service received the request.

Return type:

datetime

property versionΒΆ

Version of the engine that ran the request.

Return type:

str

property warningsΒΆ

Warnings that the service returned with the response.

Return type:

list[str]

class SolverΒΆ

Bases: 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ΒΆ
Return type:

str

__str__(self) → strΒΆ
Return type:

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
Parameters:
  • token (str) – Defaults to ''.

  • url (str) – Defaults to ''.

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

__repr__(self) → strΒΆ
Return type:

str

__str__(self) → strΒΆ
Return type:

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.

Return type:

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.

Return type:

timedelta | None

Raises:

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.

Return type:

bool

property objective_formatΒΆ

Format of the objective function in the request.

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

Return type:

ObjectiveFormat

property parametersΒΆ

Parameters that the client sends with every request.

Return type:

Parameters

property proxyΒΆ

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

Return type:

str | None

property solverΒΆ

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

Return type:

Solver

property tokenΒΆ

API token of the user.

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

Return type:

str

property urlΒΆ

URL of the service that the client sends to.

Return type:

str

property versionΒΆ

Version of the service.

Reading this property sends a request to the service.

Return type:

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.

Return type:

Path | None

property write_response_dataΒΆ

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

Return type:

Path | None