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.
__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. The
max_valueparameter specifies the maximum error bound for this instance. It has the abstract type
Valuewhich you can choose freely. The same applies to the
stepparameter, which defines the step size of a value increment.
Note that this method must call the superclass’s
__init__method, which takes an additional argument
Value. It specifies the initial value of a new
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 value
valueexceeds the maximum error bound
max_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.