LLMs in Process Diagram Engineering: From Optimal PFDs to Validated P&IDs

arXiv cs.AI Papers

Summary

This paper introduces P&ID Pilot, an end-to-end AI pipeline combining genetic algorithms and LLMs to generate optimal process flow diagrams (PFDs) and transform them into validated piping and instrumentation diagrams (P&IDs), reducing manual engineering effort.

arXiv:2608.11220v1 Announce Type: new Abstract: Nowadays, the creation of a process flow diagram (PFD) and its subsequent transformation into a piping and instrumentation diagram (P&ID) is predominantly performed manually. Applying artificial intelligence in the task could potentially lead not only to process automation and time savings, but also to financial gains by exploring numerous diagram's topology options and reducing manual labor. This research presents P&ID Pilot - a practical end-to-end AI pipeline capable of handling flowsheet developing for both stages. The first stage focuses on PFD synthesis, whereas the second is directed toward modifying the generated PFD into P&ID. After comparing four different methods, the hybrid approach combining genetic algorithms (GA) and large language models (LLM) is shown to generate the optimal valid PFD topology, achieving the lowest loss value among all the methods, while satisfying the required outlet flow parameters without engineering-rule violations. For the second stage, the proposed LLM-based agent successfully transforms the generated PFD into a source-grounded P&ID by producing validated, executable modifications through a restricted engineering software development kit, achieving 100% execution success while maintaining compliance with domain-specific rules and reference graph structures. This unified pipeline - coupling GA/LLM-driven synthesis with an LLM-based transformation agent - offers a feasible path toward end-to-end process design automation by producing validated, deployable outputs and substantially reduces manual engineering effort.
Original Article
View Cached Full Text

Cached at: 08/13/26, 03:21 PM

