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 BaseModel, conint 

18 

19 

20class ProblemType(str, Enum): 

21 """ The type of annealing problem. 

22 

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

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

25 """ 

26 

27 QUBO = "QUBO" 

28 ISING = "ISING" 

29 

30 

31class Problem(BaseModel): 

32 """ Specifies a quantum annealing problem. 

33 

34 Attributes: 

35 - type: The type of problem; can be either "QUBO" or "ISING" 

36 - linear: Linear terms of the model. 

37 - quadratic: Quadratic terms of the model, keyed on comma-separated 

38 variables as strings 

39 

40 Examples: 

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

42 """ 

43 

44 type: ProblemType 

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

46 quadratic: Dict[str, float]