problems.n_minus_1.quantum_annealing
Quantum Annealing based solution to the N-1 problem.
- class tno.quantum.problems.n_minus_1.quantum_annealing.DecodedResult(graph)[source]
Bases:
object
The
DecodedResult
class.DecodedResult
stores results decoded from a sample of a sampleset.- __eq__(other)[source]
Simple equals function.
Two
DecodedResult
s are equal if if the underlying graph after performing the switches are equal.- Return type:
- __hash__()[source]
Simple hash function.
Creates a hash of the graph using the Return Weisfeiler Lehman (WL) graph hash together with simple hashes of the turned on/off edges.
- Return type:
- __init__(graph)[source]
Init of the
DecodedResult
class.- Parameters:
graph (
Graph
) – Graph of a power network. If theDecodedResult
is used store decoded results containing loadflow constraints, then graph should have nodes and edges as described inQABasedNMinusOneSolver
.
- __repr__()[source]
String representation of the result.
- Return type:
- Returns:
String representation of the class, using the class name, number of nodes, turned on edges and turned off edges.
Example
"DecodedResult[n_nodes=4, turned_on=[(3,4)], turned_off=[(2,3)]]"
.
- class tno.quantum.problems.n_minus_1.quantum_annealing.FactoryArguments(n_layers, K, L, M)[source]
Bases:
BaseArguments
Arguments for the N-Minus-1 QUBO factory.
- __init__(n_layers, K, L, M)[source]
Init of the
NMOFactory
.- Parameters:
n_layers (
Optional
[SupportsInt
]) – Number of layers to use for the tree formulation.K (
SupportsInt
) – Number of auxiliary variables to use or encoding the real part of the potential.L (
SupportsInt
) – Number of auxiliary variables to use or encoding the imaginary part of the potential.M (
SupportsInt
) – Number of auxiliary variables to use for encoding the current.
- classmethod default()[source]
Create a default instance of the factory arguments.
The defaults sets the following values:
Number of layers:
n_layers = None
,Number of auxiliary variables real part potential:
K = 6
,Number of auxiliary variables imag part potential:
L = 5
,Number of auxiliary variables current:
M = 5
,
- Return type:
Self
- class tno.quantum.problems.n_minus_1.quantum_annealing.QABasedNMinusOneSolver(graph, failing_edge)[source]
Bases:
object
Quantum Annealing Based N-1 Solver.
The Quantum Annealing solver performs the following steps:
Transform the problem to a Binary Quadratic Model, also known as a Quadratic Unconstrained Optimization (QUBO).
Approximate a solution to this problem with the given QUBO solver. This solver can be a quantum solver.
Decode the bitstrings returned by the solver.
- __init__(graph, failing_edge)[source]
Init of the
QABasedNMinusOneSolver
.- Parameters:
graph (
Graph
) – Network represented as a graph. Each node should have the following attributes: type, U_ref, P_low, P_high, U_min and U_max. Each edge should have the following attributes: active, edge_idx, Z and I_max.failing_edge (
tuple
[Hashable
,Hashable
]) – The edge that will fail in the scenario.
- run(factory_arguments=None, qubo_arguments=None, solver_config=None)[source]
Run the algorithm.
- Parameters:
factory_arguments (
UnionType
[FactoryArguments
,Mapping
[str
,Any
],None
]) – Keyword arguments for the Binary Quadratic Model factory. See the init of theFactoryArguments
for a more detailed description. IfNone
is given (default), thedefault()
arguments are used.qubo_arguments (
UnionType
[QUBOArguments
,Mapping
[str
,Any
],None
]) – Keyword arguments for building the QUBO. SeeQUBOArguments
for a more detailed description. IfNone
is given (default), thedefault()
arguments are used.solver_config (
UnionType
[SolverConfig
,Mapping
[str
,Any
],None
]) – Configuration for the qubo solver to use. Must be aSolverConfig
or a mapping with"name"
and"options"
keys. IfNone
(default) is provided, the``{"name": "simulated_annealing_solver", "options": {}}`
.
- Return type:
- Returns:
Result overview object containing the results.
- class tno.quantum.problems.n_minus_1.quantum_annealing.QUBOArguments(penalty_depth, penalty_connectivity, penalty_loadflow, penalty_auxvar, p_extra)[source]
Bases:
BaseArguments
Arguments for the N-1 QUBO.
- __init__(penalty_depth, penalty_connectivity, penalty_loadflow, penalty_auxvar, p_extra)[source]
Arguments to configure the QUBO formulation for the N-1 problem.
- Parameters:
penalty_depth (
SupportsFloat
) – Absolute penalty scaling to use for the depth penalty.penalty_connectivity (
SupportsFloat
) – Absolute penalty scaling to use for the connectivity penalty.penalty_loadflow (
SupportsFloat
) – Absolute penalty scaling to use for the loadflow penalty.penalty_auxvar (
SupportsFloat
) – Absolute penalty scaling to use for the penalty governing the behavior of the auxiliary variables.p_extra (
SupportsFloat
) – Extra power to add to each node for numerical stability.
- classmethod default()[source]
Create a default instance of the QUBO arguments.
The defaults sets the following absolute penalty scaling values:
Depth penalty:
penalty_depth = 400
,Connectivity:
penalty_connectivity = 100
,Loadflow:
penalty_loadflow = 2
,Auxiliary variables:
penalty_auxvar = 1
,Numerical stability power:
p_extra = 1
,
- Return type:
Self
- class tno.quantum.problems.n_minus_1.quantum_annealing.ResultsOverview[source]
Bases:
object
ResultsOverview.
The
ResultsOverview
class is a collection ofDecodedResult
.- __init__()[source]
Init of the
ResultsOverview
class.
- __repr__()[source]
Make a string representation of the
ResultsOverview
.- Return type:
- add_result(result, count=1)[source]
Add a result to the overview.
- Parameters:
result (
DecodedResult
) – Result to add to the overview.count (
int
) – Number of times the result was seen. Default is 1.
- Return type:
Self
- Returns:
Self.