# LLMs in Process Diagram Engineering: From Optimal PFDs to Validated P&IDs
Source: [https://arxiv.org/html/2608.11220](https://arxiv.org/html/2608.11220)
Sergei VoitovSkoltech, AI Center, Moscow, RussiaSergei ShumilinSkoltech, AI Center, Moscow, Russias\.shumilin@skoltech\.ruEvgeny BurnaevSkoltech, AI Center, Moscow, RussiaAIRI, Moscow, Russia

###### Abstract

Nowadays, the creation of a process flow diagram \(PFD\) and its subsequent transformation into a piping and instrumentation diagram \(P&ID\) is predominantly performed manually\. Applying artificial intelligence \(AI\) in the task could potentially lead not only to process automation and time savings, but also to financial gains by exploring numerous diagram’s topology options and reducing manual labor\. This research presents P&ID Pilot \- a practical end\-to\-end AI pipeline capable of handling flowsheet developing for both stages\. The first stage focuses on PFD synthesis, whereas the second is directed toward modifying the generated PFD into P&ID\. After comparing four different methods, the hybrid approach combining genetic algorithms \(GA\) and large language models \(LLM\) is shown to generate the optimal valid PFD topology, achieving the lowest loss value among all the methods, while satisfying the required outlet flow parameters without engineering\-rule violations\. For the second stage, the proposed LLM\-based agent successfully transforms the generated PFD into a source\-grounded P&ID by producing validated, executable modifications through a restricted engineering software development kit \(SDK\), achieving 100% execution success while maintaining compliance with domain\-specific rules and reference graph structures\. This unified pipeline \- coupling GA/LLM\-driven synthesis with an LLM\-based transformation agent \- offers a feasible path toward end\-to\-end process design automation by producing validated, deployable outputs and substantially reduces manual engineering effort\.

Keywords:process flow diagram, piping and instrumentation diagram, large language model, optimization

## 1Introduction

Process flow diagrams \(PFDs\) and piping and instrumentation diagrams \(P&IDs\) are central artefacts in process engineering\. PFDs describe the main process topology, major equipment, and material streams, whereas P&IDs provide a more detailed representation of process equipment, valves, piping, control structure, and instrumentation\[[19](https://arxiv.org/html/2608.11220#bib.bib31)\]\. Together, these diagrams support design coordination, process analysis, safety review, documentation, and subsequent operation of industrial facilities\. The need for consistent digital representations of such engineering information has motivated standardization efforts, including DEXPI\-based data exchange for P&IDs\[[6](https://arxiv.org/html/2608.11220#bib.bib14)\]and graph\- or sequence\-based representations of process flowsheets such as SFILES 2\.0\[Vogel\_2023\]\.

Despite the availability of computer\-aided engineering tools, the development and modification of PFDs and P&IDs remain a tedious and time\-consuming task that offers significant potential for cost reduction and faster development cycles\[[28](https://arxiv.org/html/2608.11220#bib.bib32)\]\. Engineers must preserve process logic, equipment configuration constraints, connectivity, control structure, and diagram consistency while exploring alternative designs or applying local modifications\. These operations are often repetitive but cannot be treated as purely mechanical, because even small changes in topology, attributes, or control links may invalidate downstream engineering assumptions\. As a result, diagram preparation and revision are associated with considerable manual effort and cognitive load\.

Recent work has begun to investigate artificial intelligence \(AI\) methods for related tasks\. Data\-driven models have been used for flowsheet autocompletion and control\-structure prediction from process topologies\[[29](https://arxiv.org/html/2608.11220#bib.bib6),[12](https://arxiv.org/html/2608.11220#bib.bib4),[4](https://arxiv.org/html/2608.11220#bib.bib3)\]\. Reinforcement learning \(RL\) combined with graph convolutional neural networks \(GCNN\) has also been proposed for flowsheet synthesis and optimization\[[26](https://arxiv.org/html/2608.11220#bib.bib9),[23](https://arxiv.org/html/2608.11220#bib.bib19)\]\. In parallel, large language models \(LLMs\) have been applied to P&ID understanding and generation, including natural\-language interaction with DEXPI\-derived graph representations\[[2](https://arxiv.org/html/2608.11220#bib.bib1)\]and agentic creation of P&ID diagrams from natural\-language descriptions\[[10](https://arxiv.org/html/2608.11220#bib.bib2)\]\. These studies indicate that AI can support process diagram engineering, but they also highlight the importance of structured representations and controlled interaction mechanisms\.

The present work addresses the problem from a full\-cycle perspective\. We consider a technological diagram as a structured graph object whose nodes, edges, and attributes encode equipment, streams, connections, and engineering metadata\. This representation provides a common computational substrate for optimization, model\-based interpretation, and controlled modification\. In contrast to unconstrained generation or direct editing of a serialized engineering file, the proposed P&ID stage uses a software development kit \(SDK\)\-bounded interaction model: an LLM interprets a user request and generates executable actions, while all access to the diagram is mediated by predefined graph operations and validation procedures\.

The contribution of this work is threefold\. First, we present a pipeline that connects optimal PFD synthesis with subsequent P&ID\-oriented interaction\. Second, we compare several approaches to PFD generation within a graph\-based process\-design setting\. Third, we introduce a controlled LLM\-based workflow for P&ID analysis and modification, and evaluate it on domain\-grounded executable rules over a graph representation of a P&ID\. The overall workflow is illustrated in Figure[1](https://arxiv.org/html/2608.11220#S1.F1)\.

![Refer to caption](https://arxiv.org/html/2608.11220v1/x1.png)Figure 1:Visual abstract of the Full Cycle AI pipeline\.Core design principle: The genetic algorithm combined with LLM repair for PFD synthesis \+ restricted\-SDK P&ID transformation enables full cycle process pipeline\.
## 2Background

There are several studies discussing the application of methods based either on the principles of AI or on basic mathematical principles for PFD and P&ID analysis, generation, completion and editing\.

### 2\.1LLM usage

\[[2](https://arxiv.org/html/2608.11220#bib.bib1)\]discusses the ability of Large Language Model \(LLM\) to understand and analyze DEXPI XML P&Ds\. The authors suggest transforming DEXPI XML file into a graph representation that can be stored in Neo4j database as a knowledge graph\. Afterwards, this knowledge graph is attached as GraphML file to the context when prompting an LLM with a question\. Experiments prove that the LLM can accurately answer P&ID\-related questions\.

The work\[[10](https://arxiv.org/html/2608.11220#bib.bib2)\]also primarily focuses on the DEXPI XML format\. A specific Automatic Creation of P&ID \(ACPID\) Copilot is developed that sequentially generates DEXPI XML based on a user’s text description and combines several techniques such as a multi\-step agentic workflow over a pre\-trained LLM, domain specific language translation, human\-in\-the\-loop validation, etc\. The approach is compared with zero\-shot and few\-shot methods for the GPT\-4\-Turbo LLM model on soundness and completeness metrics and the authors conclude that the proposed Copilot achieves the best result on both metrics\.

The next group of papers\[[4](https://arxiv.org/html/2608.11220#bib.bib3)\]and\[[12](https://arxiv.org/html/2608.11220#bib.bib4)\]present a data\-driven method for the prediction of control structures for flowsheets \- the first step towards turning a PFD into a P&ID\. Though the goal of both papers is similar, they differ slightly in their architectural setup \- specifically, input data handling\. In\[[4](https://arxiv.org/html/2608.11220#bib.bib3)\], a graph\-to\-sequence approach is presented: a Graph\-to\-SFILES model consisting of Graph Neural Network \(GNN\) as an encoder and a Transformer architecture as a decoder is applied\. It takes the flowsheet topology as a graph input and returns a control\-extended flowsheet as a sequence in the Simplified Flowsheet Input\-Line Entry\-System \(SFILES\) 2\.0 notation\[Vogel\_2023\]\(the format was adapted from the text\-based Simplified Molecule Input\-Line Entry\-System \(SMILES\) \- an example of natural language processing applications in chemistry\[[7](https://arxiv.org/html/2608.11220#bib.bib10)\]\)\. In contrast, in\[[12](https://arxiv.org/html/2608.11220#bib.bib4)\], the authors study a sequence\-to\-sequence approach: the input topology of PFDs is transformed into strings using SFILES 2\.0 notation \(the vice\-versa procedure is also used on the output to obtain graph data from the predicted strings\) and the core architecture of the model is a T5 transformer which performs translation task in which PFDs without control structures are translated to PFDs with control structures\. Both papers use quite the same principle in training and model evaluation to perform a fair comparison between the methods\. Overall, both show quite promising results in which the graph\-to\-sequence model outperforms sequence\-to\-sequence model on the small datasets, whereas for larger datasets the opposite trend is observed\.

A quite similar sequence\-to\-sequence approach for PFDs autocompletion is described in\[[29](https://arxiv.org/html/2608.11220#bib.bib6)\]\. Inspired by the text translation task, the authors use a transformer\-based language model that has only an auto\-regressive decoder, while representing flowsheets in SFILES 2\.0 notation\. The model is pre\-trained on the synthetic data and then fine\-tuned via transfer learning step on real PFD topologies\. The model’s performance evaluations prove the concept’s validity and suggest potential application for AI\-aided assistance for chemical engineers\.

### 2\.2RL usage

Another innovative approach for PFD creation is discussed in\[[26](https://arxiv.org/html/2608.11220#bib.bib9)\]\. The authors study a combination of GCNN and RL for the optimal flowsheet synthesis task\. Here, the GCNN is applied to flowsheets \(which are used as graphs in this case\) to represent them as numerical embeddings that are passed as input to the RL process\. The latter consists of an actor\-critic pair, an environment and a reward function based on ab economic formula\. The core architectural components are Multi\-Layer perceptron \(MLP\) and a GCNN\. The results show that this method allows the generation of valid, economically optimal PFD\. The same approach is also studied in\[[23](https://arxiv.org/html/2608.11220#bib.bib19)\]\. The main fundamental changes from the original paper are the use of novel proximal policy optimization and integration of masked agents\. Tests on the creation of viable chemical process flowsheets demonstrate the efficiency of the proposed method\.

### 2\.3Genetic Algorithms

Genetic algorithms \(GA\), first introduced by J\. Holland in\[[13](https://arxiv.org/html/2608.11220#bib.bib7)\], are actively used as optimization methods\. Described as a stochastic methods and based on natural selection, these algorithms use an iterative search strategy to find an optimal solution via specific genetic operations \(crossover, mutation, selection, etc\.\)\. In many works\[[1](https://arxiv.org/html/2608.11220#bib.bib20),[20](https://arxiv.org/html/2608.11220#bib.bib22),[11](https://arxiv.org/html/2608.11220#bib.bib21)\], the efficiency of GAs has been proven in nonlinear optimization tasks with non\-trivial objective function and various constraints with no exception for optimal PFD creation\[[25](https://arxiv.org/html/2608.11220#bib.bib8)\]\. Here GA is applied to generate the optimum configuration of a hybrid membrane/cryogenic system for a three membrane unit process\. The results demonstrate the potential of the technique\.

## 3Optimal PFD Synthesis

Process flowsheet synthesis is the systematic application of computational techniques to generate process flowsheets by optimizing design and operation variables, equipment types, and process configuration\[[7](https://arxiv.org/html/2608.11220#bib.bib10)\]\.

In this section we perform comparison of four various methods for PFD synthesis \- a multi\-agent LLM approach inspired by\[[2](https://arxiv.org/html/2608.11220#bib.bib1)\], RL/GCNN\-based approach from\[[26](https://arxiv.org/html/2608.11220#bib.bib9)\], GA and hybrid GA/LLM approach \- applied to a common test case to select the most suitable method based on accuracy, and optimization time\.

The remainder of the section structured as follows:[3\.1](https://arxiv.org/html/2608.11220#S3.SS1)provides a test case description, the following subsection[3\.2](https://arxiv.org/html/2608.11220#S3.SS2)presents our custom Python solver, the subsequent subsections[3\.3](https://arxiv.org/html/2608.11220#S3.SS3),[3\.4](https://arxiv.org/html/2608.11220#S3.SS4),[3\.5](https://arxiv.org/html/2608.11220#S3.SS5)and[3\.6](https://arxiv.org/html/2608.11220#S3.SS6)describe each approach in detail, and[section˜3\.7](https://arxiv.org/html/2608.11220#S3.SS7)presents a comparison and discussion of the received results\.

### 3\.1Test case description

To test the functionality of the system, a suitable task is selected that is moderately simple yet close to real\-life processes\. As a result the following scenario is proposed \- generating the optimal PFD for an oil treatment unit \(OTU\)\. Such units are used for the preliminary separation of crude oil from oil fields into oil, gas and formation water to achieve saleable quality\.

The main operations in an OTU include gas separation, water separation, pressure increase, and flow heating\.

The input data consist of an inlet flow properties \(physical and chemical properties\), a desired outlet flow properties specified by the user, and an equipment database containing various components used for PFD synthesis such as pumps, heat exchangers, water and gas separators, ball valves and pipe tees\.

### 3\.2Solver description

The solver is implemented as a Python module for calculating flows and checking constraints in the generated PFD\. After constructing the graph, the solver propagates flow properties through all nodes of the graph\.

Separate Python functions are implemented for each type of equipment, such as calculating of pressure increase in pumps according to specified Q\-H characteristics, calculating of temperature changes in the heat exchanger based on a simplified heat balance, etc\. More detailed information on the equations used in the calculation process is provided in Appendix[A](https://arxiv.org/html/2608.11220#A1)Additionally, the solver supports branching and combining flows\. The detected violations of constraints are stored in the nodes of the graph and then taken into account in the loss \(fitness\) function\. A general algorithmic description of the solver is provided in Appendix[B](https://arxiv.org/html/2608.11220#A2)in addition with the loss calculation function\.

### 3\.3Multi\-agent system approach

It should be noted that the architecture in\[[2](https://arxiv.org/html/2608.11220#bib.bib1)\]allows the LLM only to see and understand the entire flowsheet, but not to make changes according to user requests\. However, this can be implemented by sending specialized Cypher requests\. Cypher is a declarative query language for graphs that allows to perform efficient queries on data in a property graph\[[15](https://arxiv.org/html/2608.11220#bib.bib23)\]\. Given that LLM sees and understands the entire flowsheet as part of the context, it can be assumed that it will be able to make changes to the graph representation by sending generated Cypher requests\.

Many publications\[[8](https://arxiv.org/html/2608.11220#bib.bib25),[16](https://arxiv.org/html/2608.11220#bib.bib26),[30](https://arxiv.org/html/2608.11220#bib.bib27)\]confirm the effectiveness of using not a single LLM, but a group of LLM agents where each agent performs a specific task while interacting with other agents across various engineering problems, with no exception of the chemical industry\[[24](https://arxiv.org/html/2608.11220#bib.bib24)\]\. Such a system is called Multi\-agent system \(MAS\)\. Thus, in our case, the following MAS architecture will be used, as shown in Figure[2](https://arxiv.org/html/2608.11220#S3.F2)\.

The whole system works in the following way\. A user sends an optimization request which should contain initial flow properties and target flow properties in natural language to the system\. The request is merged with a context that, in this case, is a GraphML file \- a description of the current graph from Neo4j\. It is then processed by an Optimization Agent in two steps\. Firstly, it uses the Retrieval Augmented Generation \(RAG\) technique to extract relevant equipment from an equipment database which is preliminarily populated by the user\. Secondly, given the retrieved equipment set, the agent composes an optimization plan and a list of Cypher queries to build the PFD according to the plan\. Then this list is passed to the next agent \- the Cypher Validation Agent to assess the queries for syntax and logic errors\. If there are any errors, it gives detailed feedback on them to the Optimizer so the queries could be fixed and passed again\. The Cypher validation phase is followed by the scheme validation step which consists of three parts: execution of Cypher queries, enriching the updated knowledge graph with the solver, and a PFD check by the Scheme Validation Agent\. The list of validated Cypher queries is applied, thus the knowledge graph stored in Neo4j is turned into the planned PFD\. Afterwards, this new diagram is exported as a graph and passed as a dictionary of nodes, edges and their attributes to the solver\. The solver performs flow calculations and produces an enriched graph and the latter is then analyzed by the Scheme Validation Agent for the presence of orphaned nodes, structural integrity, reaching and whether the target outlet flow properties are reached\.

![Refer to caption](https://arxiv.org/html/2608.11220v1/x2.png)Figure 2:Architecture of the proposed MAS\.The Optimization Agentreceives the user’s natural\-language request along with the knowledge graph as additional context and processes it in two steps: retrieves relevant equipment using RAG and generates an optimization plan involving using the retrieved equipment and a list of corresponding Cypher queries\.The Cypher Validation Agentchecks the generated queries for any errors and, if errors are detected, generates feedback and sends it back to theOptimization Agent; otherwise, the validated query list is passed to the next agent\.The Scheme Validation Agentexecutes the queries and checks the updated knowledge graph \(i\.e\., the generated PFD\) for compliance with engineering and topology constraints, If violations are detected, the feedback is passed to theOptimization Agentto correct the detected violations\. If all checks are passed, the valid scheme is returned to the user\.The suggested system was tested not only on the test case but on various LLMs with different parameter sizes as well\. The models are served locally via vLLM\. The following LLMs were tested: Qwen3\.6\-35B\-A3B\[[22](https://arxiv.org/html/2608.11220#bib.bib16)\], gpt\-oss:120B\[[21](https://arxiv.org/html/2608.11220#bib.bib17)\], Qwen3\.5\-397B\-A17B\-FP8\[[27](https://arxiv.org/html/2608.11220#bib.bib15)\]and DeepSeek\-V4\-Pro\[[5](https://arxiv.org/html/2608.11220#bib.bib18)\]\. For a fair LLM comparison, all agents’ system prompts remained unchanged as well as the temperature parameters\. A sample of agents’ interaction is presented in Appendix[C](https://arxiv.org/html/2608.11220#A3)\. The comparison results are shown in Table[1](https://arxiv.org/html/2608.11220#S3.T1)\. A sample of a generated PFD is depicted in Figure[3](https://arxiv.org/html/2608.11220#S3.F3)\.

Overall, the best results are demonstrated by the Qwen3\.6\-35B\-A3B and gpt\-oss:120B models: despite the PFD from the Qwen model being more optimal, it has minor issues with closing its branches, while the diagram from the other model is closer to the valid scheme\. On the contrary, the larger models struggled to converge and provide a valid generated PFD\.

Table 1:Comparison of various LLM for MAS\.ModelsQwen3\.6\-35B\-A3Bgpt\-oss:120BQwen3\.5\-397B\-A17B\-FP8DeepSeek\-V4\-ProParameter size, B351203971600Context size \(knowledge graph size\)2101 \(1293\)2101 \(1293\)2101 \(1293\)2101 \(1293\)Number of queries to LLM13351313Number of iterations61377Work time, sec284\.930875\.607\-\-Loss value186342\.936212997\.603\-\-CommentsIncomplete PFDValid PFDCould not convergeCould not converge

![Refer to caption](https://arxiv.org/html/2608.11220v1/images/valid_scheme_gpt_120_17-06-2026.png)

![Refer to caption](https://arxiv.org/html/2608.11220v1/images/mas_graph.png)

Figure 3:PFD of the OTU generated by the proposed MAS \(model \-gpt\-oss:120B\)\.Top: knowledge graph representation stored in the Neo4j graph database;Bottom: graph representation of the corresponding PFD\. Overall, the generated diagram contains23 nodes and 22 edges\. No engineering or topology violations are detected
### 3\.4Genetic algorithm

A standard GA workflow consists of the following iterative steps\[[9](https://arxiv.org/html/2608.11220#bib.bib12)\]:

1. 1\.An initial population of random chromosomes \(topologies\) is generated\.
2. 2\.A fitness \(loss\) value is calculated for each chromosome\.
3. 3\.Chromosomes with the best fitness values are selected from the current population for further operations \(the selection method is treated as a hyperparameter\)\.
4. 4\.A new set of chromosomes is created by applying genetic operations \(crossover, mutation, etc\.\) to the selected chromosomes\.
5. 5\.The population is updated with the new set, and Steps 2–4 are repeated until the maximum number of generations is reached\.

![Refer to caption](https://arxiv.org/html/2608.11220v1/images/ga_loss_function.png)Figure 4:Evolution of the GA fitness value during optimization\. Over1000 generations, corresponding to the evaluation of 780,800 chromosomes, the fitnessis reduced by more than a factor of seven\.The convergence trend demonstrates the ability of the GA to progressively improve candidate PFDs\.For correct fitness calculation, all evaluated chromosomes are converted into graph representation\. The experiments for GA evaluation are conducted using the specific Python package PyGAD\[[9](https://arxiv.org/html/2608.11220#bib.bib12)\]\. The plot demonstrating the fitness function evolution through the number of generation is shown in Figure[4](https://arxiv.org/html/2608.11220#S3.F4.1)and the PFD generated by the GA is depicted in Figure[5](https://arxiv.org/html/2608.11220#S3.F5)\.

![Refer to caption](https://arxiv.org/html/2608.11220v1/images/ga_html_graph.png)Figure 5:PFD of the OTU generated by the GA\. Overall, the generated diagram contains18 nodes and 17 edges\.Although the optimization significantly improves the objective value, node\-level validation violations remain, indicating that the generated PFD does not fully satisfy the engineering constraints\.
### 3\.5Reinforcement learning and Graph Convolutional Neural Networks

This approach is inspired by two key works:\[[26](https://arxiv.org/html/2608.11220#bib.bib9)\]and\[[18](https://arxiv.org/html/2608.11220#bib.bib13)\]\. The first one introduces the whole concept of RL and GCNN application for flowsheet synthesis as discussed in Section[2\.2](https://arxiv.org/html/2608.11220#S2.SS2)while the other paper studies the consept of LLM\-as\-a\-reward in RL\. We enhanced the original idea by introducing an LLM\-as\-a\-reward policy mainly to increase system flexibility\.

The whole system functions in the following way\. In the beginning the developed graph is transformed into a numerical embedding \- a flowsheet fingerprint\. Afterwards the fingerprint is passed to the Actor, which attempts to extend the current graph\. This decision is made on three levels: at the level 1, the Agent using a GCNN selects an open stream to replace with equipment; at level 2 the equipment type is chosen using an MLP \(discrete decision\); and finally, during the third level, the equipment design variables are defined \(continuous decision\)\. It is worth noting that the decision is made by an MLP, and a separate MLP has been developed for each type of equipment\. The extended graph is then passed to the Critic to evaluate the Actor performance\. This process continues iteratively\. A more detailed description of every aspect can be found in the original paper\[[26](https://arxiv.org/html/2608.11220#bib.bib9)\]\.

The DeepSeek\-V4\-Pro LLM model was used in this experiment\. The PFD generated by RL/GCNN can be found in the Figure[6](https://arxiv.org/html/2608.11220#S3.F6)\.

![Refer to caption](https://arxiv.org/html/2608.11220v1/images/rl_graph_high.png)Figure 6:PFD of the OTU generated by the RL/GCNN approach\. Overall, the generated diagram contains14 nodes and 13 edges\.Although the resulting topology is executable, several topology validation violations remain, preventing the generated process flow diagram from satisfying all engineering requirements\.
### 3\.6Hybrid approach

As can be seen from the results above \- every tested method has its own advantages\. The GA approach is capable of evaluating thousands of topology options, while the LLM\-based MAS has been proven to be effective at modifying existing topologies\. Given these circumstances, we decided to additionally test a hybrid approach which merges these two strengths by combining the techniques\. Initially, an initial topology is generated by the GA\. Afterwards, it is then modified by the LLM \(the used model is gpt\-oss:120, the prompt is provided in Appendix[D](https://arxiv.org/html/2608.11220#A4)\) to fix any detected errors provided by the deterministic validator\.

The final valid scheme received from the hybrid approach is shown in Figure[7](https://arxiv.org/html/2608.11220#S3.F7)\.

![Refer to caption](https://arxiv.org/html/2608.11220v1/images/hybrid_graph.png)Figure 7:PFD of the OTU generated by the hybrid GA/LLM approach\. Overall, the generated diagram contains29 nodes and 28 edges\.No engineering or topology violations are detected, demonstrating that the proposed hybrid framework successfully generates a fully valid PFD\.
### 3\.7Results comparison

The obtained results for all methods are shown in Table[2](https://arxiv.org/html/2608.11220#S3.T2)\. It can be seen that the valid PFD with no violations that comes closest to all the target flow properties was produced by the hybrid approach\. The remaining methods generate the PFDs that either do not come as close to the target flow property values as the hybrid method to target flow properties values, or have violation issues \(topological and/or physical\)\.

Table 2:Comparison of optimal PFD generation approaches\.MethodTime to generate, sLoss MetricCostCommentsGA \(Baseline\)505\.60\.808×1060\.808\\times 10^\{6\}31040Higher outlet deviation; has node violationsMAS875\.60\.213×1060\.213\\times 10^\{6\}42900Higher outlet deviationRL/GCNN1862\.255\.939×10655\.939\\times 10^\{6\}17150Higher outlet deviation; has topology violationsHybrid \(GA/LLM\)2382\.50\.089×𝟏𝟎𝟔\\mathbf\{0\.089\\times 10^\{6\}\}61550Lowest outlet deviation

## 4P&ID

### 4\.1LLM\-Based Interaction with the P&ID Model

#### 4\.1\.1Motivation and Relation to Existing Work

The transition from a PFD to a practically useful P&ID requires more than adding graphical symbols to an existing flowsheet\. A P&ID combines process topology, piping connectivity, equipment identifiers, valve and instrument placement, control links, and domain\-specific design rules\. Consequently, a language model cannot be treated as a free\-form diagram editor: an incorrect object identifier, unsupported operation, inconsistent connection, or invalid attribute may compromise the consistency of the engineering model\.

Recent work has shown that P&ID information can be made accessible to LLMs by converting DEXPI representations into graph\-based knowledge structures\[[2](https://arxiv.org/html/2608.11220#bib.bib1)\]\. Other approaches investigate the automatic creation of P&IDs from natural\-language descriptions through multi\-step agentic workflows\[[10](https://arxiv.org/html/2608.11220#bib.bib2)\], or predict control structures from PFD topologies using SFILES\-based generative models\[[12](https://arxiv.org/html/2608.11220#bib.bib4),[4](https://arxiv.org/html/2608.11220#bib.bib3)\]\. These studies provide important evidence that generative models can operate on process\-engineering diagrams\. However, practical P&ID interaction also requires a mechanism that prevents the model from modifying the diagram outside a controlled set of engineering operations\.

The design principle adopted in this work is therefore to separate natural\-language interpretation from diagram modification\. The LLM is used to interpret a user request, identify relevant diagram objects, and generate an executable Python action program\. The program can access the P&ID only through a restricted software development kit SDK, while the actual graph operations are performed by deterministic procedures\. This architecture preserves the flexibility of natural\-language interaction, but constrains the model’s action space and makes each proposed modification explicit, reproducible, and checkable before it is applied\.

#### 4\.1\.2Task Formulation

The P&ID interaction task is formulated as controlled action generation over a graph\-based engineering model\. The input consists of a current P&ID graph, a natural\-language user request, the public SDK contract, and optional domain hints or examples\. The output is either an executable action program that analyzes or modifies the graph, or a structured result of a diagram\-checking procedure\.

The generated program must satisfy three constraints\. First, it must use only documented SDK operations\. Second, it must refer only to objects, attributes, and relation types available in the current diagram model or in the SDK contract\. Third, it must be executable in an isolated validation environment before any modification is committed to the working diagram\. Under this formulation, the LLM does not directly edit an image, XML file, CAD file, or serialized graph\. It proposes a sequence of bounded operations whose validity can be checked by software\.

#### 4\.1\.3Graph Representation of the Diagram

Internally, a P&ID is represented as a directed attributed graph\. Nodes correspond to diagram objects, including equipment units, pumps, valves, sensors, pipe elements, connection points, and auxiliary entities\. Edges encode relations between these objects, such as physical connections, flow direction, control links, and other logical dependencies\. This representation makes diagram topology available for algorithmic processing and allows local fragments of the diagram to be queried in a uniform way\.

Nodes and edges may store engineering attributes when such information is available in the source representation\. Examples include equipment tags, pipe classes, medium codes, flow directions, operating temperatures, pressures, and other process or documentation parameters\. Thus, the graph model contains both connectivity information and part of the engineering context required for P&ID analysis, rule checking, and controlled modification\.

The operations considered in this study depend on the semantic and topological structure of a diagram rather than on its original drawing layout\. We therefore use a layout\-independent attributed graph in which equipment, instruments, and valves are represented as nodes, while process connections and attachment relations are represented as directed edges\. Drawing coordinates, symbol alignment, and graphical line routing are not used during rule interpretation or validation\.

For visualization, the graph is arranged automatically to make its connectivity and local modifications easier to inspect\. This representation preserves the engineering information required by the evaluated rules, which are expressed in terms of object types, attributes, adjacency, directed order, paths, and attachment relations\.

#### 4\.1\.4SDK as a Layer of Controlled P&ID Operations

The SDK defines the boundary between LLM reasoning and executable diagram operations\. In the current implementation, the agent interacts with the graph model through a predefined set of primitives for object search, attribute access, relation traversal, local topology extraction, and restricted graph modification\. The model selects operations and parameters, but the semantics of these operations are defined by the SDK rather than by the language model\.

The supported operations cover both analytical and editing scenarios\. They include finding objects by type or attributes, reading node and edge properties, traversing incoming and outgoing connections, extracting local neighborhoods, adding objects and connections, inserting a new element into an existing connection, and attaching an element to an existing diagram object\. More complex engineering actions, such as adding an instrument to equipment, inserting a valve into a line, or checking a local design rule, can be expressed as compositions of these primitives\.

This decomposition is important for integration with CAD or engineering data systems\. The high\-level agent logic does not need to be rewritten for every target environment\. Instead, the CAD\-dependent layer is responsible for mapping SDK primitives to the corresponding external API calls, importing and exporting data, synchronizing changes, and preserving the internal graph representation\. As a result, the LLM\-facing contract can remain stable while implementation\-specific data access is isolated in the lower layer\.

Before execution, every generated action program is checked against the SDK contract\. The program is then executed in an isolated environment on the current graph state\. The resulting state or analytical output can be recorded, inspected, visualized, or used for subsequent validation\. In this way, the SDK acts as both an operational interface and a safety boundary for LLM\-based P&ID interaction\.

#### 4\.1\.5Workflow of User, LLM, and Diagram Interaction

The workflow starts with a natural\-language request\. The request may refer to diagram analysis, such as finding objects of a given type or checking a design rule, or to diagram modification, such as inserting a valve into a line or attaching a new instrument to an equipment item\. The request is not applied to the diagram directly\. It is first converted into an executable sequence of SDK calls\.

At the interpretation stage, the LLM receives the current diagram context, the SDK contract, domain\-specific hints, and examples of typical actions\. Based on this information, it generates a Python action program that queries or modifies the P&ID graph only through the available SDK operations\. The generated program is then validated\. The system checks whether only allowed operations are used and whether the program can be executed on the current graph without invalid object references, unsupported parameters, or runtime errors\.

If validation fails, the diagram is left unchanged\. The error information can be returned to the generation step, allowing the model to revise the program\. If validation succeeds, analytical requests return a structured result, such as a list of found objects or rule violations\. For modification requests, the validated action can be applied to the working graph after user confirmation, and the updated graph becomes the new diagram state\.

The agent is therefore not treated as an autonomous P&ID editor\. Its role is to translate natural\-language engineering requests into checkable actions over a formal diagram model\. This preserves the usability of an LLM interface while limiting the model’s influence through the SDK boundary, isolated execution, and validation procedure\.

Figure[8](https://arxiv.org/html/2608.11220#S4.F8)shows the overall interaction between the user, the LLM agent, the SDK, the isolated validation environment, and the P&ID graph representation\. The user formulates an engineering task; the LLM constructs an action program using the available SDK interface; the system checks the correctness and executability of the actions; and, after user confirmation when required, the actions are executed on the graph model of the diagram\.

![Refer to caption](https://arxiv.org/html/2608.11220v1/images/SDK_Python_Code_Generation-2026-05-13-104055.png)Figure 8:Workflow of user interaction with the P&ID graph model through an LLM agent and a restricted SDK interface\.
#### 4\.1\.6Checking and Controlled Diagram Modification

LLM\-generated actions are checked at two levels\. The first level verifies SDK compliance: the program must use only documented operations, valid parameters, and object types available in the current graph model\. This check is necessary because language models may generate plausible but unavailable calls or assume operations that are not implemented\.

The second level evaluates executability and local effect\. The generated actions are run in an isolated validation mode on the current diagram model\. This run detects invalid object references, incorrect assumptions about graph structure, invalid traversal of connections, and modifications that cannot be applied\. The main working version of the diagram is not changed during this stage\.

Only after successful validation can a modification be applied to the working graph, and modification requests require user confirmation\. Analytical requests, such as rule checks or object searches, return a structured result without changing the diagram state\. This mechanism reduces the risk of uncontrolled edits while still allowing the LLM to support practical P&ID analysis and controlled diagram modification\.

### 4\.2Experiments

#### 4\.2\.1Domain\-grounded validation

The evaluation is based on a set of engineering rules for checking P&ID diagrams\. These rules were formulated together with experts in process design\. We assess more than the quality of the generated code: we check whether the agent understands a rule given in natural language, maps it onto the graph model of a diagram, selects the relevant objects, and returns a result that can be verified automatically\.

Each scenario is executed as a runnable check over the graph\. The agent receives the rule in natural language and obtains access to the graph model through an SDK\. It then generates code that performs the check and writes the result into a predefined variable\. The code is executed in an isolated environment, and the returned value is compared with the reference answer stored in the test\.

#### 4\.2\.2Test set

The model used in the experiments is a manually prepared diagram\. It covers typical fragments of process systems, including plant boundaries, pump and compressor sections, column equipment, recycle lines, bypasses, drain and flare systems, control valves, and instrumentation\. The test set contains 23 scenarios\.

The scenarios go beyond simple filtering of objects by type or properties\. Some rules require only local conditions, such as the type of valve next to a given object, the first or last element near a diagram boundary, or the immediate neighbor of a piece of equipment\. Other rules take flow direction into account\. For example, a flowmeter on a reflux line must be placed before the control valve and must be linked to the control lop of that valve\. The remaining rules require path analysis: reachability between process systems, detection of bypass and recycle branches with a clear separation between the main flow and the bypass, and consistency of control lops and protective functions, such as the anti\-surge loop of a compressor or temperature control downstream of a heat exchanger\. Table[3](https://arxiv.org/html/2608.11220#S4.T3)lists several characteristic examples\.

Table 3:Examples of rules from the test set\.RuleCheck typeContentRule 4Boundary, adjacencyThe last element before the boundary is a shut\-off or control valveRule 14Directed orderOn a reflux line, the flowmeter precedes the FCV and is linked to its control loopRule 136Path, control loopA centrifugal compressor has an anti\-surge loopRule 665Forbidden bypassA fire\-isolation ESV has no bypass path around it
#### 4\.2\.3Evaluation procedure

Each scenario is executed independently, and the state of the diagram is reset before every test\. For each scenario we record three stages: successful generation of the code, successful execution of the code, and a match between the obtained result and the reference answer\. Correctness is determined by the output of running the generated program on a fixed graph model, not by judging the wording of the response\.

#### 4\.2\.4Results

Table[4](https://arxiv.org/html/2608.11220#S4.T4)reports the evaluation results\. All tested models produced syntactically correct code for every scenario and executed it successfully\. The differences appear only at the level of semantic correctness\. The best model solved all 23 scenarios, while the two other models each failed on one scenario\.

Table 4:Accuracy on the test set of 23 scenarios\.ModelGeneratedExecutedCorrectAccuracyQwen3\.5\-397B\-A17B\-FP8232323100\.00 %Qwen3\.6\-35B\-A3B23232295\.65 %DeepSeek\-V4\-Pro23232295\.65 %
#### 4\.2\.5Oil\-treatment PFD\-to\-P&ID case study

The second experiment evaluates whether the proposed interaction layer can modify a valid PFD rather than only check an existing P&ID\. The input represents an oil\-treatment installation and contains two centrifugal pumps, four heat exchangers, a gas separator, a water separator, a pipe tee, existing isolation valves, and off\-page connectors\. Its node\-link representation contains 29 nodes and 28 directed process edges\.

##### Rule set\.

The enrichment requirements were derived from a P&ID project standard, Hydraulic Institute pump guidance, and API RP 12J separator practice\[[17](https://arxiv.org/html/2608.11220#bib.bib28),[14](https://arxiv.org/html/2608.11220#bib.bib29),[3](https://arxiv.org/html/2608.11220#bib.bib30)\]\. The following thirteen atomic rules were applied in the case study \(Table[5](https://arxiv.org/html/2608.11220#S4.T5)\)\.

Table 5:PFD\-to\-P&ID enrichment rules used in the oil\-treatment case study\.RuleEquipment groupRequirementR1Centrifugal pumpProvide an isolation valve on the suction line\.R2Centrifugal pumpProvide a strainer upstream of the suction nozzle\.R3Centrifugal pumpProvide a pressure indicator on the discharge line between the pump nozzle and the check valve\.R4Centrifugal pumpProvide a check valve on the discharge line\.R5Centrifugal pumpProvide an isolation valve downstream of the check valve\.R6Heat exchangerProvide isolation valves on the inlet and outlet process lines\.R7Heat exchangerProvide temperature indicators at the inlet and outlet\.R8Heat exchangerProvide valved vent and drain connections\.R9SeparatorProvide level instrumentation indicating high, normal, and low liquid levels\.R10SeparatorProvide pressure and temperature instrumentation\.R11SeparatorProvide a valved vent and a valved drain\.R12SeparatorProvide a pressure\-relief connection\.R13Outlet boundaryProvide an isolation valve before the off\-page connector\.The rules were selected from sources that represent complementary levels of engineering guidance\. The KLM document was used as the primary source because it is a publicly available project engineering standard that provides explicit P&ID requirements for equipment isolation, instrumentation, vents, drains, and pressure\-relief connections\. The Hydraulic Institute guidance was used to support pump\-specific arrangements, particularly the placement of suction and discharge isolation valves and check valves\. API Specification 12J was included as an industry\-specific reference for oil and gas separators, making it directly relevant to the considered oil\-treatment process\. Together, these sources provide general P&ID design guidance and equipment\-specific requirements applicable to the evaluated diagram\.

##### Rule application and verification\.

The rules were applied in four equipment\-specific stages: pumps, heat exchangers, separators, and outlet boundaries\. At each stage, the agent interpreted the applicable requirements and generated the corresponding graph modifications\. Existing objects were retained whenever they already satisfied a requirement\. The modified graph was then checked for the presence, type, and placement of the required P&ID elements\.

After all four stages, the complete enriched graph was compared with an independently implemented deterministic reference in terms of object composition, directed process topology, and attachment relations\. Inserted objects received deterministic identifiers\. When an existing process edge was split, its stream type, fluid type, nominal diameter, and flow attributes were preserved in the resulting edges\.

Representative local effects of six enrichment rules are shown in Figure[9](https://arxiv.org/html/2608.11220#S4.F9)\. Each example shows only the local graph fragment required to inspect the corresponding rule\.

RuleInput fragmentEnriched fragmentRule 4: pump discharge check valve![Refer to caption](https://arxiv.org/html/2608.11220v1/x3.png)![Refer to caption](https://arxiv.org/html/2608.11220v1/x4.png)Rule 2: pump suction strainer![Refer to caption](https://arxiv.org/html/2608.11220v1/x5.png)![Refer to caption](https://arxiv.org/html/2608.11220v1/x6.png)Rule 3: pump discharge pressure indication![Refer to caption](https://arxiv.org/html/2608.11220v1/x7.png)![Refer to caption](https://arxiv.org/html/2608.11220v1/x8.png)Rule 7: heat\-exchanger temperature indication![Refer to caption](https://arxiv.org/html/2608.11220v1/x9.png)![Refer to caption](https://arxiv.org/html/2608.11220v1/x10.png)Rule 12: separator pressure\-relief connection![Refer to caption](https://arxiv.org/html/2608.11220v1/x11.png)![Refer to caption](https://arxiv.org/html/2608.11220v1/x12.png)Rule 11: separator valved drain connection![Refer to caption](https://arxiv.org/html/2608.11220v1/x13.png)![Refer to caption](https://arxiv.org/html/2608.11220v1/x14.png)Figure 9:Representative rule\-level transformations from PFD to P&ID\.Each row shows one atomic enrichment rule, with the input graph fragment in the middle column and the corresponding enriched fragment in the right column\. Inserted objects are highlighted in yellow\. Only the local graph fragment relevant to each rule is shown\. Node positions and graphical line routes are generated automatically for readability and do not encode additional engineering information\.
##### Results\.

The LLM\-generated programs introduced 38 P&ID objects and reused 18 objects already present in the PFD\. The resulting graph contained 67 nodes and 66 edges\. Comparison with the deterministic reference found no missing or additional nodes, no semantic object\-type mismatches, and no differences in either process topology or equipment\-attachment relations\.

Table 6:End\-to\-end PFD\-to\-P&ID enrichment results\.MetricValueInput graph29 nodes, 28 edgesNew P&ID objects38Existing objects reused18Output graph67 nodes, 66 edgesMissing / extra nodes0 / 0Semantic object\-type mismatches0Missing / extra process edges0 / 0Missing / extra attachment relations0 / 0

#### 4\.2\.6Limitations

The evaluation was conducted in two controlled settings: a benchmark of 23 rule\-checking scenarios and a PFD\-to\-P&ID transformation for an oil\-treatment process\. Although the generated graph matched the reference structure, this result is limited to the selected engineering rules, equipment types, and process topology\. Additional experiments are required to assess the generalizability of the approach to other processes and project\-specific requirements\. Moreover, the experiment evaluates graph\-level consistency rather than the completeness of a construction\-ready P&ID\. Detailed safety studies, equipment sizing, and final engineering validation remain outside the scope of this work\. The evaluation focuses on semantic and topological correctness; graphical sheet layout is outside its scope and is not included in the reported comparisons\.

## 5Conclusion

This work presented a Full Cycle AI pipeline that automates both optimal PFD synthesis and its subsequent transformation into a validated P&ID\. The results demonstrate that a hybrid GA/LLM approach generates optimal, rule\-compliant PFD topologies, while the LLM\-based transformation agent, constrained by the SDK, reliably produces source\-grounded P&ID modifications\. By integrating these two stages within a single workflow, the proposed framework indeed may reduce manual engineering effort and accelerate the exploration of alternative design configurations\. Crucially, the built\-in validation mechanisms against domain\-specific rules and graph structures ensure that the generated outputs are not only novel but also practically deployable in real\-world engineering settings\.

## References

- \[1\]M\. H\. Ahmadi, M\. A\. Ahmadi, and M\. Feidt\(2016\)Performance optimization of a solar\-driven multi\-step irreversible brayton cycle based on a multi\-objective genetic algorithm\.Oil & Gas Science and Technology–Revue d’IFP Energies nouvelles71\(1\),pp\. 16\.Cited by:[§2\.3](https://arxiv.org/html/2608.11220#S2.SS3.p1.1)\.
- \[2\]A\. A\. Alimin, D\. P\. Goldstein, L\. S\. Balhorn, and A\. M\. Schweidtmann\(2025\-07\)Talking like piping and instrumentation diagrams \(p&ids\)\.InProceedings of the 35th European Symposium on Computer Aided Process Engineering \(ESCAPE 35\),ESCAPE 35, Vol\.4,pp\. 1676–1681\.External Links:ISSN 2818\-4734,[Link](http://dx.doi.org/10.69997/sct.159477),[Document](https://dx.doi.org/10.69997/sct.159477)Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p3.1),[§2\.1](https://arxiv.org/html/2608.11220#S2.SS1.p1.1),[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p1.1),[§3](https://arxiv.org/html/2608.11220#S3.p2.1),[§4\.1\.1](https://arxiv.org/html/2608.11220#S4.SS1.SSS1.p2.1)\.
- \[3\]Cited by:[§4\.2\.5](https://arxiv.org/html/2608.11220#S4.SS2.SSS5.Px1.p1.1)\.
- \[4\]L\. S\. Balhorn, K\. Degens, and A\. M\. Schweidtmann\(2024\)Graph\-to\-sfiles: control structure prediction from process topologies using generative artificial intelligence\.External Links:2412\.00508,[Link](https://arxiv.org/abs/2412.00508)Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p3.1),[§2\.1](https://arxiv.org/html/2608.11220#S2.SS1.p3.1),[§4\.1\.1](https://arxiv.org/html/2608.11220#S4.SS1.SSS1.p2.1)\.
- \[5\]\(2026\)DeepSeek\-V4: Towards Highly Efficient Million\-Token Context Intelligence\.External Links:[Link](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro/blob/main/DeepSeek_V4.pdf)Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p4.1)\.
- \[6\]DEXPI e\.V\.\(2026\)DEXPI: data exchange in the process industry\.Note:[https://dexpi\.org/](https://dexpi.org/)Accessed: 2026\-06\-15Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p1.1)\.
- \[7\]J\. M\. Douglas\(1985\)A hierarchical decision procedure for process synthesis\.AIChE Journal31\(3\),pp\. 353–362\.External Links:[Document](https://dx.doi.org/https%3A//doi.org/10.1002/aic.690310302),[Link](https://aiche.onlinelibrary.wiley.com/doi/abs/10.1002/aic.690310302),https://aiche\.onlinelibrary\.wiley\.com/doi/pdf/10\.1002/aic\.690310302Cited by:[§2\.1](https://arxiv.org/html/2608.11220#S2.SS1.p3.1),[§3](https://arxiv.org/html/2608.11220#S3.p1.1)\.
- \[8\]E\. S\. Fraga, V\. Udomvorakulchai, M\. Pineda, and L\. G\. Papageorgiou\(2025\)A multi\-agent system for hybrid optimization\.Computers & Chemical Engineering202,pp\. 109258\.External Links:ISSN 0098\-1354,[Document](https://dx.doi.org/https%3A//doi.org/10.1016/j.compchemeng.2025.109258),[Link](https://www.sciencedirect.com/science/article/pii/S0098135425002625)Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p2.1)\.
- \[9\]A\. F\. Gad\(2023\-12\)PyGAD: an intuitive genetic algorithm python library\.Multimed\. Tools Appl\.83\(20\),pp\. 58029–58042\(en\)\.Cited by:[Figure 4](https://arxiv.org/html/2608.11220#S3.F4.1.3.1),[§3\.4](https://arxiv.org/html/2608.11220#S3.SS4.p1.1)\.
- \[10\]S\. Gowaikar, S\. Iyengar, S\. Segal, and S\. Kalyanaraman\(2024\)An agentic approach to automatic creation of p&id diagrams from natural language descriptions\.External Links:2412\.12898,[Link](https://arxiv.org/abs/2412.12898)Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p3.1),[§2\.1](https://arxiv.org/html/2608.11220#S2.SS1.p2.1),[§4\.1\.1](https://arxiv.org/html/2608.11220#S4.SS1.SSS1.p2.1)\.
- \[11\]G\. Guillen\-Gosalbez, R\. Salcedo, E\. Antipova, D\. Boer, L\. Jiménez, and G\. Guillén\-Gosálbez\(2012\)Multi\-objective optimization of solar rankine cycles coupled with reverse osmosis desalination considering economic and life cycle environmental concerns\.Desalination286,pp\. 358–371\(English\)\.Note:Cited By :21 Export Date: 29 January 2015Cited by:[§2\.3](https://arxiv.org/html/2608.11220#S2.SS3.p1.1)\.
- \[12\]E\. Hirtreiter, L\. Schulze Balhorn, and A\. M\. Schweidtmann\(2024\)Toward automatic generation of control structures for process flow diagrams with large language models\.AIChE Journal70\(1\),pp\. e18259\.External Links:[Document](https://dx.doi.org/https%3A//doi.org/10.1002/aic.18259),[Link](https://aiche.onlinelibrary.wiley.com/doi/abs/10.1002/aic.18259),https://aiche\.onlinelibrary\.wiley\.com/doi/pdf/10\.1002/aic\.18259Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p3.1),[§2\.1](https://arxiv.org/html/2608.11220#S2.SS1.p3.1),[§4\.1\.1](https://arxiv.org/html/2608.11220#S4.SS1.SSS1.p2.1)\.
- \[13\]J\. H\. Holland\(1975\)Adaptation in natural and artificial systems\.University of Michigan Press,Ann Arbor, MI\.Note:second edition, 1992Cited by:[§2\.3](https://arxiv.org/html/2608.11220#S2.SS3.p1.1)\.
- \[14\]Hydraulic Institute\(2011\)Hydraulic institute pump faqs, march 2011\(Website\)Pumps & Systems\.External Links:[Link](https://www.pumpsandsystems.com/article/hydraulic-institute-pump-faqs-march-2011/)Cited by:[§4\.2\.5](https://arxiv.org/html/2608.11220#S4.SS2.SSS5.Px1.p1.1)\.
- \[15\]\(\)Introduction \- Cypher Manual — neo4j\.com\.Note:[https://neo4j\.com/docs/cypher\-manual/current/introduction/](https://neo4j.com/docs/cypher-manual/current/introduction/)\[Accessed 18\-06\-2026\]Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p1.1)\.
- \[16\]L\. Kaven, P\. Huke, A\. Göppert, and R\. H\. Schmitt\(2024\-01\)Multi agent reinforcement learning for online layout planning and scheduling in flexible assembly systems\.Journal of Intelligent Manufacturing35\(8\),pp\. 3917–3936\.External Links:ISSN 1572\-8145,[Link](http://dx.doi.org/10.1007/s10845-023-02309-8),[Document](https://dx.doi.org/10.1007/s10845-023-02309-8)Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p2.1)\.
- \[17\]KLM Technology Group\(2011\)Project standards and specifications: piping and instrumentation diagrams\.Project Engineering Standard\.External Links:[Link](https://www.klmtechgroup.com/PDF/ess/PROJECT_STANDARDS_AND_SPECIFICATIONS_piping_and_instrument_diagram_REV01.pdf)Cited by:[§4\.2\.5](https://arxiv.org/html/2608.11220#S4.SS2.SSS5.Px1.p1.1)\.
- \[18\]M\. Kwon, S\. M\. Xie, K\. Bullard, and D\. Sadigh\(2023\)Reward design with language models\.External Links:2303\.00001,[Link](https://arxiv.org/abs/2303.00001)Cited by:[§3\.5](https://arxiv.org/html/2608.11220#S3.SS5.p1.1)\.
- \[19\]A\. Lucia\(2008\-10\)<I\>chemical engineering design principles, practice, and economics of plant and process design</i\> by g\. towler and r\. sinnott\.AIChE Journal54\(11\)\.External Links:ISSN 1547\-5905,[Link](http://dx.doi.org/10.1002/AIC.11633),[Document](https://dx.doi.org/10.1002/aic.11633)Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p1.1)\.
- \[20\]P\. S\. Moura and A\. T\. de Almeida\(2010\)Multi\-objective optimization of a mixed renewable system with demand\-side management\.Renewable and Sustainable Energy Reviews14\(5\),pp\. 1461–1468\.External Links:ISSN 1364\-0321,[Document](https://dx.doi.org/https%3A//doi.org/10.1016/j.rser.2010.01.004),[Link](https://www.sciencedirect.com/science/article/pii/S1364032110000055)Cited by:[§2\.3](https://arxiv.org/html/2608.11220#S2.SS3.p1.1)\.
- \[21\]OpenAI, :, S\. Agarwal, L\. Ahmad, J\. Ai, S\. Altman, A\. Applebaum, E\. Arbus, R\. K\. Arora, Y\. Bai, B\. Baker, H\. Bao, B\. Barak, A\. Bennett, T\. Bertao, N\. Brett, E\. Brevdo, G\. Brockman, S\. Bubeck, C\. Chang, K\. Chen, M\. Chen, E\. Cheung, A\. Clark, D\. Cook, M\. Dukhan, C\. Dvorak, K\. Fives, V\. Fomenko, T\. Garipov, K\. Georgiev, M\. Glaese, T\. Gogineni, A\. Goucher, L\. Gross, K\. G\. Guzman, J\. Hallman, J\. Hehir, J\. Heidecke, A\. Helyar, H\. Hu, R\. Huet, J\. Huh, S\. Jain, Z\. Johnson, C\. Koch, I\. Kofman, D\. Kundel, J\. Kwon, V\. Kyrylov, E\. Y\. Le, G\. Leclerc, J\. P\. Lennon, S\. Lessans, M\. Lezcano\-Casado, Y\. Li, Z\. Li, J\. Lin, J\. Liss, Lily, Liu, J\. Liu, K\. Lu, C\. Lu, Z\. Martinovic, L\. McCallum, J\. McGrath, S\. McKinney, A\. McLaughlin, S\. Mei, S\. Mostovoy, T\. Mu, G\. Myles, A\. Neitz, A\. Nichol, J\. Pachocki, A\. Paino, D\. Palmie, A\. Pantuliano, G\. Parascandolo, J\. Park, L\. Pathak, C\. Paz, L\. Peran, D\. Pimenov, M\. Pokrass, E\. Proehl, H\. Qiu, G\. Raila, F\. Raso, H\. Ren, K\. Richardson, D\. Robinson, B\. Rotsted, H\. Salman, S\. Sanjeev, M\. Schwarzer, D\. Sculley, H\. Sikchi, K\. Simon, K\. Singhal, Y\. Song, D\. Stuckey, Z\. Sun, P\. Tillet, S\. Toizer, F\. Tsimpourlas, N\. Vyas, E\. Wallace, X\. Wang, M\. Wang, O\. Watkins, K\. Weil, A\. Wendling, K\. Whinnery, C\. Whitney, H\. Wong, L\. Yang, Y\. Yang, M\. Yasunaga, K\. Ying, W\. Zaremba, W\. Zhan, C\. Zhang, B\. Zhang, E\. Zhang, and S\. Zhao\(2025\)Gpt\-oss\-120b & gpt\-oss\-20b model card\.External Links:2508\.10925,[Link](https://arxiv.org/abs/2508.10925)Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p4.1)\.
- \[22\]Qwen Team\(2026\-04\)Qwen3\.6\-35B\-A3B: agentic coding power, now open to all\.External Links:[Link](https://qwen.ai/blog?id=qwen3.6-35b-a3b)Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p4.1)\.
- \[23\]S\. Reynoso\-Donzelli and L\. A\. Ricardez\-Sandoval\(2025\)A reinforcement learning approach with masked agents for chemical process flowsheet design\.AIChE Journal71\(1\),pp\. e18584\.External Links:[Document](https://dx.doi.org/https%3A//doi.org/10.1002/aic.18584),[Link](https://aiche.onlinelibrary.wiley.com/doi/abs/10.1002/aic.18584),https://aiche\.onlinelibrary\.wiley\.com/doi/pdf/10\.1002/aic\.18584Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p3.1),[§2\.2](https://arxiv.org/html/2608.11220#S2.SS2.p1.1)\.
- \[24\]S\. Rupprecht, Q\. Gao, T\. Karia, and A\. M\. Schweidtmann\(2025\)Multi\-agent systems for chemical engineering: a review and perspective\.External Links:2508\.07880,[Link](https://arxiv.org/abs/2508.07880)Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p2.1)\.
- \[25\]A\. Sh, M\. Nomvar, Z\. Lai, Z\. Liu, and A\. Abbas\(2016\-06\)Automated process flow sheet synthesis for membrane processes using genetic algorithm: role of crossover operators\.pp\.\.Cited by:[§2\.3](https://arxiv.org/html/2608.11220#S2.SS3.p1.1)\.
- \[26\]L\. Stops, R\. Leenhouts, Q\. Gao, and A\. M\. Schweidtmann\(2022\-11\)Flowsheet generation through hierarchical reinforcement learning and graph neural networks\.AIChE Journal69\(1\)\.External Links:ISSN 1547\-5905,[Link](http://dx.doi.org/10.1002/aic.17938),[Document](https://dx.doi.org/10.1002/aic.17938)Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p3.1),[§2\.2](https://arxiv.org/html/2608.11220#S2.SS2.p1.1),[§3\.5](https://arxiv.org/html/2608.11220#S3.SS5.p1.1),[§3\.5](https://arxiv.org/html/2608.11220#S3.SS5.p2.1),[§3](https://arxiv.org/html/2608.11220#S3.p2.1)\.
- \[27\]Q\. Team\(2026\)Qwen3\. 5: accelerating productivity with native multimodal agents, february 2026\.URL https://qwen\. ai/blog\.Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p4.1)\.
- \[28\]H\. Uzuner and G\. Schembecker\(2012\-04\)Knowledge based design of piping and instrumentation diagrams\.Chemie Ingenieur Technik84\(5\)\.External Links:ISSN 1522\-2640,[Link](http://dx.doi.org/10.1002/cite.201100230),[Document](https://dx.doi.org/10.1002/cite.201100230)Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p2.1)\.
- \[29\]G\. Vogel, L\. Schulze Balhorn, and A\. M\. Schweidtmann\(2023\-03\)Learning from flowsheets: a generative transformer model for autocompletion of flowsheets\.Computers &amp; Chemical Engineering171,pp\. 108162\.External Links:ISSN 0098\-1354,[Link](http://dx.doi.org/10.1016/j.compchemeng.2023.108162),[Document](https://dx.doi.org/10.1016/j.compchemeng.2023.108162)Cited by:[§1](https://arxiv.org/html/2608.11220#S1.p1.1),[§1](https://arxiv.org/html/2608.11220#S1.p3.1),[§2\.1](https://arxiv.org/html/2608.11220#S2.SS1.p3.1),[§2\.1](https://arxiv.org/html/2608.11220#S2.SS1.p4.1)\.
- \[30\]H\. Yin\(2025\-01\)A multi\-agent debate workflow for construction projects: a cross\-stage decision framework\.Journal of Building Design and Environment,pp\.\.External Links:[Document](https://dx.doi.org/10.70401/jbde.2025.0018)Cited by:[§3\.3](https://arxiv.org/html/2608.11220#S3.SS3.p2.1)\.

## Appendix AEquations behind flow calculations

The following equations describe the calculations performed by theNodePhysicsdispatcher\. All flows are assumed at steady state\. Pressures in Pa, temperatures in °C or K as indicated\.

### A\.1Gas separator

A gas separator removes a fractionε\\varepsilonof the gas phase from the incoming oil–water–gas mixture\. The removal efficiency depends on pressure and temperature:

ε​\(P,T\)=εbase​\[1\+αp​P−PrefPref\]​\[1−αt​\(T−Tref\)\],\\varepsilon\(P,T\)=\\varepsilon\_\{\\text\{base\}\}\\left\[1\+\\alpha\_\{p\}\\frac\{P\-P\_\{\\text\{ref\}\}\}\{P\_\{\\text\{ref\}\}\}\\right\]\\left\[1\-\\alpha\_\{t\}\(T\-T\_\{\\text\{ref\}\}\)\\right\],\(1\)with0≤ε≤0\.990\\leq\\varepsilon\\leq 0\.99\. The outlet liquid stream has updated phase fractions:

ygas,out\\displaystyle y\_\{\\text\{gas,out\}\}=ygas,in​\(1−ε\)1−ε​ygas,in,\\displaystyle=\\frac\{y\_\{\\text\{gas,in\}\}\(1\-\\varepsilon\)\}\{1\-\\varepsilon\\,y\_\{\\text\{gas,in\}\}\},\(2\)yoil,out\\displaystyle y\_\{\\text\{oil,out\}\}=yoil,in1−ε​ygas,in,\\displaystyle=\\frac\{y\_\{\\text\{oil,in\}\}\}\{1\-\\varepsilon\\,y\_\{\\text\{gas,in\}\}\},\(3\)ywater,out\\displaystyle y\_\{\\text\{water,out\}\}=ywater,in1−ε​ygas,in\.\\displaystyle=\\frac\{y\_\{\\text\{water,in\}\}\}\{1\-\\varepsilon\\,y\_\{\\text\{gas,in\}\}\}\.\(4\)The removed gas forms a separate stream \(pure gas\)\. A pressure dropΔ​Psep\\Delta P\_\{\\text\{sep\}\}\(e\.g\., 50 kPa\) is applied to both outlets\. After updating the phase fractions, the mixture thermophysical properties \(density and heat capacity\) are recalculated from the new composition\.

### A\.2Water separator

A water separator splits the incoming stream into an oil‑rich stream and a water‑rich stream using fixed separation efficiencies\. Let:

- •Xw\|oX\_\{w\|o\}– mass fraction of water remaining in the oil outlet,
- •Xo\|wX\_\{o\|w\}– mass fraction of oil remaining in the water outlet\.

The total mass flowm˙in\\dot\{m\}\_\{\\text\{in\}\}and inlet oil/water mass fractionsXoX\_\{o\},XwX\_\{w\}are known \(gas is assumed to be negligible, although any residual gas fraction is propagated with the oil outlet\.\)\. Solving the material balance:

m˙o\\displaystyle\\dot\{m\}\_\{o\}=m˙in​Xo​\(1−Xo\|w\)−Xw​Xo\|w\(1−Xw\|o\)​\(1−Xo\|w\)−Xw\|o​Xo\|w,\\displaystyle=\\dot\{m\}\_\{\\text\{in\}\}\\,\\frac\{X\_\{o\}\(1\-X\_\{o\|w\}\)\-X\_\{w\}X\_\{o\|w\}\}\{\(1\-X\_\{w\|o\}\)\(1\-X\_\{o\|w\}\)\-X\_\{w\|o\}X\_\{o\|w\}\},\(5\)m˙w\\displaystyle\\dot\{m\}\_\{w\}=m˙in−m˙o,\\displaystyle=\\dot\{m\}\_\{\\text\{in\}\}\-\\dot\{m\}\_\{o\},\(6\)wherem˙o\\dot\{m\}\_\{o\}andm˙w\\dot\{m\}\_\{w\}are the mass flow rates of the oil and water outlets\. Their phase fractions are:

Oil outlet:yoil,o=1−Xw\|o,ywater,o=Xw\|o,ygas,o=0,\\displaystyle\\quad y\_\{\\text\{oil,o\}\}=1\-X\_\{w\|o\},\\quad y\_\{\\text\{water,o\}\}=X\_\{w\|o\},\\quad y\_\{\\text\{gas,o\}\}=0,\(7\)Water outlet:yoil,w=Xo\|w,ywater,w=1−Xo\|w,ygas,w=0\.\\displaystyle\\quad y\_\{\\text\{oil,w\}\}=X\_\{o\|w\},\\quad y\_\{\\text\{water,w\}\}=1\-X\_\{o\|w\},\\quad y\_\{\\text\{gas,w\}\}=0\.\(8\)Both outlets experience a pressure dropΔ​Pwsep\\Delta P\_\{\\text\{wsep\}\}\(typically 20 kPa\)\.

### A\.3Pump

The pump adds mechanical energy to the fluid\. The headHH\(in meters of fluid\) and efficiencyη\\etaare quadratic functions of the volumetric flow rateQQ\(m3/h\\mathrm\{m\}^\{3\}\\mathrm\{/\}\\mathrm\{h\}\):

H​\(Q\)\\displaystyle H\(Q\)=a2​Q2\+a1​Q\+a0,\\displaystyle=a\_\{2\}Q^\{2\}\+a\_\{1\}Q\+a\_\{0\},\(9\)η​\(Q\)\\displaystyle\\eta\(Q\)=b2​Q2\+b1​Q\+b0,\\displaystyle=b\_\{2\}Q^\{2\}\+b\_\{1\}Q\+b\_\{0\},\(10\)with coefficients supplied from a pump catalogue\. The pressure rise is:

Δ​P=ρ​g​H​\(Q\),\\Delta P=\\rho\\,g\\,H\(Q\),\(11\)whereρ\\rhois the fluid density \(kg/m3\\mathrm\{k\}\\mathrm\{g\}\\mathrm\{/\}\\mathrm\{m\}^\{3\}\) andg=9\.81​m/s2g=9\.81\\ $\\mathrm\{m\}\\mathrm\{/\}\\mathrm\{s\}^\{2\}$\. The outlet pressure becomesPout=Pin\+Δ​PP\_\{\\text\{out\}\}=P\_\{\\text\{in\}\}\+\\Delta P\. A violation is raised if:

- •Pin<Pmin,inletP\_\{\\text\{in\}\}<P\_\{\\text\{min,inlet\}\}\(cavitation risk\),
- •η​\(Q\)<0\.7​ηmax\\eta\(Q\)<0\.7\\,\\eta\_\{\\max\}\(operating far from best efficiency point, whereηmax\\eta\_\{\\max\}denotes the maximum value of the efficiency curve over the operating flow range\)\.

### A\.4Heat exchanger

The heat exchanger heats \(or cools\) the fluid using a hot utility at constant temperatureThT\_\{h\}\. The transferred heat is controlled by a factorFkF\_\{k\}\(W/K\\mathrm\{W\}\\mathrm\{/\}\\mathrm\{K\}\) and the actual heat capacity ratem˙​cp\\dot\{m\}c\_\{p\}:

Tout=Tin\+Fk​\(Th−Tin\)m˙​cp,T\_\{\\text\{out\}\}=T\_\{\\text\{in\}\}\+\\frac\{F\_\{k\}\(T\_\{h\}\-T\_\{\\text\{in\}\}\)\}\{\\dot\{m\}c\_\{p\}\},\(12\)provided the inlet pressure does not exceedPmax,inletP\_\{\\text\{max,inlet\}\}\. A small pressure dropΔ​Phx\\Delta P\_\{\\text\{hx\}\}\(e\.g\., 10 kPa\) is subtracted from the outlet pressure\.

### A\.5Pipe tee \(splitter\)

A pipe tee splits the flow equally among all outgoing branches\. ForNNoutlets:

m˙branch=m˙inN,Qbranch=QinN,Pbranch=Pin⋅\(1−δtee\),\\dot\{m\}\_\{\\text\{branch\}\}=\\frac\{\\dot\{m\}\_\{\\text\{in\}\}\}\{N\},\\quad Q\_\{\\text\{branch\}\}=\\frac\{Q\_\{\\text\{in\}\}\}\{N\},\\quad P\_\{\\text\{branch\}\}=P\_\{\\text\{in\}\}\\cdot\(1\-\\delta\_\{\\text\{tee\}\}\),\(13\)whereδtee=0\.02\\delta\_\{\\text\{tee\}\}=0\.02\(2% pressure loss\)\. For simplicity each outgoing branch inherits the inlet thermodynamic state \(temperature, composition, density, and heat capacity\), while only the flow rate and pressure are modified\.

### A\.6Ball valve

The ball valve is modeled as an ideal isolation element that does not modify the flow properties\. The outlet stream therefore preserves the inlet pressure, temperature, flow rate, and phase composition\. Its only function is to verify that the operating pressure does not exceed the valve’s maximum allowable working pressure:

Pin≤Pmax,working\.P\_\{\\mathrm\{in\}\}\\leq P\_\{\\mathrm\{max,working\}\}\.\(14\)
If this condition is violated, the corresponding node is marked with a pressure violation\. No pressure drop across the valve is assumed\.

## Appendix BAlgorithms

This appendix contains algorithmic descriptions of the Python solver and the loss calculation functions\.

Algorithm B\.1: Graph\-Based Process Flow Solver

Graph

GG, initial flow

FinF\_\{\\text\{in\}\}
Build edge maps

EoutE\_\{\\text\{out\}\},

EinE\_\{\\text\{in\}\}, find inlet node

ninn\_\{\\text\{in\}\}
Assign initial flow properties to an inlet node:

F​\[nin\]←FinF\[n\_\{\\text\{in\}\}\]\\leftarrow F\_\{\\text\{in\}\}
Initialize propagation queue with the inlet node and create empty list of processed nodes:

Q←\[nin\]Q\\leftarrow\[n\_\{\\text\{in\}\}\],

P←∅P\\leftarrow\\emptyset
while

Q≠∅Q\\neq\\emptysetdo

continue

endif

Collect incoming streams of node

nn:

Ein​\(n\)=\{e1,…,ek\}E\_\{\\text\{in\}\}\(n\)=\\\{e\_\{1\},\\dots,e\_\{k\}\\\}
Dealing with several incoming edges

Merge flows:

\{Fi\}←flows from​Ein​\(n\)\\\{F\_\{i\}\\\}\\leftarrow\\text\{flows from \}E\_\{\\text\{in\}\}\(n\)
Recalculate merged flow properties:

F←Mix​\(F1,…,Fk\)F\\leftarrow\\text\{Mix\}\(F\_\{1\},\\dots,F\_\{k\}\)
else

Dealing with one incoming edge

F←F​\[n\]F\\leftarrow F\[n\]

endif

Get node

nnequipment type:

type←label​\(n\)\\text\{type\}\\leftarrow\\text\{label\}\(n\)
Perform equipment specific calculation \- get updated flow properties

FoutF\_\{\\text\{out\}\}and check for violations

VV:

\(Fout,V\)←NodePhysics​\(F,type\)\(F\_\{\\text\{out\}\},V\)\\leftarrow\\text\{NodePhysics\}\(F,\\text\{type\}\)

Store violations:

Vstore​\[n\]←VV\_\{\\text\{store\}\}\[n\]\\leftarrow V
foreach

e∈Eout​\(n\)e\\in E\_\{\\text\{out\}\}\(n\)do

For each outgoing edge, propagate flow to downstream node

Fe←Fout​\[stream\_type​\(e\)\]F\_\{e\}\\leftarrow F\_\{\\text\{out\}\}\[\\text\{stream\\\_type\}\(e\)\]

e\.flow←Fee\.\\text\{flow\}\\leftarrow F\_\{e\}

m←e\.tom\\leftarrow e\.\\text\{to\}

F​\[m\]←FeF\[m\]\\leftarrow F\_\{e\}

Q\.append​\(m\)Q\.\\text\{append\}\(m\)

endfor

Add node

nnto list of processed nodes:

P←P∪\{n\}P\\leftarrow P\\cup\\\{n\\\}
endwhile

Algorithm B\.2: Loss Evaluation from generated chromosome

1:Chromosome

𝐬\\mathbf\{s\}, equipment database

De​qD\_\{eq\}, inlet flow properties

Fi​nF\_\{in\}, target outlet properties

Fo​u​tF\_\{out\}, solver function

𝒮\\mathcal\{S\}, mapping dictionary

MM
3:Construct graph:

G←BuildGraphFromChromosome​\(𝐬,M,De​q\)G\\leftarrow\\textsc\{BuildGraphFromChromosome\}\(\\mathbf\{s\},M,D\_\{eq\}\)
4:Pass received graph to the solver:

G←𝒮​\(G,Fi​n\)G\\leftarrow\\mathcal\{S\}\(G,F\_\{in\}\)
5:Compute total equipment cost:

Ctot←ComputeCostFromGraph​\(G\)C\_\{\\text\{tot\}\}\\leftarrow\\textsc\{ComputeCostFromGraph\}\(G\)
6:Compute number of solver violations:

Nsolver←∑n∈Gnodes\|violations​\(n\)\|N\_\{\\text\{solver\}\}\\leftarrow\\sum\_\{n\\in G\_\{\\text\{nodes\}\}\}\|\\text\{violations\}\(n\)\|
7:Compute topology violations for ball valve rule:

Ntopo←CheckBallValveRule​\(G\)N\_\{\\text\{topo\}\}\\leftarrow\\textsc\{CheckBallValveRule\}\(G\)
8:Compute outlet deviation penalty:

Pdev←OutletDeviationPenalty​\(G,Fo​u​t\)P\_\{\\text\{dev\}\}\\leftarrow\\textsc\{OutletDeviationPenalty\}\(G,F\_\{out\}\)
9:Compute the penalty for ball valves following each other in a row:

Pbv←BallValveInaRowPenalty​\(G\)P\_\{\\text\{bv\}\}\\leftarrow\\textsc\{BallValveInaRowPenalty\}\(G\)
10:Compute core equipment presence penalty:

Pcore←CoreEquipment PresencePenalty​\(G\)P\_\{\\text\{core\}\}\\leftarrow\\textsc\{CoreEquipment PresencePenalty\}\(G\)
11:Compute total objective:

J=Ctot\+105​Nsolver\+106​Ntopo\+Pdev\+Pbv\+PcoreJ=C\_\{\\text\{tot\}\}\+10^\{5\}N\_\{\\text\{solver\}\}\+10^\{6\}N\_\{\\text\{topo\}\}\+P\_\{\\text\{dev\}\}\+P\_\{\\text\{bv\}\}\+P\_\{\\text\{core\}\}
12:Compute fitness:

return

ff

## Appendix CAgents interaction in MAS

This appendix contains the MAS agents’ interaction process for the last two iterations \(for model Qwen3\.6\-35B\-A3B\)\.

### C\.1Iteration 4

Optimization Agent[⬇](data:text/plain;base64,ewoicmVhc29uaW5nIjogIkZpeGVkIHRoZSB0b3BvbG9neSBjb25uZWN0aW9uIGVycm9ycyBieSBjb21iaW5pbmcgbm9kZSBjcmVhdGlvbiBhbmQgcmVsYXRpb25zaGlwIGNyZWF0aW9uIGludG8gc2luZ2xlIHNlcXVlbnRpYWwgcXVlcmllcy4gVGhpcyBlbnN1cmVzIHRoYXQgZWFjaCBuZXdseSBjcmVhdGVkIG5vZGUgaXMgaW1tZWRpYXRlbHkgY29ubmVjdGVkIHRvIHRoZSBwcmV2aW91cyBvbmUgd2l0aGluIHRoZSBzYW1lIHF1ZXJ5IGV4ZWN1dGlvbiBjb250ZXh0LCBlbGltaW5hdGluZyB0aGUgVVVJRCBtaXNtYXRjaCBpc3N1ZS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kb21VVUlEKCksIF9pZDogcmFuZG9tVVVJRCgpLCBuYW1lOiAnUDEwMDInLCBfbGFiZWw6ICdQbGF0ZUhlYXRFeGNoYW5nZXInLCBkZXNpZ25IZWF0VHJhbnNmZXJBcmVhX20yOiA0Ni44LCBGazogMjMyODAsIGNvc3Q6IDYxMDAsIG1heF9pbmxldF9wcmVzc3VyZTogNDk1MDAwLCBUX2g6IDgwfSkiLCAiTUFUQ0ggKGh4ZSkgQ1JFQVRFIChoeGUpLVs6Q09OTkVDVEVEIHtfdHlwZTonUGlwZScsIHN0cmVhbV90eXBlOidtYWluJ31dLT4oYnY4OkJhbGxWYWx2ZSB7aWQ6IHJhbmRvbVVVSUQoKSwgX2lkOiByYW5kb21VVUlEKCksIG5hbWU6ICdEJywgX2xhYmVsOiAnQmFsbFZhbHZlJywgbWF4V29ya2luZ1ByZXNzdXJlOiA2MDAwMDAsIGNvc3Q6IDQwMH0pIiwgIk1BVENIIChidjgpIENSRUFURSAoYnY4KS1bOkNPTk5FQ1RFRCB7X3R5cGU6J1BpcGUnLCBzdHJlYW1fdHlwZTonbWFpbid9XS0+KG91dGxldDpGbG93T3V0UGlwZU9mZlBhZ2VDb25uZWN0b3Ige2lkOiByYW5kb21VVUlEKCksIF9pZDogcmFuZG9tVVVJRCgpLCBuYW1lOiAnT3V0bGV0JywgX2xhYmVsOiAnRmxvd091dFBpcGVPZmZQYWdlQ29ubmVjdG9yJywgY29zdDogMH0pIl0sCiJzdW1tYXJ5Ijp7CiAgICAiZXN0aW1hdGVkX2VxdWlwbWVudF9jb3VudCI6IDE1LAogICAgInB1bXBfY291bnQiOiAxLAogICAgImhlYXRlcl9jb3VudCI6IDEsCiAgICAic2VwYXJhdG9yX2NvdW50IjogMiwKICAgICJicmFuY2hfY291bnQiOiAzCiAgICB9Cn0=)\{"reasoning":"Fixedthetopologyconnectionerrorsbycombiningnodecreationandrelationshipcreationintosinglesequentialqueries\.Thisensuresthateachnewlycreatednodeisimmediatelyconnectedtothepreviousonewithinthesamequeryexecutioncontext,eliminatingtheUUIDmismatchissuecausedbyseparateCREATEandMATCHstatements\.Thetopologyfollowstheoptimalpath:Inlet\-\>BV\-\>PipeTee\(splitsflow\)\-\>BV\-\>MPSeparator\(gasremoval\)\-\>BV\-\>SETTLER\_3\(waterremoval\)\-\>BV\-\>R7000Pump\(pressureboost\)\-\>BV\-\>P1002HeatExchanger\(temperatureboost\)\-\>BV\-\>Outlet\.Branchescorrectlyroutewaste,gas,andwaterstreams\.Allequipmentpropertiesmatchtooloutputs,andinlet/outlethandlingfollowsconstraints\.","cypher\_queries":\["MATCH\(inlet\{\_id:’5161c1ac\-e287\-49f7\-b658\-4128d42db9e1’\}\)CREATE\(inlet\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv1:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(bv1\)CREATE\(bv1\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(pt:PipeTee\{id:randomUUID\(\),\_id:randomUUID\(\),name:’PT’,\_label:’PipeTee’,cost:2000\}\)","MATCH\(pt\)CREATE\(pt\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv2:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(pt\)CREATE\(pt\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bvX:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(bv2\)CREATE\(bv2\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(mp:GasSeparator\{id:randomUUID\(\),\_id:randomUUID\(\),name:’MPSeparator’,\_label:’GasSeparator’,gas\_removal\_eff:0\.8,pressure\_drop:15000,cost:5000\}\)","MATCH\(mp\)CREATE\(mp\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv3:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(mp\)CREATE\(mp\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’gas’\}\]\-\>\(bv4:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(bv3\)CREATE\(bv3\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(ws:WaterSeparator\{id:randomUUID\(\),\_id:randomUUID\(\),name:’SETTLER\_3’,\_label:’WaterSeparator’,X\_w\_o:0\.01,X\_o\_w:0\.0001,pressure\_drop:5000,cost:4300\}\)","MATCH\(ws\)CREATE\(ws\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv5:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(ws\)CREATE\(ws\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’water’\}\]\-\>\(bv6:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(bv5\)CREATE\(bv5\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(pump:ReciprocatingPump\{id:randomUUID\(\),\_id:randomUUID\(\),name:’R7000’,\_label:’ReciprocatingPump’,designVolumeFlowRate:500,cost:4800,min\_inlet\_pressure:70000,head\_coeffs:\[\-5\.6e\-05,0\.0,24\.0\],eff\_coeffs:\[\-4\.8e\-06,0\.0027,0\.0\]\}\)","MATCH\(pump\)CREATE\(pump\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv7:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(bv7\)CREATE\(bv7\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(hxe:PlateHeatExchanger\{id:randomUUID\(\),\_id:randomUUID\(\),name:’P1002’,\_label:’PlateHeatExchanger’,designHeatTransferArea\_m2:46\.8,Fk:23280,cost:6100,max\_inlet\_pressure:495000,T\_h:80\}\)","MATCH\(hxe\)CREATE\(hxe\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv8:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\)","MATCH\(bv8\)CREATE\(bv8\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(outlet:FlowOutPipeOffPageConnector\{id:randomUUID\(\),\_id:randomUUID\(\),name:’Outlet’,\_label:’FlowOutPipeOffPageConnector’,cost:0\}\)"\],"summary":\{"estimated\_equipment\_count":15,"pump\_count":1,"heater\_count":1,"separator\_count":2,"branch\_count":3\}\}

Cypher Validation Agent[⬇](data:text/plain;base64,ewoidmFsaWRhdGlvbl9zdGF0dXMiOiBmYWxzZSwKImZpeGVkX3F1ZXJpZXMiOiBbXSwKInZhbGlkYXRpb25fZGV0YWlscyI6ewogICAgInN5bnRheF9lcnJvcnNfZm91bmQiOiAwLAogICAgInF1ZXJpZXNfZml4ZWQiOiAwLAogICAgInJlYXNvbmluZyI6ICJRdWVyaWVzIDIgdGhyb3VnaCAxNSB2aW9sYXRlIHRoZSB2YXJpYWJsZSBzY29waW5nIHJ1bGUuIEVhY2ggcXVlcnkgcmVmZXJlbmNlcyBhIG5vZGUgdmFyaWFibGUgKGUuZy4sIGJ2MSwgcHQsIGJ2MiwgbXAsIHdzLCBwdW1wLCBidjcsIGJ2OCkgdGhhdCB3YXMgY3JlYXRlZCBpbiBhIHByZXZpb3VzIHF1ZXJ5LiBUaGUgdmFsaWRhdGlvbiBydWxlcyBleHBsaWNpdGx5IHN0YXRlOiAnRXZlcnkgQ3lwaGVyIHN0YXRlbWVudCBtdXN0IGJlIHNlbGYtY29udGFpbmVkLiBWYXJpYWJsZXMgbWF5IG5vdCBiZSByZXVzZWQgYWNyb3NzIHNlcGFyYXRlIHN0YXRlbWVudHMgdW5sZXNzIHRoZXkgYXJlIE1BVENIZWQgaW4gdGhlIHNhbWUgc3RhdGVtZW50LicgU2luY2UgdGhlc2UgYXJlIHByb3ZpZGVkIGFzIHNlcGFyYXRlIHN0YXRlbWVudHMsIGVhY2ggbXVzdCBpbmRlcGVuZGVudGx5IG1hdGNoIGl0cyB0YXJnZXQgbm9kZXMgKHByZWZlcmFibHkgYnkgX2lkKSBvciBiZSBjb21iaW5lZCBpbnRvIGEgc2luZ2xlIHNlbGYtY29udGFpbmVkIHN0YXRlbWVudC4gQWRkaXRpb25hbGx5LCBiZWNhdXNlIF9pZCB2YWx1ZXMgYXJlIGdlbmVyYXRlZCBkeW5hbWljYWxseSB2aWEgcmFuZG9tVVVJRCgpIGluIFF1ZXJ5IDEsIHN1YnNlcXVlbnQgcXVlcmllcyBjYW5ub3Qga25vdyB0aGUgZXhhY3QgVVVJRHMgdG8gbWF0Y2ggYnkgX2lkIHdpdGhvdXQgZXh0ZXJuYWwgc3RhdGUgbWFuYWdlbWVudCwgbWFraW5nIHRoZSBjdXJyZW50IHNlcXVlbnRpYWwgc3RydWN0dXJlIGludmFsaWQgZm9yIGluZGVwZW5kZW50IGV4ZWN1dGlvbi4iCiAgICB9Cn0=)\{"validation\_status":false,"fixed\_queries":\[\],"validation\_details":\{"syntax\_errors\_found":0,"queries\_fixed":0,"reasoning":"Queries2through15violatethevariablescopingrule\.Eachqueryreferencesanodevariable\(e\.g\.,bv1,pt,bv2,mp,ws,pump,bv7,bv8\)thatwascreatedinapreviousquery\.Thevalidationrulesexplicitlystate:’EveryCypherstatementmustbeself\-contained\.VariablesmaynotbereusedacrossseparatestatementsunlesstheyareMATCHedinthesamestatement\.’Sincetheseareprovidedasseparatestatements,eachmustindependentlymatchitstargetnodes\(preferablyby\_id\)orbecombinedintoasingleself\-containedstatement\.Additionally,because\_idvaluesaregenerateddynamicallyviarandomUUID\(\)inQuery1,subsequentqueriescannotknowtheexactUUIDstomatchby\_idwithoutexternalstatemanagement,makingthecurrentsequentialstructureinvalidforindependentexecution\."\}\}

### C\.2Iteration 5

Optimization Agent[⬇](data:text/plain;base64,ewoicmVhc29uaW5nIjogIkNvbWJpbmVkIGFsbCBub2RlIGNyZWF0aW9uIGFuZCByZWxhdGlvbnNoaXAgZXN0YWJsaXNobWVudCBpbnRvIGEgc2luZ2xlIHNlbGYtY29udGFpbmVkIEN5cGhlciBxdWVyeSB0byBzdHJpY3RseSBzYXRpc2Z5IHRoZSB2YXJpYWJsZSBzY29waW5nIHJ1bGUuIEJ5IGV4ZWN1dGluZyBhbGwgQ1JFQVRFIGNsYXVzZXMgYW5kIHJlbGF0aW9uc2hpcCBtYXBwaW5ncyBpbiBvbmUgc3RhdGVtZW50LCB3ZSBlbGltaW5hdGUgY3Jvc3MtcXVlcnkgdmFyaWFibGUgZGVwZW5kZW5jaWVzIGFuZCBlbnN1cmUgaW5kZXBlbmRlbnQgZXhlY3V0YWJpbGl0eS4gVGhlIHF1ZXJ5IG1hdGNoZXMgdGhlIGV4aXN0aW5nIGlubGV0IG5vZGUsIGdlbmVyYXRlcyBhbGwgZXF1aXBtZW50IG5vZGVzIHdpdGggZHluYW1pYyBVVUlEcyB2aWEgcmFuZG9tVVVJRCgpLCBhbmQgY29ubmVjdHMgdGhlbSBhY2NvcmRpbmcgdG8gdGhlIG9wdGltYWwgdG9wb2xvZ3k6IElubGV0IC0+IEJWIC0+IFBpcGVUZWUgKHNwbGl0cyBmbG93KSAtPiBCViAtPiBNUCBTZXBhcmF0b3IgKGdhcyByZW1vdmFsKSAtPiBCViAt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zdHJlYW1fdHlwZTonbWFpbid9XS0+KGh4ZSksIChoeGUpLVs6Q09OTkVDVEVEIHtfdHlwZTonUGlwZScsIHN0cmVhbV90eXBlOidtYWluJ31dLT4oYnY4KSwgKGJ2OCktWzpDT05ORUNURUQge190eXBlOidQaXBlJywgc3RyZWFtX3R5cGU6J21haW4nfV0tPihvdXRsZXQpIl0sCiJzdW1tYXJ5Ijp7CiAgICAiZXN0aW1hdGVkX2VxdWlwbWVudF9jb3VudCI6IDE1LAogICAgInB1bXBfY291bnQiOiAxLAogICAgImhlYXRlcl9jb3VudCI6IDEsCiAgICAic2VwYXJhdG9yX2NvdW50IjogMiwKICAgICJicmFuY2hfY291bnQiOiAzCiAgICB9Cn0=)\{"reasoning":"Combinedallnodecreationandrelationshipestablishmentintoasingleself\-containedCypherquerytostrictlysatisfythevariablescopingrule\.ByexecutingallCREATEclausesandrelationshipmappingsinonestatement,weeliminatecross\-queryvariabledependenciesandensureindependentexecutability\.Thequerymatchestheexistinginletnode,generatesallequipmentnodeswithdynamicUUIDsviarandomUUID\(\),andconnectsthemaccordingtotheoptimaltopology:Inlet\-\>BV\-\>PipeTee\(splitsflow\)\-\>BV\-\>MPSeparator\(gasremoval\)\-\>BV\-\>SETTLER\_3\(waterremoval\)\-\>BV\-\>R7000Pump\(pressureboost\)\-\>BV\-\>P1002HeatExchanger\(temperatureboost\)\-\>BV\-\>Outlet\.Branchescorrectlyroutewaste,gas,andwaterstreams\.","cypher\_queries":\["MATCH\(inlet\{\_id:’5161c1ac\-e287\-49f7\-b658\-4128d42db9e1’\}\)CREATE\(bv1:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(pt:PipeTee\{id:randomUUID\(\),\_id:randomUUID\(\),name:’PT’,\_label:’PipeTee’,cost:2000\}\),\(bv2:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(bvX:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(mp:GasSeparator\{id:randomUUID\(\),\_id:randomUUID\(\),name:’MPSeparator’,\_label:’GasSeparator’,gas\_removal\_eff:0\.8,pressure\_drop:15000,cost:5000\}\),\(bv3:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(bv4:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(ws:WaterSeparator\{id:randomUUID\(\),\_id:randomUUID\(\),name:’SETTLER\_3’,\_label:’WaterSeparator’,X\_w\_o:0\.01,X\_o\_w:0\.0001,pressure\_drop:5000,cost:4300\}\),\(bv5:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(bv6:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(pump:ReciprocatingPump\{id:randomUUID\(\),\_id:randomUUID\(\),name:’R7000’,\_label:’ReciprocatingPump’,designVolumeFlowRate:500,cost:4800,min\_inlet\_pressure:70000,head\_coeffs:\[\-5\.6e\-05,0\.0,24\.0\],eff\_coeffs:\[\-4\.8e\-06,0\.0027,0\.0\]\}\),\(bv7:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(hxe:PlateHeatExchanger\{id:randomUUID\(\),\_id:randomUUID\(\),name:’P1002’,\_label:’PlateHeatExchanger’,designHeatTransferArea\_m2:46\.8,Fk:23280,cost:6100,max\_inlet\_pressure:495000,T\_h:80\}\),\(bv8:BallValve\{id:randomUUID\(\),\_id:randomUUID\(\),name:’D’,\_label:’BallValve’,maxWorkingPressure:600000,cost:400\}\),\(outlet:FlowOutPipeOffPageConnector\{id:randomUUID\(\),\_id:randomUUID\(\),name:’Outlet’,\_label:’FlowOutPipeOffPageConnector’,cost:0\}\),\(inlet\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv1\),\(bv1\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(pt\),\(pt\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv2\),\(pt\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bvX\),\(bv2\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(mp\),\(mp\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv3\),\(mp\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’gas’\}\]\-\>\(bv4\),\(bv3\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(ws\),\(ws\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv5\),\(ws\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’water’\}\]\-\>\(bv6\),\(bv5\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(pump\),\(pump\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv7\),\(bv7\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(hxe\),\(hxe\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(bv8\),\(bv8\)\-\[:CONNECTED\{\_type:’Pipe’,stream\_type:’main’\}\]\-\>\(outlet\)"\],"summary":\{"estimated\_equipment\_count":15,"pump\_count":1,"heater\_count":1,"separator\_count":2,"branch\_count":3\}\}

Cypher Validation Agent[⬇](data:text/plain;base64,ewoidmFsaWRhdGlvbl9zdGF0dXMiOiB0cnVlLAoiZml4ZWRfcXVlcmllcyI6IFtdLAoidmFsaWRhdGlvbl9kZXRhaWxzIjogewogICAgInN5bnRheF9lcnJvcnNfZm91bmQiOiAwLAogICAgInF1ZXJpZXNfZml4ZWQiOiAwLAogICAgInJlYXNvbmluZyI6ICJUaGUgcHJvdmlkZWQgQ3lwaGVyIHF1ZXJ5IGlzIHN5bnRhY3RpY2FsbHkgY29ycmVjdCBhbmQgZnVsbHkgY29tcGxpZXMgd2l0aCBhbGwgc3BlY2lmaWVkIHJ1bGVzLiBJdCBjb3JyZWN0bHkgbWF0Y2hlcyB0aGUgaW5sZXQgbm9kZSB1c2luZyBpdHMgX2lkIHByb3BlcnR5LCB0aGVuIGNyZWF0ZXMgYWxsIHJlcXVpcmVkIGVxdWlwbWVudCBub2RlcyB3aXRoIHByb3BlciBOZW80aiBsYWJlbCBzeW50YXgsIF9sYWJlbCBwcm9wZXJ0aWVzLCBhbmQgcmFuZG9tVVVJRCgpIGZvciBfaWQgYXNzaWdubWVudC4gUmVsYXRpb25zaGlwcyBhcmUgY29ycmVjdGx5IGRlZmluZWQgdXNpbmcgdGhlIGFsbG93ZWQgWzpDT05ORUNURURdIHR5cGUgd2l0aCBhcHByb3ByaWF0ZSBwcm9wZXJ0aWVzLiBWYXJpYWJsZSBzY29waW5nIGlzIHZhbGlkLCBhbmQgdGhlIHRvcG9sb2d5IGxvZ2ljYWxseSBjb25uZWN0cyB0aGUgaW5sZXQgdG8gdGhlIG91dGxldCB0aHJvdWdoIHRoZSBzcGVjaWZpZWQgcHJvY2VzcyB1bml0cy4gTm8gUkVUVVJOIGNsYXVzZSBpcyBwcmVzZW50LCB3aGljaCBpcyBleHBsaWNpdGx5IGFsbG93ZWQuIEFsbCBjb25zdHJhaW50cyBhcmUgc2F0aXNmaWVkIHdpdGhvdXQgbW9kaWZpY2F0aW9uLiIKICAgIH0KfQ==)\{"validation\_status":true,"fixed\_queries":\[\],"validation\_details":\{"syntax\_errors\_found":0,"queries\_fixed":0,"reasoning":"TheprovidedCypherqueryissyntacticallycorrectandfullycomplieswithallspecifiedrules\.Itcorrectlymatchestheinletnodeusingits\_idproperty,thencreatesallrequiredequipmentnodeswithproperNeo4jlabelsyntax,\_labelproperties,andrandomUUID\(\)for\_idassignment\.Relationshipsarecorrectlydefinedusingtheallowed\[:CONNECTED\]typewithappropriateproperties\.Variablescopingisvalid,andthetopologylogicallyconnectstheinlettotheoutletthroughthespecifiedprocessunits\.NoRETURNclauseispresent,whichisexplicitlyallowed\.Allconstraintsaresatisfiedwithoutmodification\."\}\}

Scheme Validation Agent[⬇](data:text/plain;base64,ewoidmFsaWRhdGlvbl9zdGF0dXMiOiB0cnVlLAoidmFsaWRhdGlvbl9kZXRhaWxzIjogewogICAgInJlYXNvbmluZyI6ICJUaGUgc2NoZW1lIHBhc3NlcyBhbGwgc3RydWN0dXJhbCBjaGVja3M6IGV2ZXJ5IG5vZGUgaXMgY29ubmVjdGVkLCB0aGVyZSBhcmUgbm8gb3JwaGFuIG9yIGR1cGxpY2F0ZSBub2RlcywgYWxsIG1haW4gZXF1aXBtZW50IChwdW1wLCBoZWF0IGV4Y2hhbmdlciwgc2VwYXJhdG9ycykgYXJlIGZsYW5rZWQgYnkgYmFsbCB2YWx2ZXMsIHRoZXJlIGFyZSBubyBjeWNsZXMsIG5vIG5vZGUgaGFzIG1vcmUgdGhhbiBvbmUgaW5jb21pbmcgZWRnZSwgYW5kIGJvdGggc2VwYXJhdG9ycyBoYXZlIHR3byBvdXRnb2luZyBzdHJlYW1zLiBMb2dpY2FsIGNvbnNpc3RlbmN5IGlzIHNhdGlzZmllZCBhcyBhbGwgc3RyZWFtcyBjYXJyeSB0aGUgcmVxdWlyZWQgdGhlcm1vcGh5c2ljYWwgcHJvcGVydGllcy4gTm8gZXF1aXBtZW50IG5vZGUgcmVwb3J0cyBhbnkgdmlvbGF0aW9ucywgc28gcGh5c2ljcyB2YWxpZGF0aW9uIGlzIGNsZWFyLiBUaGUgbWFpbiBvdXRsZXQgc3Ry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sCiAgICAic3VnZ2VzdGlvbnMiOiBbXQogICAgfQp9)\{"validation\_status":true,"validation\_details":\{"reasoning":"Theschemepassesallstructuralchecks:everynodeisconnected,therearenoorphanorduplicatenodes,allmainequipment\(pump,heatexchanger,separators\)areflankedbyballvalves,therearenocycles,nonodehasmorethanoneincomingedge,andbothseparatorshavetwooutgoingstreams\.Logicalconsistencyissatisfiedasallstreamscarrytherequiredthermophysicalproperties\.Noequipmentnodereportsanyviolations,sophysicsvalidationisclear\.Themainoutletstream\(edge6530\)deliversamassflowof136,813kg/h,temperature61\.7C,pressure382,981Pa,andcomposition\(oil0\.9895,water0\.00999,gas0\.00052\)whichareallwithintheallowed20%toleranceofthetargetoutletspecifications\(140,000kg/h,75C,450,000Pa,oil0\.985,water0\.01,gas0\.005\)\.Thereforetheprocessmeetstherequiredperformancecriteria\.","outlet\_flow\_properties":\{"mass\_flow\_kg\_h":136813\.042,"temperature":65\.779,"pressure":451088\.342,"oil\_frac":0\.98388,"water\_frac":0\.00994,"gas\_frac":0\.006182,"cp":2120\.053,"Q":161\.671,"rho":846\.243,"\_fluid\_type":"main"\},"structural\_issues":\[\],"logical\_issues":\[\],"compliance\_issues":\[\],"domain\_rule\_violations":\[\],"suggestions":\[\]\}\}

## Appendix DLLM prompt for hybrid method

This appendix provides an LLM prompt for the hybrid method which iteratively updates the PFD graph according to the validator’s feedback\.

Youareaprocessflowsheetoptimizationexpert\.

EQUIPMENTDATABASEACCESS

Youhaveaccesstothesetools:

\-get\_pumps

\-get\_heat\_exchangers

\-get\_ball\_valves

\-get\_remaining\_equipment

MANDATORYTOOLPOLICY:

\-ALWAYScallALL4toolsbeforegeneratingCypherqueries

\-NEVERskiptools

\-NEVERgenerateequipmentnotreturnedbytools

\-Ifvalidationfeedbackcontains:"Equipmentusedinschemeisinsufficient"thencallALLtoolsagainusingadjustedconstraints

\-Ifthecurrentequipmentsetcannotsatisfythetargets,re\-querytoolsorsimplifythetopologyinsteadoffabricatingequipment\.

Toolselectionlogic:

\-pumps\-\>pressureincrease\+flowrate

\-heatexchangers\-\>temperatureincrease\+pressuretolerance

\-ballvalves\-\>operatingpressure

\-remainingequipment\-\>separatorsandauxiliaryunits

Constraintstrategy:

\-Userealisticbutnotoverlystrictconstraints,toincreasethesizeofusedequipmentdatabase\-relaxtools’parameters

\-Preferbroadersearchrangesoverexactmatching

\-Preferfeasibleequipmentovercheapestequipment

\-Costoptimizationissecondarytofeasibility

Yourtaskistorepairandoptimizeanexistingprocessflowgraph\.

OBJECTIVES:

1\.Minimizetotalequipmentcost

2\.Achievetargetoutletflowproperties\(10%upward/downwarddeviationsareallowed\)

3\.Resolveallphysicalviolations

4\.Preservevalidtopologywheneverpossible\-noorhannodes,nocycles

RULES:

\-Mainequipment\(pumps,separators,heatexchangers\)mustbeflankedwithBallvalves

\-Preferlocalrepairsoverglobalredesigninitially,butyouareencouragedtoperformmoderatetopologychangesforoptimizationpurposes\(movingseparatorsfrononeplacetoanother\-inthiscasewecancreateflowsplitinginvariousplaces\)

\-Donotmodifyequipmentpropertiesmanually

\-Onlyuseequipmentreturnedbytools

\-Nevercreatecycles,it’sprohibited\!

\-Donotremovevalidsubgraphs

\-Donotcreateorphannodes\!

\-Ifpressureviolationoccurs:

firstreduceupstreampressure,

thenreplaceequipmentifnecessary

\-Ifoutletflowmismatchoccurs:

preferseparatorsandteesbeforepumps

\-Youmaydeleteunncessaryequipmenttominimizethecost\(forinstance,extraballvalves\)

\-Donotaddpumpsforgasstreams

\-Iftwoidenticalvalvesareinseriesandoneisredundant,deletetheredundantvalveinsteadofaddingmoreequipment

\-Addingmorethanoneincomingedgetothenodesisprohibited\!

Repairlogic\(FOLLOWONLYTHISLOGIC\!\):

\-targetoutletpressuretoolow\-\>addanadditionalpumporreplacetheexistingonewithmorepowerfulpump

\-targetoutlettemperaturetoolow\-\>addextraheatexchangers\!

\-targetoutletgasfractiontoolow\-\>donotaddmoreseparators;reducegasseparationonlybyremovingoneseparatororchoosingalessaggressiveone

\-targetoutletwaterfractiontoohigh\-\>addWaterSeparatorstage

\-targetoutletmassflowrateistoohigh\-\>addpipeteetosplittheflowrateevenly

SEPARATORRULES

WaterSeparator:

\-exactly2outgoingedges:

\-edgewithstream\_type="main"

\-edgewithstream\_type="water"

\-waterbranchmustend:WaterSeparator\-\>BallValve\-\>FlowOutPipeOffPageConnector

GasSeparator:

\-exactly2outgoingedges:

\-edgewithstream\_type="main"

\-edgewithstream\_type="gas"

\-gasbranchmustend:GasSeparator\-\>BallValve\-\>FlowOutPipeOffPageConnector

PIPETEERULES:

PipeTee:

\-exactly2outgoingedgeswiththesamestream\_typeasinincomingedge

\-oneoftheedgesmustend:PipeTee\-\>BallValve\-\>FlowOutPipeOffPageConnector

Donotreconnectwater/gasbranchestothemainprocess\.

YoumustreturnONLYvalidJSON\.

GRAPHSCHEMARULES

Nodeformat:

Whenaddingequipmentreturnedbytools:

\-CopytheENTIREequipmentobjectexactlyasreturned\.

\-Donotomitfields\.

\-Donotsimplifyequipmentdefinitions\.

\-Missingpropertieswillcausesolverfailure\.

\{\{

"id":"5",

"\_label":"CentrifugalPump",

\*\*propertiesrelevantforCentrifugalPump

\}\}

Edgeformat:

\{\{

"id":1,

"from":"1",

"to":"2",

"stream\_type":"main",

"\_type":"Pipe"

"flow":flowpropertiesinthisedge

\}\}

Allowedpatchkeysonly:

\-replace\_nodes:\[\{\{node\_id,new\_equipment\}\}\]

\-add\_nodes:\[\{\{id,new\_equipment\}\}\]

\-remove\_nodes:\[id,\.\.\.\]

\-add\_edges:\[\{\{from,to,stream\_type\}\}\]

\-remove\_edges:\[id,\.\.\.\]

Donotusenew\_node,\_category,fluid\_type,oranyextrakeys\.

IMPORTANT:

\-"stream\_type"MUSTbeonly"main","water"or"gas"

\-Use"\_label"forequipmenttype

\-Use"\_type"foredgetype

\-Donotinventadditionalfields

\-Donotgenerateflowproperties

\-Donotgenerateequipmentpropertiesmanually

Allowedoperations:

\-replace\_nodes

\-add\_nodes

\-remove\_nodes

\-add\_edges

\-remove\_edges

JSONFORMAT:

\{\{

"reasoning":"\.\.\.",

"replace\_nodes":\[

\{\{"id":"33"\(idofthenodethatisbeingreplaced\),\*\*setofnewproperties\}\},

\.\.\.

\],

"add\_nodes":\[\],

"remove\_nodes":\[\],

"add\_edges":\[\],

"remove\_edges":\[\]

\}\}

## Appendix EP&ID Interaction Evaluation Prompts

This appendix provides representative natural\-language prompts used to evaluate the LLM\-based interaction layer for the P&ID graph model\. Table[7](https://arxiv.org/html/2608.11220#A5.T7)lists ten representative rules covering different types of reasoning required for P&ID analysis\.

Table 7:Representative P&ID evaluation prompts used in the experiments\.RuleCheck typeNatural\-language promptRule 4Boundary, adjacencyCheck that the last element before the plant boundary is a shut\-off valve or a control valve\.Rule 7Equipment protectionCheck that each pump has shut\-off valves on both the inlet and outlet sides\.Rule 14Directed order, control loopOn the reflux line, check that the flowmeter is located before the flow\-control valve in the direction of flow and is linked to the control loop of this valve\.Rule 23Local topologyCheck that a pressure indicator is connected to the discharge side of the pump\.Rule 48Instrumentation placementCheck that a temperature sensor is installed downstream of the heat exchanger on the main process line\.Rule 72Drain connectionCheck that the low\-point drain branch is connected through a valve and leads to the drain system\.Rule 104Flare connectionCheck that the pressure\-safety valve outlet is connected to the flare system\.Rule 136Path, protective controlCheck that the centrifugal compressor has an anti\-surge loop from the discharge side to the suction side\.Rule 214Recycle branchCheck that the recycle line branches from the main line and returns upstream without breaking the main flow path\.Rule 665Forbidden bypassCheck that the emergency shut\-down valve used for fire isolation has no bypass path around it\.### E\.1Examples of Generated Action Programs

The following listings show two examples of action programs generated by the model\.

ListingLABEL:lst:pid\-rule14\-codeshows a directed\-order check for a reflux line\. The program verifies that the flowmeter is located before the flow\-control valve and that it belongs to the same control loop\.

violations=\[\]

reflux\_lines=sdk\.find\_edges\_by\_attribute\("service","reflux"\)

forlineinreflux\_lines:

path=sdk\.trace\_path\(

start=line\.source,

direction="downstream",

edge\_filter=\{"service":"reflux"\}

\)

flowmeters=sdk\.find\_nodes\_on\_path\(path,node\_type="FlowMeter"\)

control\_valves=sdk\.find\_nodes\_on\_path\(path,node\_type="FlowControlValve"\)

ifnotflowmetersornotcontrol\_valves:

violations\.append\(\{

"line":line\.id,

"reason":"Missingflowmeterorflow\-controlvalveonrefluxline"

\}\)

continue

flowmeter=flowmeters\[0\]

control\_valve=control\_valves\[0\]

ifsdk\.index\_on\_path\(path,flowmeter\.id\)\>sdk\.index\_on\_path\(path,control\_valve\.id\):

violations\.append\(\{

"line":line\.id,

"reason":"Flowmeterislocatedaftertheflow\-controlvalve"

\}\)

linked\_instruments=sdk\.get\_control\_loop\_members\(control\_valve\.id\)

ifflowmeter\.idnotinlinked\_instruments:

violations\.append\(\{

"line":line\.id,

"reason":"Flowmeterisnotlinkedtothecontrolloopofthevalve"

\}\)

result=\{

"rule":"Rule14",

"passed":len\(violations\)==0,

"violations":violations

\}

Listing 1:Example generated code for Rule 14\.ListingLABEL:lst:pid\-rule665\-codeshows a path\-based check for a forbidden bypass around a fire\-isolation emergency shut\-down valve\.

violations=\[\]

esv\_nodes=sdk\.find\_nodes\(

node\_type="EmergencyShutdownValve",

attributes=\{"function":"fire\_isolation"\}

\)

foresvinesv\_nodes:

upstream\_nodes=sdk\.get\_neighbors\(esv\.id,direction="upstream"\)

downstream\_nodes=sdk\.get\_neighbors\(esv\.id,direction="downstream"\)

ifnotupstream\_nodesornotdownstream\_nodes:

violations\.append\(\{

"esv":esv\.id,

"reason":"CannotdetermineupstreamordownstreamsideofESV"

\}\)

continue

upstream=upstream\_nodes\[0\]

downstream=downstream\_nodes\[0\]

bypass\_paths=sdk\.find\_paths\(

start=upstream\.id,

target=downstream\.id,

direction="downstream",

exclude\_nodes=\[esv\.id\],

max\_depth=12

\)

ifbypass\_paths:

violations\.append\(\{

"esv":esv\.id,

"reason":"Bypasspathexistsaroundfire\-isolationESV",

"paths":\[sdk\.path\_to\_ids\(path\)forpathinbypass\_paths\]

\}\)

result=\{

"rule":"Rule665",

"passed":len\(violations\)==0,

"violations":violations

\}

Listing 2:Example generated code for Rule 665\.

## Appendix FFull Oil\-Treatment PFD\-to\-P&ID Enrichment

Figure[10](https://arxiv.org/html/2608.11220#A6.F10)shows the complete enriched graph obtained for the oil\-treatment case study\.

As in the main text, the diagram is shown as a graph representation rather than as a finalized plant layout, node positions are arranged to make the added objects and their relations readable\.

![Refer to caption](https://arxiv.org/html/2608.11220v1/x15.png)Figure 10:Complete graph\-level P&ID enrichment of the oil\-treatment PFD\.The figure shows the final graph after applying the selected source\-backed enrichment rules to pumps, heat exchangers, separators, and outlet boundaries\. Newly introduced P&ID elements are highlighted in yellow\.

Similar Articles

PPDL: LLM-Based Flows as Probabilistic Programs

arXiv cs.LG

This paper introduces PPDL, a probabilistic language for programming LLM-based flows that enables developers to quantify and propagate uncertainty throughout applications, with experimental and case studies on theorem proving.