# The Intelligent Layout of the Ship Piping System Based on the Optimization Algorithm
## 2 Optimization A*-Genetic Algorithm for Intelligent Arrangement of Single Pipeline
### Objective Function and Fitness Function  
When arranging a ship's pipeline, it is necessary to meet various pipeline design specifications, relevant conventions, and experts' experiences. After summarizing, the rules and constraints to be followed when arranging the pipeline are as follows:  
1. Pipelines should be connected to specific pipeline interfaces to ensure the connectivity and legality of pipelines. 2. If there is no special requirement, the pipeline should be arranged orthogonally. 3. It is necessary to ensure that there is no physical interpolation between pipelines and equipment obstacles, as well as between pipelines and pipelines. 4. The length of the pipeline should be as short as possible to reduce the cost of the pipe. 5. The number of elbows in the pipeline should be as few as possible to reduce the cost of elbows. 6. In principle, the pipeline should be installed along the bulkhead, bilge, and supportable equipment surface as far as possible to reduce the installation cost. The pipeline should be far away from dangerous equipment to reduce the impact of equipment vibration on the pipeline and the probability of risk. For example, steam, oil, and water pipes should not be installed above and behind electrical equipment, generators, and essential instruments. Rules (1)-(5) are strict rules, that must be satisfied in the process of pipeline arrangement, and rules (6) are weak rules that should be satisfied in the pipeline arrangement as much as possible. Figure 1: Schematic diagram of segmentation–modeling–combination of devices. Among them, rule (1) can be realized by searching the route from the starting grid to the target grid through the genetic algorithm logic itself. Rule (2) is realized by setting the search direction, which is specified in this paper that each grid can only be searched in six directions, i.e., a list is set in the program ([1, 0, 0], [0, 1, 0], [0, 0, 1], [-1, 0, 0], [0, \(-1\). 0], [0, 0, \(-1\). 0], [0, 0, \(-1\). 0], [0, 0, \(-1\)]), where each element of the list corresponds to a search direction. For example, the search direction represented by [1, 0, 0] is the positive X-axis direction, and the grid (5,5,5) reaches the grid (6,5,5) after searching once in the positive X-axis direction. Rule (3) is implemented by continuously calling the interpolation detection function described in the previous section when searching for the pipeline route. Rules (4) to (6) are implemented by setting the length cost, elbow number cost, energy value cost, etc., and assigning appropriate weight coefficients to these three objectives. This simplifies the complex multi-objective optimization problem into a single-objective optimization problem, thus reducing the complexity of the problem and speeding up the solution rate. Each mesh in the layout space is assigned an energy property, and the energy value of each mesh is set according to the rules. The energy cost of an individual pipe is obtained by adding up the energy values of all the grids through which it passes. The principle of assigning energy value to each grid is as follows: if the rules require the pipeline to be installed along the bulkhead, bilge, or supportable obstacle surface as much as possible, the network corresponding to the bulkhead, bilge, or supportable obstacle surface is assigned a lower energy value. The grid corresponding to the area where the pipeline is expected not to pass as much as possible, such as the generator, is assigned a higher energy value. Meanwhile, the grid corresponding to other common passable areas with no special requirements is assigned a medium energy value. In a word, the lower the energy value, the higher the priority of the grid in the piping arrangement. In genetic algorithms, the magnitude of the fitness value characterizes the level of difference between the individuals in the population and the best individuals. The fitness value often determines the genetic algorithm solution's convergence speed and quality level.