Design Space Modeling API
adore.graph.api.manager.GraphApiManager
GraphApiManager(project: Project = None, schema_factory: SchemaFactory = None)
Main class that manages editing a project by performing model checks and making sure everything is consistent. Manages translation between the Project and the AdoreGraph / ADSG.
Creating a new project:
from adore import GraphApiManager
manager = GraphApiManager()
project = manager.project
factory = manager.factory
helper = manager.helper
# Modify the project using the factory and helper
...
manager.sync()
print(manager.project.design_space.issues)
Loading an existing ADORE project:
adore_graph
The Architecture Design Space Graph (ADSG) constructed from the ADORE Project.
Use adore_graph.export_dot("adsg.dot") and https://viz-js.com/ to visualize the ADSG.
get_design_problem_translator
get_design_problem_translator(design_problem_id: id_type = None, sync=True) -> DesignProblemTranslator
Get a design problem translator for formulating the optimization problem from the design space.
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!
sync
Main synchronization/checking function. Should be executed after manipulating the design space model. Performs the following steps:
- Synchronizes external databases: auto-links elements and overrides element properties.
- Derives architecture choices (
Decision) from the design space. - Creates issues if there are any issues in the design space.
sync_decision_stats
Calculates design space and choice statistics. Can take a long time so it is recommended to set a timeout.
adore.api.factory.SchemaFactory
Class with functions for creating model elements, and writing/reading a Project to/from files.
The SchemaFactory should be instantiated from a GraphApiManager or a Database.
attribute
attribute(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, conn: ConnSpec = None, group_per_component: bool = False, values: List[AttributeValue] = None) -> Attribute
attribute_value
attribute_value(value: attribute_value_type, name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, conn: ConnSpec = None) -> AttributeValue
component
component(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, n_inst: List[int] = None, fulfilled_function_ids: List[id_type] = None, needed_function_ids: List[id_type] = None, attributes: List[Attribute] = None, instance_attributes: List[Attribute] = None, qois: List[Qoi] = None, instance_qois: List[Qoi] = None, input_ports: List[PortConnection] = None, output_ports: List[PortConnection] = None) -> Component
concept
concept(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, neutral_function_id: id_type = None, specific_function_id: id_type = None) -> Concept
conn_spec
conn_spec(n_range_max: int = None, n_range_min: int = None, n_specific: List[int] = None, repeat_allowed: bool = False) -> ConnSpec
decision
decision(name: str = None, notes: str = None, ref: ref_type = None, type_: DecisionType = None, operation: DecisionOperation = None, source_ref_element_ids: List[id_type] = None, target_ref_element_ids: List[id_type] = None, component_idx: int = None, system_idx: List[int] = None, n_opts: int = None) -> Decision
decomposition
decomposition(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, emerged_function_id: id_type = None, zoomed_function_ids: List[id_type] = None) -> Decomposition
design_space
design_space(context: SystemContext = None, system: System = None, decisions: List[Decision] = None, structural_constraints: List[StructuralConstraint] = None) -> DesignSpace
external_database
external_database(name: str = None, notes: str = None, ref: ref_type = None, source: str = None, elements: List[ExternalElement] = None, last_update: datetime = None, db_type_name: str = None, elements_type_name: str = None, linking_field_name: str = None) -> ExternalDatabase
external_element
external_element(name: str = None, notes: str = None, ref: ref_type = None, types: List[Union[Type[Element], str]] = None, metadata: dict = None, prop_override: dict = None, qoi_is_input: bool = None, auto_match_patterns: List[str] = None) -> ExternalElement
function
function(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, type_: FunctionType = SOLUTION_SPECIFIC, boundary_function: bool = None, qois: List[Qoi] = None) -> Function
get_ref
Should have same behavior as src/design-space/element-editor.vue::_getDerivedRef
multi_fulfillment
multi_fulfillment(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, function_ids: List[id_type] = None) -> MultiFulfillment
non_fulfillment
non_fulfillment(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, function_ids: List[id_type] = None) -> NonFulfillment
port
port(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None) -> Port
port_connection
port_connection(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, port_id: id_type = None, conn: ConnSpec = None, grouping: Optional[PortGroupingType] = BY_COMPONENT_INSTANCE, n_inst: List[int] = None, self_connect_allowed: bool = True) -> PortConnection
project
project(name: str = None, design_space: DesignSpace = None, design_problems: List[DesignProblem] = None, architectures: List[Architecture] = None, ref: str = None) -> Project
qoi
qoi(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, bounds: Tuple[float, float] = None, options: List[str] = None, pos_better: bool = False, ref_value: float = None, value: float = None, value_str: str = None, type_: QOIType = None, units: Union[str, Unit] = None) -> Qoi
structural_constraint
structural_constraint(name: str = None, notes: str = None, ref: ref_type = None, element_ids: List[id_type] = None, type_: StructuralConstraintType = INCOMPATIBILITY) -> StructuralConstraint
system
system(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, n_inst: List[int] = None, functions: List[Function] = None, components: List[Component] = None, concepts: List[Concept] = None, decompositions: List[Decomposition] = None, non_fulfillments: List[NonFulfillment] = None, multi_fulfillments: List[MultiFulfillment] = None, display: List[DisplayProperties] = None, ports: List[Port] = None, qois: List[Qoi] = None, systems: List[System] = None)
system_context
system_context(name: str = None, notes: str = None, ref: ref_type = None, external_ids: List[id_type] = None, functions: List[Function] = None, components: List[Component] = None, concepts: List[Concept] = None, decompositions: List[Decomposition] = None, non_fulfillments: List[NonFulfillment] = None, multi_fulfillments: List[MultiFulfillment] = None, ports: List[Port] = None, qois: List[Qoi] = None, display: List[DisplayProperties] = None) -> SystemContext
adore.api.helper.SchemaHelper
SchemaHelper(project: Project)
Helper class for finding elements in a project. Most methods apply to the design space (not architecture instances).
delete_element
Delete element from the design space and remove all its references (in the design space). Keep synchronized with design-space/design-space-editor.ts:deleteElement
get_arch_elements
get_arch_elements(architecture: Architecture, ids: List[id_type] = None, force=False) -> List[ArchElement]
Find elements in an architecture instance.
get_arch_elements_chain
get_arch_elements_chain(architecture: Architecture, ids: List[id_type] = None, force=False) -> List[Tuple[ArchElement, List[ArchElement]]]
get_create_display_properties
get_create_display_properties(element: Element, display_container: DisplayContainer, display_key: str = None) -> DisplayProperties
Display properties helper function. Make sure logic is synced with src/design-space/graph/graph-canvas.ts
get_elements_chain
get_elements_chain(ids: List[id_type] = None) -> List[Tuple[WalkElement, List[WalkElement]]]
Returns the element and its owner chain (does not include the element)
get_structural_constraints
get_structural_constraints(ids: List[id_type] = None) -> List[StructuralConstraint]
get_system_contained_top_level_elements
get_system_contained_top_level_elements(system: BaseSystem, recursive=False) -> List[Element]
walk_elements
walk_elements(callback: Callable[[Union[object, WalkElement], List[Union[object, WalkElement]]], None])
adore.api.external.ExternalDatabaseHelper
ExternalDatabaseHelper(project: Project = None, factory: SchemaFactory = None)
Helper class for creating (standalone) external element databases.
add_to_project
add_to_project(project: Project, ext_dbs: Union[ExternalDatabase, List[ExternalDatabase]], factory: SchemaFactory = None, update=True) -> List[ExternalDatabase]
Add external databases to a Project.
If update=True, existing external databases with the same ref will be merged/updated.
add_to_project_from_file
add_to_project_from_file(project: Project, path_or_data: Union[str, bytes], update=True)
Add external databases to a Project from an .adoredb file.
If update=True, existing external databases with the same ref will be merged/updated.
create_db
create_db(name: str, ref: ref_type, source: str, elements: List[ExternalElement], notes: str = None, last_update: datetime = None, db_type_name: str = None, elements_type_name: str = None, linking_field_name: str = None) -> ExternalDatabase
Create a new external database.
element
element(name: str, ref: ref_type, types: List[Union[Type[Element], str]] = None, prop_override: dict = None, qoi_is_input: bool = None, metadata: dict = None, auto_match_patterns: List[str] = None, notes: str = None) -> ExternalElement
Create a new external element.
to_file
to_file(ext_dbs: Union[ExternalDatabase, List[ExternalDatabase]], path: str)
Stores external databases in a file to be imported in a project later on.
Preferably use FILE_EXT for the file extension.