Extensible components¶
- Approximators
- ErrorMetrics
ErrorMetrics¶
Error metrics (or ErrorMetric
instances) provide a general way to specify quality constraints. Each ErrorMetric
represents a specific way of quantifying the errors produced by an approximated circuit in relation to the original circuit’s output. Each instance, however, specifies a concrete maximum bound for its metric to serve as candidate-specific quality constraint.
To create an abstract interface for working with error metrics of arbitrary types, the ErrorMetric
class provides several methods for increasing or comparing error values independently of the respective error metric’s value representation.
Functions¶
__init__(id: String, max_value: Value, step: StepValue)
¶
For identification and representation of different error metrics, each
ErrorMetric
must have a unique class-level ID, just like approximators. Themax_value
parameter specifies the maximum error bound for this instance. It has the abstract typeValue
which you can choose freely. The same applies to thestep
parameter, which defines the step size of a value increment.Note
Note that this method must call the superclass’s
__init__
method, which takes an additional argumentdefault_value
of typeValue
. It specifies the initial value of a newErrorMetric
instance.
getNextValue(cur_value: Value): Value
¶
This method calculates the next error value as the current value increased by exactly one step. The value is returned, even if it exceeds the maximum error bound of this instance.
greaterMax(value: Value): Boolean
¶
A simple query method to check whether the given error valuevalue
exceeds the maximum error boundmax_value
of this instance.
getValueStr(value: Value): String
¶
Returns a string representation of the given error value. This is used for ID generation of variants and circuit configurations, so different error values should always generate different string representations. Also make sure to keep the representation as short as possible to avoid overly long IDs.