approximation.approximation module

class approximation.approximation.Approximation(cfg_file)

Bases: object

Singleton class for finishing creation and ensuring validity of the CandidateSet. Provides functionality to delegate approximation tasks to specific approximators.

Parameters:cfg_file (str) – The absolute path to the configuration file, ending on .cfg.
Raises:ValueError – If no default approximation methods or quality constraints are specified in the configuration file.
SUPPORTED_ERROR_METRICS = ['WC', 'BF', 'BM']
__init__(cfg_file)

Parses app_methods and quality constraints from config file.

static _parseApproxMethods(cfg_file)

Parses default approximation methods from the config file and returns a list containing an ApproxMethod instance for each specified approximation method without redundancies.

Parameters:cfg_file (str) – The absolute path to the configuration file, ending on .cfg.
Returns:A list containing an ApproxMethod instance for each approximation method ID found in the Method option of the configuration file’s Approximation section. At most one ApproxMethod instance of each type is included.
Return type:list of ApproxMethod
static _parseQualityConstraints(cfg_file)

Parses default quality constraints from the config file and returns a list containing an ErrorMetric instance for each specified quality constraint without redundancies.

Parameters:cfg_file (str) – The absolute path to the configuration file, ending on .cfg.
Returns:A list containing an ErrorMetric instance for each error metric ID found in the QualityConstraints option of the configuration file’s Approximation section. At most one ErrorMetric instance of each type is included.
Return type:list of ErrorMetric
setup(gen_info)

Sets up Approximation instance using a GeneralInformation instance. Sets default app_methods and default quality_constraints attributes on each Candidate in cand_set if attribute is empty and returns the root node.

Parameters:gen_info (GeneralInformation) – The framework’s GeneralInformation instance.
Returns:The root node of the search space tree.
Return type:Node
Raises:ValueError – If a candidate is left without approximation methods or quality constraitns after incompatibilities were removed.
performApproximations(nodes)

Generates approximated versions of all Variants in all Nodes in a given list and synthesizes the resulting circuits.

Parameters:nodes (list of Node) – A list of Node instances whose circuits will be approximated.
_getRootNode()

Creates and returns the root node of the search space tree and adds its Variants to the VariantSet.

Returns:The root node of the search space tree.
Return type:Node
static _autoDetectBoundaries(cand)

Automatically detects quality boundaries for a Candidate. PO information about the Candidate is required.

Parameters:cand (Candidate) – The Candidate to check for boundaries.