Skip to content

NamedDPs (Diagrams)

NamedDPs are objects that describe the elements of a co-design diagram; a graph that interconnects DPs.

They could be interpreted more as an "operad" built on DP.

Common NamedDP interface

NamedDP dataclass

Bases: Generic[FT, RT]

Generic interface of a NamedDP.

Attributes:

Name Type Description
functionalities dict[str, Poset[FT]]

a dictionary of functionalities. The order is significant.

resources dict[str, Poset[RT]]

a dictionary of resources. The order is significant.

Source code in src/act4e_mcdp/nameddps.py
@dataclass
class NamedDP(Generic[FT, RT]):
    r"""
    Generic interface of a NamedDP.

    Attributes:
        functionalities: a dictionary of functionalities. The order is significant.
        resources: a dictionary of resources. The order is significant.


    """
    functionalities: dict[str, Poset[FT]]
    resources: dict[str, Poset[RT]]

SimpleWrap

The function of SimpleWrap is to wrap a PrimiviteDP in the graph.

SimpleWrap dataclass

Bases: NamedDP[FT, RT]

A simple wrapper that wraps a PrimitiveDP.

Note that a PrimitiveDP does not have a notion of "functionality names" and "resource names". When we wrap it in a SimpleWrap, we can associate names to them.

Attributes:

Name Type Description
functionalities dict[str, Poset]

a dictionary of functionalities. The order is significant.

resources dict[str, Poset]

a dictionary of resources. The order is significant.

dp PrimitiveDP[tuple[FT, ...], tuple[RT, ...]]

the wrapped DP.

Source code in src/act4e_mcdp/nameddps.py
@dataclass
class SimpleWrap(NamedDP[FT, RT]):
    r"""
    A simple wrapper that wraps a [PrimitiveDP][act4e_mcdp.primitivedps.PrimitiveDP].


    Note that a [PrimitiveDP][act4e_mcdp.primitivedps.PrimitiveDP] does not have
    a notion of "functionality names" and "resource names". When we wrap it in a SimpleWrap,
    we can associate names to them.


    Attributes:
        functionalities (dict[str, Poset]): a dictionary of functionalities. The order is significant.
        resources (dict[str, Poset]): a dictionary of resources. The order is significant.
        dp: the wrapped DP.


    """

    dp: PrimitiveDP[tuple[FT, ...], tuple[RT, ...]]

CompositeNamedDP

The function of CompositeNamedDP is to interconnect a number of NamedDPs in a graph.

Each node of the graph is a NamedDP -- either a SimpleWrap, which wraps one DP, or another CompositeNamedDP, thus allowing recursion.

CompositeNamedDP dataclass

Bases: Generic[FT, RT], NamedDP[FT, RT]

Description of a composite NamedDP.

The nodes are in nodes dictionary and the connections are in connections list. See the class Connection for more details about the interconnections.

This is how you would describe an empty diagram:

empty = CompositeNamedDP(functionalities={}, resources={},
                         nodes={}, connections=[])

This corresponds to the DP from 1 to 1 which is always true.

This is how you would describe a diagram with two empty nodes:

two_inside = CompositeNamedDP(
    functionalities={}, resources={},
    nodes={
        'one': empty,
        'two': empty,
     }, connections=[])

This is how you would describe a diagram with one functionality and resource connected directly (identity):

P = FinitePoset({'a', 'b'}, {('a', 'b')})

two_inside = CompositeNamedDP(
    functionalities={'f1': P},
    resources={'r1': P},
    nodes={},
    connections=[
        Connection(
            source=ModelFunctionality('f1'),
            target=ModelResource('r1')
        )]
)

Attributes:

Name Type Description
functionalities dict[str, Poset]

a dictionary of functionalities

resources dict[str, Poset]

a dictionary of resources

nodes dict[str, NamedDP[Any, Any]]

the nodes inside the graph

connections list[Connection]

the connections between nodes

