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
ErrorMetricmust have a unique class-level ID, just like approximators. Themax_valueparameter specifies the maximum error bound for this instance. It has the abstract typeValuewhich you can choose freely. The same applies to thestepparameter, 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_valueof typeValue. It specifies the initial value of a newErrorMetricinstance.
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 valuevalueexceeds the maximum error boundmax_valueof 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.