Skip to content

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:

from adore import GraphApiManager

manager = GraphApiManager.from_file('path/to/model.adore')
adore_graph
adore_graph: AdoreGraph

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.

factory
factory: SchemaFactory
helper
helper: SchemaHelper
project
project: Project
from_file
from_file(path: str) -> GraphApiManager
from_file_content
from_file_content(data: bytes) -> GraphApiManager
from_project
from_project(project: Project) -> GraphApiManager
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_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
sync(force=True)

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
sync_decision_stats(encoding_timeout: float = None)

Calculates design space and choice statistics. Can take a long time so it is recommended to set a timeout.

to_file
to_file(path: str)
to_file_contents
to_file_contents()

adore.api.factory.SchemaFactory

SchemaFactory(get_next_id_func: Optional[Callable[..., id_type]] = None)

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
from_dict
from_dict(project_dict: dict) -> Project

Instantiate a Project from a serialized dict.

from_file
from_file(path: str)

Load a Project from a .adore file.

from_file_content
from_file_content(data: bytes) -> Project

Load a Project from file contents.

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_id
get_id() -> id_type
get_ref
get_ref(name: Optional[str]) -> Optional[str]

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
to_file
to_file(path: str, project: Project)

Write a Project to a file.

to_file_content
to_file_content(project: Project) -> bytes

Serialize a Project to file contents.

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).

project
project: Project
delete_element
delete_element(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_attributes
get_attributes(ids: List[id_type] = None) -> List[Attribute]
get_components
get_components(ids: List[id_type] = None) -> List[Component]
get_concepts
get_concepts(ids: List[id_type] = None) -> List[Concept]
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_decompositions
get_decompositions(ids: List[id_type] = None) -> List[Decomposition]
get_elements
get_elements(ids: List[id_type] = None) -> List[WalkElement]
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_external_elements
get_external_elements(ids: List[id_type] = None) -> List[ExternalElement]
get_functions
get_functions(ids: List[id_type] = None) -> List[Function]
get_multi_fulfillments
get_multi_fulfillments(ids: List[id_type] = None) -> List[MultiFulfillment]
get_non_fulfillments
get_non_fulfillments(ids: List[id_type] = None) -> List[NonFulfillment]
get_port_connections
get_port_connections(ids: List[id_type] = None) -> List[PortConnection]
get_ports
get_ports(ids: List[id_type] = None) -> List[Port]
get_qois
get_qois(ids: List[id_type] = None) -> List[Qoi]
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]
get_systems
get_systems(ids: List[id_type] = None) -> List[System]
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.

from_file
from_file(path: str) -> List[ExternalDatabase]
from_file_content
from_file_content(data: bytes) -> List[ExternalDatabase]
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.

to_file_content
to_file_content(ext_dbs: Union[ExternalDatabase, List[ExternalDatabase]]) -> bytes