sampo.structurator.base#

Overview#

Function#

make_new_node_id(work_unit_id, ind)

Creates an auxiliary id for restructuring the graph

fill_parents_to_new_nodes(origin_node, id2new_nodes, restructuring_edges2new_nodes_id, use_lag_edge_optimization)

Restores edges for transformed node

split_node_into_stages(origin_node, restructuring_edges, id2new_nodes, restructuring_edges2new_nodes_id, use_lag_edge_optimization)

Splits the node into stages according to the lags in the restructuring edges.

graph_restructuring(wg, use_lag_edge_optimization)

Rebuilds all edges into Finish-Start and Inseparable-Finish-Start edges

Attributes#

STAGE_SEP

-

Functions#

sampo.structurator.base.make_new_node_id(work_unit_id: str, ind: int) str#

Creates an auxiliary id for restructuring the graph

Parameters:
  • work_unit_id – str - id of work unit

  • ind – int - sequence number of work_unit stage

Returns:

auxiliary_id: str - an auxiliary id for the work unit

sampo.structurator.base.fill_parents_to_new_nodes(origin_node: sampo.schemas.graph.GraphNode, id2new_nodes: sampo.schemas.graph.GraphNodeDict, restructuring_edges2new_nodes_id: dict[tuple[str, str], str], use_lag_edge_optimization: bool)#

Restores edges for transformed node

Parameters:
  • origin_node – GraphNode - The original unconverted node

  • id2new_nodes – GraphNodeDict - Dictionary with restructured new nodes id where the restructured nodes are written

  • restructuring_edges2new_nodes_id – dict[tuple[str, str], str] - Dictionary for matching edges in the original work graph and IDs of new nodes that logically match those edges

  • use_lag_edge_optimization – bool - if true - considers lags amount in edges, otherwise considers lags equal to zero and LagFinishStart edges as FinishStart edges

Returns:

Nothing

sampo.structurator.base.split_node_into_stages(origin_node: sampo.schemas.graph.GraphNode, restructuring_edges: list[tuple[sampo.schemas.graph.GraphEdge, bool]], id2new_nodes: sampo.schemas.graph.GraphNodeDict, restructuring_edges2new_nodes_id: dict[tuple[str, str], str], use_lag_edge_optimization: bool)#

Splits the node into stages according to the lags in the restructuring edges. For all stages except the last one, the id changes. For the last one, the id remains the same, so that it is more convenient to restore the edges. The resulting nodes are chained together by Inseparable-Finish-Start edges.

Parameters:
  • restructuring_edges – list[tuple[GraphEdge, bool]] - list of restructuring edges and bool flag of reversion

  • origin_node – GraphNode - Node to be divided into stages

  • id2new_nodes – GraphNodeDict - Dictionary with restructured new nodes id where the restructured nodes will be written

  • restructuring_edges2new_nodes_id – dict[tuple[str, str], str] - Dictionary for matching edges in the original work graph and IDs of new nodes that logically match those edges

  • use_lag_edge_optimization – bool - if true - considers lags amount in edges, otherwise considers lags equal to zero and LagFinishStart edges as FinishStart edges

Returns:

Nothing

sampo.structurator.base.graph_restructuring(wg: sampo.schemas.graph.WorkGraph, use_lag_edge_optimization: bool | None = False) sampo.schemas.graph.WorkGraph#

Rebuilds all edges into Finish-Start and Inseparable-Finish-Start edges with the corresponding rebuilding of the nodes and returns new work graph

Parameters:
  • wg – WorkGraph - The graph to be converted

  • use_lag_edge_optimization – bool - if true - considers lags amount in edges, otherwise considers lags equal to zero and LagFinishStart edges as FinishStart edges

Returns:

new_work_graph: WorkGraph - restructured graph

Attributes#

sampo.structurator.base.STAGE_SEP = '_stage_'#