Class ProcessModelGraph

java.lang.Object
neqsim.process.processmodel.graph.ProcessModelGraph
All Implemented Interfaces:
Serializable

public class ProcessModelGraph extends Object implements Serializable
Represents a hierarchical process model as a graph of graphs.

This class handles the case where multiple ProcessSystem objects are combined into a ProcessModule. It maintains both:

  • Individual graphs for each ProcessSystem (sub-graphs)
  • A unified flattened graph for the entire model
  • A module-level graph showing inter-system connections

Use cases:

  • Analyzing complex process plants with multiple interacting subsystems
  • Identifying cross-system stream connections
  • Determining calculation order across subsystems
  • AI/ML analysis of hierarchical process structures
Version:
1.0
Author:
NeqSim
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getModelName

      public String getModelName()
      Returns:
      the name of this process model
    • getSubSystemGraphs

      public List<ProcessModelGraph.SubSystemGraph> getSubSystemGraphs()
      Returns:
      list of sub-system graphs
    • getFlattenedGraph

      public ProcessGraph getFlattenedGraph()
      Returns:
      the flattened graph containing all equipment from all sub-systems
    • getInterSystemConnections

      public List<ProcessModelGraph.InterSystemConnection> getInterSystemConnections()
      Returns:
      list of connections between sub-systems
    • getSubSystemCount

      public int getSubSystemCount()
      Returns:
      total number of sub-systems
    • getTotalNodeCount

      public int getTotalNodeCount()
      Returns:
      total number of nodes across all sub-systems
    • getTotalEdgeCount

      public int getTotalEdgeCount()
      Returns:
      total number of edges across all sub-systems
    • getInterSystemConnectionCount

      public int getInterSystemConnectionCount()
      Returns:
      number of cross-system connections
    • getSubSystem

      public ProcessModelGraph.SubSystemGraph getSubSystem(String systemName)
      Get sub-system graph by name.
      Parameters:
      systemName - the name of the sub-system
      Returns:
      the sub-system graph, or null if not found
    • getSubSystemByIndex

      public ProcessModelGraph.SubSystemGraph getSubSystemByIndex(int index)
      Get sub-system graph by index.
      Parameters:
      index - the execution index
      Returns:
      the sub-system graph, or null if not found
    • getConnectionsFrom

      public List<ProcessModelGraph.InterSystemConnection> getConnectionsFrom(String systemName)
      Get connections from a specific sub-system.
      Parameters:
      systemName - the name of the source sub-system
      Returns:
      list of connections originating from this sub-system
    • getConnectionsTo

      public List<ProcessModelGraph.InterSystemConnection> getConnectionsTo(String systemName)
      Get connections to a specific sub-system.
      Parameters:
      systemName - the name of the target sub-system
      Returns:
      list of connections going to this sub-system
    • hasCycles

      public boolean hasCycles()
      Check if the model has any cycles.
      Returns:
      true if any sub-system or the overall model has cycles
    • analyzeCycles

      public ProcessGraph.CycleAnalysisResult analyzeCycles()
      Analyzes cycles across the entire model.
      Returns:
      cycle analysis result for the flattened graph
    • getCalculationOrder

      public List<ProcessEquipmentInterface> getCalculationOrder()
      Get the calculation order for the entire model.
      Returns:
      list of equipment in topological order, or null if cycles exist
    • partitionForParallelExecution

      public ProcessGraph.ParallelPartition partitionForParallelExecution()
      Partition the entire model for parallel execution.
      Returns:
      parallel partition result
    • getNodeFeatureMatrix

      public double[][] getNodeFeatureMatrix()
      Get node feature matrix for the entire model (GNN compatible).
      Returns:
      2D array [nodes][features]
    • getEdgeIndexTensor

      public int[][] getEdgeIndexTensor()
      Get edge index tensor for the entire model (GNN compatible).
      Returns:
      2D array [2][edges] with [0]=source indices, [1]=target indices
    • getSummary

      public String getSummary()
      Generate a human-readable summary of the model graph.
      Returns:
      summary string
    • getNodeToSubSystemMap

      public Map<ProcessNode, String> getNodeToSubSystemMap()
      Get a map showing which sub-system each node belongs to.
      Returns:
      map from node to sub-system name
    • getStatistics

      public Map<String,Object> getStatistics()
      Get statistics about the model structure.
      Returns:
      map of statistic name to value
    • getSubSystemDependencies

      public Map<String, Set<String>> getSubSystemDependencies()
      Build a dependency graph between sub-systems based on inter-system connections.
      Returns:
      map from sub-system name to set of sub-system names it depends on
    • partitionSubSystemsForParallelExecution

      public ProcessModelGraph.ModuleParallelPartition partitionSubSystemsForParallelExecution()
      Partition sub-systems into levels for parallel execution. Sub-systems at the same level have no dependencies between them and can execute concurrently.

      Uses topological sorting on the sub-system dependency graph to determine execution levels.

      Returns:
      partition of sub-systems into parallel execution levels
    • isParallelSubSystemExecutionBeneficial

      public boolean isParallelSubSystemExecutionBeneficial()
      Check if parallel execution of sub-systems would be beneficial. Returns true if there are at least 2 sub-systems that can run in parallel at some level.
      Returns:
      true if parallel execution would provide speedup
    • getIndependentSubSystems

      public List<ProcessModelGraph.SubSystemGraph> getIndependentSubSystems()
      Get the list of sub-systems that have no dependencies (can start immediately).
      Returns:
      list of independent sub-systems
    • getSubSystemCalculationOrder

      public List<ProcessModelGraph.SubSystemGraph> getSubSystemCalculationOrder()
      Get sub-systems in topological order (respecting dependencies).
      Returns:
      list of sub-systems in execution order, or null if cycles exist
    • toString

      public String toString()
      Overrides:
      toString in class Object