braket.annealing.problem module¶
-
class
braket.annealing.problem.
ProblemType
[source]¶ Bases:
str
,enum.Enum
The type of annealing problem. QUBO: Quadratic Unconstrained Binary Optimization, with values 1 and 0 ISING: Ising model, with values +/-1
-
QUBO
= 'QUBO'¶
-
ISING
= 'ISING'¶
-
-
class
braket.annealing.problem.
Problem
(problem_type: braket.annealing.problem.ProblemType, linear: Optional[Dict[int, float]] = None, quadratic: Optional[Dict[Tuple[int, int], float]] = None)[source]¶ Bases:
object
Represents an annealing problem.
- Parameters
problem_type (ProblemType) – The type of annealing problem
linear (Dict[int, float]) – The linear terms of this problem, as a map of variable to coefficient
quadratic (Dict[Tuple[int, int], float]) – The quadratic terms of this problem, as a map of variables to coefficient
Examples
>>> problem = Problem( >>> ProblemType.ISING, >>> linear={1: 3.14}, >>> quadratic={(1, 2): 10.08}, >>> ) >>> problem.add_linear_term(2, 1.618).add_quadratic_term((3, 4), 1337)
-
property
problem_type
¶ The type of annealing problem.
- Returns
ProblemType – The type of annealing problem
-
property
linear
¶ The linear terms of this problem.
- Returns
Dict[int, float] – The linear terms of this problem, as a map of variable to coefficient
-
property
quadratic
¶ The quadratic terms of this problem.
- Returns
Dict[Tuple[int, int], float] –
- The quadratic terms of this problem,
as a map of variables to coefficient
-
add_linear_term
(term: int, coefficient: float) → braket.annealing.problem.Problem[source]¶ Adds a linear term to the problem.
- Parameters
term (int) – The variable of the linear term
coefficient (float) – The coefficient of the linear term
- Returns
Problem – This problem object
-
add_linear_terms
(coefficients: Dict[int, float]) → braket.annealing.problem.Problem[source]¶ Adds linear terms to the problem.
- Parameters
coefficients (Dict[int, float]) – A map of variable to coefficient
- Returns
Problem – This problem object
-
add_quadratic_term
(term: Tuple[int, int], coefficient: float) → braket.annealing.problem.Problem[source]¶ Adds a quadratic term to the problem.
- Parameters
term (Tuple[int, int]) – The variables of the quadratic term
coefficient (flost) – The coefficient of the quadratic term
- Returns
Problem – This problem object
-
add_quadratic_terms
(coefficients: Dict[Tuple[int, int], float]) → braket.annealing.problem.Problem[source]¶ Adds quadratic terms to the problem.
- Parameters
coefficients (Dict[Tuple[int, int], float]) – A map of variables to coefficient
- Returns
Problem – This problem object