quast_decisiontree.algorithms.hybrid.hybrid_algorithm
quast_decisiontree.algorithms.hybrid.hybrid_algorithm
HybridAlgorithm
Bases: ABC
Base class for hybrid quantum-classical algorithms.
Integrates with AutoClassBuilder: subclasses declare HYPERPARAMS and their init receives kwargs matching those names.
Subclasses declare INPUT_KEYS to specify which problem data they need, then implement run_algorithm() with the actual logic.
Source code in src/quast_decisiontree/algorithms/hybrid/hybrid_algorithm.py
16 17 18 19 20 21 22 23 24 25 26 27 28 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 | |
HYPERPARAMS
class-attribute
HYPERPARAMS = []
List of HyperParam instances; override in subclass.
INPUT_KEYS
class-attribute
INPUT_KEYS = ()
Keys the algorithm expects (e.g., 'qubo_matrix', 'graph', 'cost_operator').
backend
instance-attribute
backend = None
input
property
input
__init__
__init__(**kwargs)
Initialize from keyword arguments matching HYPERPARAMS names.
This constructor signature is compatible with AutoClassBuilder.build().
Source code in src/quast_decisiontree/algorithms/hybrid/hybrid_algorithm.py
32 33 34 35 36 37 38 39 40 41 | |
set_input
set_input(input_dict)
Validate and store input data. Raises on unknown keys.
Source code in src/quast_decisiontree/algorithms/hybrid/hybrid_algorithm.py
49 50 51 52 53 54 55 56 57 58 59 60 | |
reset
reset()
Clear input and backend state after execution.
Source code in src/quast_decisiontree/algorithms/hybrid/hybrid_algorithm.py
71 72 73 74 | |
execute
execute(backend, **kwargs)
Execute the hybrid algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
Backend
|
Backend instance supporting run()/run_batch(). |
required |
**kwargs
|
Any
|
Must match INPUT_KEYS (e.g., qubo_matrix=..., graph=...). |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Algorithm-specific result. |
Source code in src/quast_decisiontree/algorithms/hybrid/hybrid_algorithm.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
run_algorithm
abstractmethod
run_algorithm(backend, input)
Algorithm-specific execution. Override in subclass.
Backend usage
- backend(circuit, shots=None) or backend.run(circuit, shots=None)
- backend.run_batch(circuits, shots=None)
Backends return Dict[str, int] mapping bitstrings to counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
Backend
|
The quantum backend to submit circuits to. |
required |
input
|
dict[str, Any]
|
Dict with keys from INPUT_KEYS, all guaranteed non-None. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Algorithm result (solution dict, counts, optimal value, etc.) |
Source code in src/quast_decisiontree/algorithms/hybrid/hybrid_algorithm.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
get_builder
classmethod
get_builder(name=None, description=None)
Create an AutoClassBuilder for this algorithm class.
Source code in src/quast_decisiontree/algorithms/hybrid/hybrid_algorithm.py
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 | |