AmplifyModel

class AmplifyModel

Bases: Generic[_C]

A class to represent an optimization model using Amplify SDK.

Methods

__init__

Initialize the AmplifyModel.

solve

Solve the given problem.

Attributes

client

Return the Amplify client used by the model.

constraints

Return the constraints of the optimization model.

objective

Return the objective function of the optimization model.

variables

Return the variables of the optimization model.

classmethod __class_getitem__(params)
__init__(
variables: PolyArray,
client: _C = FixstarsClient({'url': 'https://optigan.fixstars.com', 'token': '', 'compression': true, 'parameters': {'outputs': {}}}),
) None

Initialize the AmplifyModel.

Parameters:
  • variables (amplify.PolyArray) – The variables of the optimization model.

  • client (_C, optional) – The Amplify client to use. Defaults to _default_client.

classmethod __init_subclass__(*args, **kwargs)

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

solve(
constraint_weight: float = 1.0,
max_retries: int = 10,
) tuple[list[ndarray[tuple[int, ...], dtype[float64]]], Result]

Solve the given problem.

The return value is lists of solutions in binary variables that this class holds. When some of the variables are not contained in the given problem, default values are used for those variables.

Parameters:
  • constraint_weight (float) – Weight of constraints. Defaults to 1.0.

  • max_retries (int, optional) – Max number of retries when no feasible solution is found. Defaults to 10.

Returns:

List of solutions in Amplify SDK’s variables and the Amplify SDK’s raw result.

Return type:

tuple[list[npt.NDArray[np.float64]], amplify.Result]

__dict__ = mappingproxy({'__module__': 'amplify_bbopt.amplify_model', '__doc__': 'A class to represent an optimization model using Amplify SDK.', '__init__': <function AmplifyModel.__init__>, 'variables': <property object>, 'client': <property object>, 'objective': <property object>, 'constraints': <property object>, 'solve': <function AmplifyModel.solve>, '__orig_bases__': (typing.Generic[~_C],), '__dict__': <attribute '__dict__' of 'AmplifyModel' objects>, '__weakref__': <attribute '__weakref__' of 'AmplifyModel' objects>, '__parameters__': (~_C,), '__annotations__': {'_variables': 'amplify.PolyArray', '_client': '_C'}})
__orig_bases__ = (typing.Generic[~_C],)
__parameters__ = (~_C,)
__slots__ = ()
__weakref__

list of weak references to the object (if defined)

property client: _C

Return the Amplify client used by the model.

property constraints: ConstraintList

Return the constraints of the optimization model.

property objective: Poly

Return the objective function of the optimization model.

property variables: PolyArray

Return the variables of the optimization model.