Source code in src/act4e_mcdp/nameddps.py
@dataclass
class CompositeNamedDP(Generic[FT, RT], NamedDP[FT, RT]):
    r"""
    Description of a composite NamedDP.

    The nodes are in `nodes` dictionary and the connections are in `connections` list.
    See the class [Connection][act4e_mcdp.nameddps.Connection] for more details about the
    interconnections.

    This is how you would describe an empty diagram:

    ```python
    empty = CompositeNamedDP(functionalities={}, resources={},
                             nodes={}, connections=[])
    ```

    This corresponds to the DP from 1 to 1 which is always true.


    This is how you would describe a diagram with two empty nodes:

    ```python
    two_inside = CompositeNamedDP(
        functionalities={}, resources={},
        nodes={
            'one': empty,
            'two': empty,
         }, connections=[])
    ```

    This is how you would describe a diagram with one functionality and resource
    connected directly (identity):

    ```python
    P = FinitePoset({'a', 'b'}, {('a', 'b')})

    two_inside = CompositeNamedDP(
        functionalities={'f1': P},
        resources={'r1': P},
        nodes={},
        connections=[
            Connection(
                source=ModelFunctionality('f1'),
                target=ModelResource('r1')
            )]
    )
    ```

    Attributes:
       functionalities (dict[str, Poset]): a dictionary of functionalities
       resources (dict[str, Poset]): a dictionary of resources
       nodes: the nodes inside the graph
       connections: the connections between nodes

    """

    functionalities: dict[str, Poset[FT]]
    resources: dict[str, Poset[RT]]
    nodes: dict[str, NamedDP[Any, Any]]
    connections: list[Connection]

The connections are described by a list of Connection objects.

Connection dataclass

A connection in a co-design graph.

Note that the source of a connection can be either:

Note that the target of a connection can be either:

Attributes:

Name Type Description
source ModelFunctionality | NodeResource

the source of the connection

target ModelResource | NodeFunctionality

the target of the connection

Source code in src/act4e_mcdp/nameddps.py
@dataclass
class Connection:
    r"""
    A connection in a co-design graph.

    Note that the **source** of a connection can be either:

    - a [ModelFunctionality][act4e_mcdp.nameddps.ModelFunctionality]: a **functionality** of the entire
    diagram
    - a [NodeResource][act4e_mcdp.nameddps.NodeResource]: a **resource** of a node.

    Note that the **target** of a connection can be either:

    - a [ModelResource][act4e_mcdp.nameddps.ModelResource]: a **resource** of the entire diagram
    - a [NodeFunctionality][act4e_mcdp.nameddps.NodeFunctionality]: a **functionality** of a node.

    Attributes:
        source: the source of the connection
        target: the target of the connection

    """
    source: ModelFunctionality | NodeResource
    target: ModelResource | NodeFunctionality

These are the utility classes that describe the interconnection.

ModelResource dataclass

A resource of the entire diagram. Used by the Connection class.

Attributes:

Name Type Description
resource str

the resource name

Source code in src/act4e_mcdp/nameddps.py
@dataclass
class ModelResource:
    """
    A resource of the entire diagram.
    Used by the [Connection][act4e_mcdp.nameddps.Connection] class.

    Attributes:
        resource: the resource name

    """

    resource: str

ModelFunctionality dataclass

A functionality of the entire diagram. Used by the Connection class.

Attributes:

Name Type Description
functionality str

the functionality name

Source code in src/act4e_mcdp/nameddps.py
@dataclass
class ModelFunctionality:
    """
    A functionality of the entire diagram.
    Used by the [Connection][act4e_mcdp.nameddps.Connection] class.

    Attributes:
        functionality: the functionality name
    """

    functionality: str

NodeResource dataclass

A resource of a node. Used by the Connection class.

Attributes:

Name Type Description
node str

the node name

resource str

the resource name

Source code in src/act4e_mcdp/nameddps.py
@dataclass
class NodeResource:
    """
    A resource of a node.
    Used by the [Connection][act4e_mcdp.nameddps.Connection] class.

    Attributes:
        node: the node name
        resource: the resource name

    """

    node: str
    resource: str

NodeFunctionality dataclass

A functionality of a node. Used by the Connection class.

Attributes:

Name Type Description
node str

the node name

functionality str

the functionality name

Source code in src/act4e_mcdp/nameddps.py
@dataclass
class NodeFunctionality:
    """
    A functionality of a node.
    Used by the [Connection][act4e_mcdp.nameddps.Connection] class.

    Attributes:
        node: the node name
        functionality: the functionality name
    """

    node: str
    functionality: str