Class Factory Evaluator (CFE) API
For an overview of the API, refer to
and the accompanying: ADORE Evaluation Docs
adore.optimization.api.factory_evaluator.ClassFactoryApiEvaluator
Evaluator that uses the architecture to instantiate Python classes and use that to evaluate the architecture:
- Instantiate classes from architecture
- Evaluate instantiated classes
- Interpret results from output object or dict
get_class_factories
get_class_factories() -> List[ClassFactory]
Returns the list of class factories defining the input for the architecture evaluation.
get_metrics_factory
get_metrics_factory() -> MetricsFactory
Returns the metrics factory defining the output of the architecture evaluation.
update_external_databases
Update/add the external database, auto-match elements, and report linked elements.
export_external_dbs
Export the external elements database as defined by the class and metric factories. The created database can be added to your ADORE project.
launch_in_gui
Launch the GUI with this project loaded in memory. Note that any edits done are then not synchronized with the original project anymore.
show_project
show_project(save_path: str = None, height: int = None, show_architecture_id: int = None, externalize_js: Union[bool, str] = False)
Generate and view the HTML export showing the project. Also supports Jupyter notebooks.
externalize_js=True places the frontend code in a separate file in the same directory as the notebook,
thereby greatly reducing the size of the notebook itself.
However, this only works when the notebook is exported to HTML and then served. Within the interactive notebook
itself it does not work!
_evaluate
_evaluate(architecture: Architecture, arch_qois: List[ArchQOI], **kwargs) -> Dict[ArchQOI, Union[float, Quantity]]
Evaluate the performance of an architecture. Use the following methods to help:
instantiateto instantiate classes defined in your ClassFactory'sprocess_resultsto get results for ADORE from a dict or object with keys defined in your MetricsFactory
Example:
objects = self.instantiate(architecture)
results = ... # Run the evaluation
return self.process_results(architecture, arch_qois, results)
Optionally you can also instantiate classes for a subset of defined class factories:
To get information about the owner chain (e.g. system instance, component instance),
you can use instantiate_by_owner instead.
Results should be provided as an object or dict with keys/attributes being the metric factory keys, and values being either float values (NaN is supported) or Quantity elements (which are values + units). If a metric factory matches multiple QOIs, the values can be provided as a list (with the same nr of QOIs).
instantiate
instantiate(architecture: Architecture, factories: Union[str, List[ClassFactory]] = None) -> List[Any]
Instantiate classes for the architecture.
Optionally only for the given class factories, specified either as a list of class factories
(from self._class_factories or self.get_factories_by_el_name) or as the element name
(supports wildcard patterns).
instantiate_by_owner
instantiate_by_owner(architecture: Architecture, factories: Union[str, List[ClassFactory]] = None) -> List[Tuple[Any, List[ArchElement]]]
Instantiate classes for the architecture and return owner chain (list of elements containing the targeted element). Optionally only for the given class factories.
get_factories_by_el_name
get_factories_by_el_name(el_name_pattern: str) -> List[ClassFactory]
Get class factories by name, optionally as a pattern: name_*
quantity
Create a Quantity from a numerical value and units.
qoi_to_units
Get a copy of a QOI with values converted to other units.
get_qoi_value
Get the QOI value as Quantity (value + units)
process_results
process_results(architecture: Architecture, arch_qois: List[ArchQOI], results: Union[object, dict]) -> Dict[ArchQOI, Union[float, Quantity]]
Read results from an object or dict and link them to the requested QOIs.
adore.optimization.api.factory_evaluator.ClassFactory
ClassFactory(el: ExternalElementDef, cls: type, props: Dict[str, Union[Any, ExternalElementDef, SpecialValue, ConnectionValue, Callable[[], Any]]] = None, only_contained_props: bool = True, ext_db_def: ExtDbDef = None)
Defines external database elements for linking to design space elements, and how linked architecture elements are used to instantiate a class.
The main external element that leads to the instantiation of the class is given in el.
The props dict is used to define additional properties (passed as kwargs to the class) that can be based on
other linked elements, optionally only contained elements if only_contained_props is true
(e.g. QOIs that are owned by a component).
props
props: Dict[str, Union[Any, ExternalElementDef, SpecialValue, ConnectionValue, Callable[[], Any]]] = None
adore.optimization.api.factory_evaluator.MetricsFactory
MetricsFactory(metrics: Dict[str, ExternalQOIDef], ext_db_def: ExtDbDef = None)
Defines external database elements for defining analysis output metrics. The metrics dictionary defines which key in the output (can be provided either as an object or as a dict) is associated to which external QOI element.
adore.optimization.api.factory_evaluator.ExtDbDef
ExtDbDef(name: str, ref: str = None, db_type_name: str = None, elements_type_name: str = None, linking_field_name: str = None, source: str = None)
Class that overrides database/element names in the GUI.
db_type_name
Shown when selecting the external database as: "db_type_name": database name
elements_type_name
Name of the elements (shown above the elements table).
linking_field_name
Name of the selector field when editing an ADORE element for linking to external elements in the database.
adore.optimization.api.factory_evaluator.ExternalElementDef
ExternalElementDef(name: str, el_types: List[Type[Element]] = None, ref: str = None, metadata: dict = None, prop_override: dict = None, notes: str = None, auto_match_pattern: Union[str, List[str]] = None, auto: bool = False, default_prop_value: Any = NO_VALUE, value_getter: callable = None, value_units: str = None)
Defines a generic external element.
el_types defines to which types of design space elements it can be linked.
ref should be unique across all elements: if not given, it is derived from the name.
value_getter
Function for converting between model value and class value.
adore.optimization.api.factory_evaluator.ExternalQOIDef
ExternalQOIDef(name: str, el_types: List[Type[Element]] = None, ref: str = None, metadata: dict = None, prop_override: dict = None, notes: str = None, auto_match_pattern: Union[str, List[str]] = None, auto: bool = False, default_prop_value: Any = NO_VALUE, value_getter: callable = None, value_units: str = None, qoi_type: QOIType = None, pos_better: bool = None, ref_value: float = None, bounds: Tuple[float, float] = None, options: List[str] = None, value: float = None, value_str: str = None, units: str = None)
Defines an external element that can be linked to a Quantity of Interest. Has specialized fields to override QOI properties.
If no specific QOI type is specified, QOI types are restricted based on whether they are defined as part of a class factory (input) or metrics factory (output).
Note: QOI values types (used for the class properties) are as follows: - Input parameter (value; string), Design Variable (discrete options) --> STRING - Anything else: float (can also be NaN)
adore.optimization.api.factory_evaluator.ExternalAttributeDef
ExternalAttributeDef(name: str, el_types: List[Type[Element]] = None, ref: str = None, metadata: dict = None, prop_override: dict = None, notes: str = None, auto_match_pattern: Union[str, List[str]] = None, auto: bool = False, default_prop_value: Any = NO_VALUE, value_getter: callable = None, value_units: str = None)
Defines an external element that can be linked to a component Attribute.
Note: the associated element value is a list of strings! This is because in an architecture, an attribute can have multiple of the attributes values assigned, and attribute values are of type string.
adore.optimization.api.factory_evaluator.ExternalFunctionDef
ExternalFunctionDef(name: str, el_types: List[Type[Element]] = None, ref: str = None, metadata: dict = None, prop_override: dict = None, notes: str = None, auto_match_pattern: Union[str, List[str]] = None, auto: bool = False, default_prop_value: Any = NO_VALUE, value_getter: callable = None, value_units: str = None, function_type: FunctionType = None, boundary_function: bool = None)
Defines an external element that can be linked to a Function. Has specialized fields to override Function properties.
adore.optimization.api.factory_evaluator.ExternalComponentDef
ExternalComponentDef(name: str, el_types: List[Type[Element]] = None, ref: str = None, metadata: dict = None, prop_override: dict = None, notes: str = None, auto_match_pattern: Union[str, List[str]] = None, auto: bool = False, default_prop_value: Any = NO_VALUE, value_getter: callable = None, value_units: str = None, n_inst: List[int] = None)
adore.optimization.api.factory_evaluator.ExternalPortDef
ExternalPortDef(name: str, el_types: List[Type[Element]] = None, ref: str = None, metadata: dict = None, prop_override: dict = None, notes: str = None, auto_match_pattern: Union[str, List[str]] = None, auto: bool = False, default_prop_value: Any = NO_VALUE, value_getter: callable = None, value_units: str = None)
Defines an external element that can be linked to a Port.
adore.optimization.api.factory_evaluator.ConnectionValue
ConnectionValue(conn_target_def: Union[ExternalElementDef, List[ExternalElementDef]], input_conn: Optional[bool] = None, return_ports: bool = False)
Provides a way to use connection targets as a property value. The property value will be set to a list (for connection target) of instantiated classes representing the target components.
To track port connection targets: provide an ExternalPortDef. To track connections between Functions and Components/Concepts/Decompositions/NonFulfillments/MultFulfillments: provide any other ExternalElementDef type (or list).
