Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"). You 

4# may not use this file except in compliance with the License. A copy of 

5# the License is located at 

6# 

7# http://aws.amazon.com/apache2.0/ 

8# 

9# or in the "license" file accompanying this file. This file is 

10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 

11# ANY KIND, either express or implied. See the License for the specific 

12# language governing permissions and limitations under the License. 

13 

14from enum import Enum 

15from typing import Dict 

16 

17from pydantic import Field, conint 

18 

19from braket.schema_common import BraketSchemaBase, BraketSchemaHeader 

20 

21 

22class ProblemType(str, Enum): 

23 """ The type of annealing problem. 

24 

25 QUBO: Quadratic Unconstrained Binary Optimization, with values 1 and 0 

26 ISING: Ising model, with values +/-1 

27 """ 

28 

29 QUBO = "QUBO" 

30 ISING = "ISING" 

31 

32 

33class Problem(BraketSchemaBase): 

34 """ Specifies a quantum annealing problem. 

35 

36 Attributes: 

37 braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need 

38 to set this value. Only default is allowed. 

39 type (ProblemType): The type of problem; can be either "QUBO" or "ISING" 

40 linear (Dict[int, float]): Linear terms of the model. 

41 quadratic (Dict[str, float]): Quadratic terms of the model, keyed on comma-separated 

42 variables as strings 

43 

44 Examples: 

45 >>> Problem(type=ProblemType.QUBO, linear={0: 0.3, 4: -0.3}, quadratic={"0,5": 0.667}) 

46 """ 

47 

48 _PROBLEM_HEADER = BraketSchemaHeader(name="braket.ir.annealing.problem", version="1") 

49 braketSchemaHeader: BraketSchemaHeader = Field(default=_PROBLEM_HEADER, const=_PROBLEM_HEADER) 

50 type: ProblemType 

51 linear: Dict[conint(ge=0), float] 

52 quadratic: Dict[str, float]