QuadraticProgramToQubo
Bases: QuadraticProgramConverter
Convert a given optimization problem to a new problem that is a QUBO.
Examples:
>>> from qiskit_optimization.problems import QuadraticProgram
>>> from qiskit_optimization.converters import QuadraticProgramToQubo
>>> problem = QuadraticProgram()
>>> # define a problem
>>> conv = QuadraticProgramToQubo()
>>> problem2 = conv.convert(problem)
Source code in q3as/quadratic/converters/quadratic_program_to_qubo.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
penalty: Optional[float]
property
writable
Returns the penalty factor used in conversion.
Returns:
| Type | Description |
|---|---|
Optional[float]
|
The penalty factor used in conversion. |
__init__(penalty=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
penalty |
Optional[float]
|
Penalty factor to scale equality constraints that are added to objective. If None is passed, a penalty factor will be automatically calculated on every conversion. |
None
|
Source code in q3as/quadratic/converters/quadratic_program_to_qubo.py
convert(problem)
Convert a problem with linear constraints into new one with a QUBO form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem |
QuadraticProgram
|
The problem with linear constraints to be solved. |
required |
Returns:
| Type | Description |
|---|---|
QuadraticProgram
|
The problem converted in QUBO format as minimization problem. |
Raises:
| Type | Description |
|---|---|
QiskitOptimizationError
|
In case of an incompatible problem. |
Source code in q3as/quadratic/converters/quadratic_program_to_qubo.py
get_compatibility_msg(problem)
staticmethod
Checks whether a given problem can be solved with this optimizer.
Checks whether the given problem is compatible, i.e., whether the problem can be converted to a QUBO, and otherwise, returns a message explaining the incompatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem |
QuadraticProgram
|
The optimization problem to check compatibility. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A message describing the incompatibility. |
Source code in q3as/quadratic/converters/quadratic_program_to_qubo.py
interpret(x)
Convert a result of a converted problem into that of the original problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x |
Union[ndarray, List[float]]
|
The result of the converted problem. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The result of the original problem. |
Source code in q3as/quadratic/converters/quadratic_program_to_qubo.py
is_compatible(problem)
Checks whether a given problem can be solved with the optimizer implementing this method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem |
QuadraticProgram
|
The optimization problem to check compatibility. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Returns True if the problem is compatible, False otherwise. |