Abstract
Ship pipe route design (SPRD) is to search the near optimal pipe routes that meet various constraints and objectives in a constrained ship space, which is one of the most time-consuming and difficult process in ship production. This paper proposes an automatic approach for solving the SPRD problem based on the grid theory and particle swarm optimization (PSO) algorithm. The fitness functions which are used in the PSO algorithm are formulated to evaluate the engineering objectives and constraints. A fixed-length particle encoding is improved according to the characteristics of ship pipe routing in 3-D space to overcome the shortcomings of variable-length encoding. Mutation operation is combined with the computing process of PSO to avoid the problem of local optimum and to accelerate the convergence rate. Based on the proposed algorithm, the multi-swarms optimization with co-evolution mechanism is applied to solve the problem of multiple pipes and branch pipe routing. The simulations of pipe routing examples are conducted by using VC++ and OpenGL, which demonstrate the feasibility and efficiency of the proposed algorithm. Results show that our approach can route the most common variations of ship pipes automatically under certain constraints in 3-D space. Moreover, the approach can also be applied to other similar path-planning or pipe-routing problems.
Keywords
Introduction
Pipe route design (PRD) has been a popular research topic since 1970s. The goal of PRD is to find optimal route or path between interface locations under various kinds of constraints in a 2-D or 3-D layout space. Lots of methods are studied, including: deterministic methods, e.g., maze algorithm [18], escape algorithm [10],
The design of ship piping system usually includes five successive phases: preliminary design, functional design, detail design, production engineering, and system support information. Ship pipe route design (SPRD) plays an important role in the detail design phase since it takes over 50% of the total detail design man-hours and many other activities of detail design depend on it [22]. However, it still relies on pipe engineers’ experience and CAD software. A large amount of pipes have to be routed manually in working areas according to various rules and regulations. To improve the efficiency and quality of SPRD, some automatic methods have been proposed. Kang et al. [13] developed an expert system to route pipelines automatically. Park et al. [22] described a cell-generation method to get pipes on the basis of routing patterns. Lu et al. [21] proposed a space modeling method to simplify environment for 3-D pipeline in a ship engine room. Fan et al. [7,8] and Jiang et al. [12] used several methods based on ant colony algorithm to solve the SPRD problem. Asmara and Nienhuis [1–4] provided a pipe routing framework for detailed ship design. Kimura and Ikehira [16,17] described pipe arrangement considering valve operationally and branches. Kim et al. [15] presented a pipe routing system in practical CAD environment using network optimization. In a word, lots of methods have been proposed and verified so far, among which the most complete and mature system is developed by Asmara [1].
In Asmara’s work [1], different path finding algorithms were utilized and compared, and

Mutually intervening case.
In this paper, a method based on PSO algorithm is proposed to solve the SPRD problem. PSO is originally attributed to Kennedy, Eberhart, and Shi [14,23] and was first intended for simulating social behavior, as a stylized representation of the movement of organisms in a bird flock or fish school. It was observed powerful to find optimal solutions of the numerical and qualitative problems. Moreover, it is a very efficient global searching algorithm which has fewer parameters and simpler implementation. Many research studies have been carried out to solve path planning or PRD using PSO algorithms. Foo et al. [9] presented a 3-D path planning problem formulation and solution approach using PSO. Liu et al. [20] simplified the aero-engine 3-D rotational space into 2-D planes, and then modified PSO was employed to solve the pipeline arrangement in this 2-D model. Asmara [1] briefly mentioned a method to solve the PRD problem using PSO. In Asmara’s method, the space is also divided into grids. A chromosome is defined as a turning grid location of the path, in which such location indicates a pipe bend. And the number of chromosomes in a population is the same as the maximum number of turning locations.
However, the SPRD problem has its own characters compared with pipeline arrangement in 2-D space or robot path planning in a free space. Ship pipes need to be routed orthogonally in 3-D working area under various kinds of constraints. Therefore, PSO is modified and adopted to find optimal pipe routes in 3-D space, which provides a novel method to solve SPRD. Furthermore, based on the method of routing single pipe, an algorithm framework is proposed to solve the routing of multiple pipes and branched pipes, in which pipes and branches are presented by different swarms. In this paper, the potential of routing pipe with PSO algorithm is validated using the designed test cases, and the weights of constraints in fitness functions were set manually by trial. In order to apply the proposed method in real ship piping, some following researches need to be done in the future, e.g., validating the method using real CAD model data, calibrating the weights of the constraints to fit engineering requirements, etc.
The rest of the paper is organized as follows. Section 2 describes the principle of PSO algorithm. Section 3 presents the formulation of the SPRD problem. Section 4 describes the process of solving SPRD based on the modified PSO algorithm. Section 5 provides the simulations conducted and discusses the results. Finally, Section 6 concludes the paper.
In the PSO, an initial randomly generated swarm (a set of particles) flies towards an optimal solution in the D-dimensional search space where each particle represents a potential solution to the optimization problem, and reaches the global optimum over a series of iterations. Each particle in the swarm explores the problem space based on the information provided by previous best particles and the global best particle. PSO then uses this information to generate a velocity vector indicating a search direction towards a promising solution, and updates the locations of the particle.
Each particle with index k in the swarm,
ith dimensional component of the velocity of particle k at time t.
ith dimensional component of the position of particle k at time t.
ith dimensional component of the personal best (pbest) position of particle k at time t.
ith dimensional component of the global best (gbest) position of the swarm at time t.
At each iteration in a PSO process, velocity and position updates are performed for each dimensional component,
Each of the terms of the velocity updates equation play different roles.
In order to prevent oscillations, velocity clamping is used to control the maximum velocity of each particle. For a search space with the range
It can be seen from the PSO algorithm that the length (dimension) of the particle encoding needs to be fixed, i.e., fixed-length encoding. An alternative to fixed-length encoding is variable-length encoding, which is commonly adopted to solve path planning problem in grid space. E.g., a pipe route can be encoded as a series of continuous grid positions or a series of direction vectors indicating the movements of an object from the starting point to the end point. But in our method, a pipe route is converted from a particle which is encoded as a series of control points in pipe path (see Section 4.1). Since the number of control points is fixed and not too much, the performance based on this fixed-length encoding is much higher than that based on the variable-length encoding used by Ito [11]. Also, the proposed encoding method significantly differs from Asmara’s method [1], in which the number of pipe bends should be specified in advance. Moreover, the fixed-length encoding mechanism designed for PSO algorithm can be adopted by other evolutionary algorithms to solve pipe routing problem. In order to meet some special constraints of SPRD as well as to fit the pipe routing in 3-D space, the PSO algorithm is also modified.
Problem formulation
Objectives and constraints in SPRD
There are lots of objectives and constraints in the SPRD problem. To verify our proposed algorithm, some of the general objectives and major constraints have been taken into account as follows.
Connect pipe interfaces (nozzles, endpoints).
Avoid obstacles and routed pipes.
Arrange pipe orthogonally.
Minimize the length of pipe.
Minimize the number of pipe bends (elbows).
Route pipe close to walls or devices for better supporting.
Share pipe racks if possible to reduce installation cost.
Arrange pipes to have the same height (in a layer) if possible.
Physical constraints (1)–(3) are restrictive, while economic constraints (4)–(7) and aesthetic constraint (8) are quantifiable. Therefore, pipe routing optimization seeks to find the best path from an economic point of view among the set of feasible paths restricted by the physical constraints.
It should be noted that the preferences of the constraints are different in practical pipe engineering. E.g., the physical constraints (1)–(3) should have the highest priorities; the installation costs of constraints (6) and (7) are usually more expensive than the material costs of constraints (4) and (5); the bends cost of constraint (5) is more expensive than the length cost of constraint (4) because too many bends may result in unacceptable layout even if the pipe is short. Therefore, costly constraints are usually assigned with higher weight values. To find optimal solutions for real piping cases, lots of weight adjustments need to be performed according to the relative emphases of the constraints by experiment and comparison.
Fitness function
In the SPRD problem, the workspace can be simplified to a 3-D cubic box space. The space is decomposed into grids according to the pipeline diameter and the requirement of minimum interval distance. Grid method has been applied by many studies because it not only can guarantee the pipeline to go orthogonally, but also it can present many routing constraints easily.
The single pipe route is presented by a series of grids which connect the starting grid and the end grid in the space. The structure of a pipe path can be presented as follows:
In the proposed method, some constraints (2, 4, 5, 6, and 7) are considered as the objectives of SPRD, and can be evaluated in the fitness functions. The other constraints (1, 3, and 8) are controlled by the restrictions in the implementation of the algorithm and the space model.
To satisfy constraint (2), the penalty function
To cope with constraint (4), the length function
To cope with constraint (5), the bends function
To cope with constraint (6), the energy function
Based on the above functions, the fitness function of single pipe routing is defined as Eq. (4)
The multiple pipes routing can be divided into the arrangement of several single pipes. However, when routing a single pipe, the impact produced by the other related pipes needs to be taken into account.
The overlapping among different pipes are not expected, so a function used to represent the penalty of collision is introduced by
In the stage of installation, pipes need to be supported by racks, and the pipes side by side are supported by the same series of racks. To reduce the cost of installation, arrangement of pipes as a group is encouraged. Therefore, the bonus function

Installation path.
Based on Eqs (4), (5) and (6), the fitness function of multiple pipes routing is formulated as Eq. (7)
The branch pipe routing is also broken down into the routing of several single pipes, which has only one starting point and several end points, or has only one end point and several starting points. The purpose of routing branch pipe is to minimize the total length of all the branches. The overlapping between different branches is allowable, which is different from multiple pipes routing. But the length of the repetitive parts is only counted once.
To induce the overlapping of different branches,
Based on Eqs (4) and (8), the fitness function of branch pipe routing is defined as Eq. (9)
Particle encoding
One of the key techniques in designing a successful PSO algorithm is the encoding method which aims at creating a suitable mapping between problem solution and PSO particle. In this section, we propose a new fixed-length encoding method used for pipe routing in 3-D space. Figure 3 shows an example of a virtual routing area.

The encoding model.

Creation of path segment based on control points.
Because the routing space is divided into grids, this mechanism of encoding could be implemented with less effort based on the grid model. Each control point is able to find a grid corresponding to it, and each virtual plane is corresponding to a layer of grids. The minimum value of step is 1, which means each layer of grids provides a control point. In case of a large routing area, step is usually set to a value bigger than 1 to reduce the dimensions of particle. If the distance between

Example of encoding in grid model.
During the process of routing a pipe from one point to another, the direction of virtual planes is firstly selected based on the relative positions between the starting point and the end point. In Section 4.1, the virtual routing space is divided by virtual planes which are perpendicular to the direction of Z axis. However, this encoding strategy cannot always find feasible solutions. For example, if the Z coordinates of
The direction with larger probability is more likely to be tried, as illustrated in Fig. 7. If an optimal path is found by using particles encoded in a certain direction, it’s no need to try the encodings in other directions.

Direction of virtual planes.

Probability of direction based on end points.
PSO is commonly used in solving optimization problems in continuous search space. In this paper, the routing space is divided into adjacent grids, and there is no space gap between any adjacent grids. No matter where a control point locates, it belongs to a specific grid (control grid) in this space. Therefore, the update formulas of velocity and position in standard PSO can be applied to the path optimization in the grid model. As previously described, each particle corresponds to a grid path defined by the control points. So the kth particle is defined as follows:
The position and velocity of the kth particle are expressed as Eqs (13) and (14).
In Eq. (14), zero indicates that velocity does not update in that position. The kth particle in the swarm is updated according to Eqs (15) and (16).
After each updating, the values of
Consideration of generation method for initial particles
In order to speed up the convergence of the proposed algorithm, it’s better to produce a swarm consisting of high quality particles. Two methods are used in this paper. (1) Each control point of a particle should not locate in an obstacle. If it drops into an obstacle, let it regenerate. By this means, the probability of intersection between routing path and obstacles is greatly reduced, and the path with small or none penalty will become more promising during the process of iterations. (2) Try to encode the control points as straight as possible, which can reduce the number of bending parts. As shown in Fig. 8, when generating a new control point, it is expected to be placed in the same direction as the previous control point. Only if the new position selected by this method drops into an obstacle, other possible positions could be tried.

Particle initialization.
The two main advantages of PSO over the other algorithms are its algorithmic simplicity and the ability to control convergence. However, it has some drawbacks including: it may prematurely converges to a stable position, which is not guaranteed for a local optimum [25], and it is also a kind of stochastic approach, which means that no specific parameter configuration can be applied to all problems. To overcome the limitations, this paper hybrids the standard PSO with mutation mechanism to increase the diversity of the swarm and the ability to avoid being trapped into a local minimum.
When the global best particle (gbest) does not update its position over some designated iterations (ThresholdNum), the mutation operation is performed on gbest particle. With this help, the stagnated global best particle is likely to fly to a better search space. The procedure of mutation can be briefly described as follows:
Initialize counter c, Back up the global best particle, tbest ← gbest. Randomly select two control points Re-generate the control points from Create the grid path of tbest based on the updated control points. Evaluate the fitness of tbest, and if tbest is better than gbest, then update gbest, gbest ← tbest. Increase counter c, If
Considerations of engineering constraints
Direction of endpoints
In actual pipe routing work, one of the constraints is about the direction of endpoint, which is not considered in the implementation of our particle encoding. To cope with this constraint, each original endpoint is firstly moved to a new position according to its specification of direction, and then the particles are encoded based on these new endpoints. Finally, each straight pipe segment between the original endpoint and the new endpoint is added to complete the entire path of a pipeline.
Layered pipe arrangement
In some cases, routing pipes at a certain height or height range is favorable in practical pipe engineering. The layered pipe arrangement can make the workspace more rational and aesthetic. Our proposed method could be used to route a pipe in this condition. E.g., supposing the height direction of a workspace is along Z axis, in order to meet the height requirement, the Z coordinates of the control points are only allowed to move within a specified height range. Moreover, if the layout height is fixed, the Z coordinates of the control points do not need to be updated. In such cases, it is more likely to find good results during the computing time because the workspace has been reduced a lot.
Flowchart of a single pipe routing
The flowchart of the algorithm based on PSO for single pipe routing is shown in Fig. 9.

Flowchart for solving single pipe routing based on PSO.
The computational complexity of the proposed algorithm is an aspect that should be considered in practical applications. The measures of algorithm complexity are the execution time and space, which are often estimated by big O notation.
Time complexity
An efficient algorithm is the one whose worst case running time is bounded by a polynomial of the problem size. PSO performance is usually measured by the numbers of particle updates and evaluations, which are carried out during the course of a PSO run. Therefore, the PSO’s time complexity is measured as a function of the number of iterations, the number of particles and the problem size, where the problem size in this algorithm is related with the dimension of encoding and the evaluation of particles. The time complexity function
If the PSO algorithm is combined with mutation operations, an additional time cost
In which Cost is the sum of a mutation cost and an evaluation cost.
Space complexity
Space complexity is a measure of the amount of working memory that an algorithm needs. The majority of memory used in this algorithm is for storing the grid of cells and the particles, which are allocated at the initialization stage of the algorithm and can be predicted by Eq. (19)
As can be seen from Eq. (19), the memory need of this algorithm is almost stable over time.
Multiple pipes routing and branch pipe routing based on multi-swarms optimization
In order to solve the routing optimization of multiple pipes and branch pipe, the cooperative idea which was proposed by the previous work can also be applied here [12]. In this algorithm, to solve single pipe routing, all the particles belong to only one swarm. But to solve multiple pipes and branch pipe routing, the particles belong to different swarms, which set up a cooperative ecological system. Each swarm is used to route a single pipeline. All the swarms take the same process of evolution in iterations, and the representative of each swarm together forms an entire layout solution. During the optimization, each swarm is under the influence of other swarms, and all the swarms will become more and more collaborative. Finally, the optimal result of the whole problem will be reached. The flowchart of multi-swarms optimization algorithm for solving multiple pipes and branch pipe routing is shown in Fig. 10.

Flowchart for solving multiple pipes and branch pipe routing based on multi-swarm optimization.
As can be seen in Fig. 10, the process of routing multiple pipes and branch pipe is almost the same. The difference only exists in the evaluation method for a solution, which has been presented in Section 3.2. Equations (5)–(7) are for the evaluation of multiple pipes routing, while Eqs (8)–(9) are for the evaluation of branch pipe routing.
Space model
The proposed algorithm for pipe routing is compiled with Microsoft VC++ and OpenGL under Windows 7 x64. All computational experiments are carried out on a PC with Intel i3 CPU 3.30 GHz and 8.00 GB RAM.
The layout space is simplified as a box whose coordinate values of the diagonal positions are
In the following cases, the layout space is divided into grids by 20 layers × 20 columns × 20 rows, and each grid can be indexed by a position structure denoted as (layer ID, column ID, row ID), where each ID is an integer value in range
Due to the random computing process of the proposed algorithm, each experiment is executed 15 times, and the results of the optimal ones are selected to show here.
Simulation for single pipe routing
In this case, the terminal grids of the routing pipe are A
The diagonal coordinates of the obstacles
The diagonal coordinates of the obstacles
The parameters set for single pipe routing

Result of single pipe routing.
The results of the 15 runs are listed in Table 3, which shows that the simulations can obtain good solutions in a very short time frame. And the fitness value curve of the 1st simulation is shown in Fig. 12. Because the proposed algorithm is a population based stochastic optimization technique, various candidate solutions can be obtained in different runs. Although sub-optimal solutions have slightly larger fitness values, they may be more reasonable in some conditions from the view of engineering, and can be taken as important references for pipe engineers.
The results of single pipe routing

Fitness value curve.
In this case, there are two pipes to be routed. The starting and end grids of each pipe are listed as follows: P1: A (15, 1, 19)–B (13, 8, 0); P2: C (15, 0, 19)–D (15, 10, 0). The set of weights in Eq. (4) is selected as
One optimal solution is shown in Fig. 13. Each pipe is connected and there is no collision between any of the pipes and no collision with any of the obstacles. The pipes are arranged along the surface of units with low energy as much as possible, and many parts of the two pipes can share the same installation path.

Result of multiple pipes routing.
Among the 15 times of running, our method failed to find feasible solution for 4 times. The failure is due to the complexity of the routing and the weak constraint of the fitness function which cannot absolutely prevent the collision between pipes. However, as Asmara [1] noted that the non-deterministic method for parallel arrangement is suitable to solve the shortest path problem for up to 2 or 3 pipes at the same time. To reduce the probability of collision between pipes, one possible solution is to take the height of each pipe as optimization variable and arrange different pipe at different height.
In this case, the terminal grids of the branch pipe are A (0, 0, 19), B (0, 16, 0), C (19, 14, 10), D (12, 4, 0), and E (8, 2, 10). A (0, 0, 19) is selected as the starting point. OverlapBonus used in Eq. (8) is 1000, and the other parameters used are the same as Table 2.
One optimal solution is shown in Fig. 14(a). It can be seen that the layout of this branch pipe can meet the constraints and the objectives, and the overlapping paths of different branches are as long as possible.

Result of branch pipe routing.
As mentioned in Section 4.6.2, in practical routing, it is expected that the main part of pipelines can be arranged at a specified height. Due to the reduction of space, the probability of overlapping between pipes will grow, which is favorable for branch pipe routing. E.g., when layer ID is set to 7 as the desired height, one optimal result is presented in Fig. 14(b). Compared with the result in Fig. 14(a), most part of the branch pipe in Fig. 14(b) is routed at the specified height, which makes the workspace more rational.
From the results of simulations, we see that the piping height is an important factor that affects the layout of multiple pipes and branch pipe. Therefore, how to identify an optimal height or height range for routing will be studied further in our future work.
This paper proposes a new method for solving SPRD problem based on a modified PSO algorithm. The definition of fitness functions, the encoding of particles to deal with a pipe route, the rules to update velocity and position, the method to generate initial individuals, the considerations of engineering constraints as well as the complexity of the algorithm are described. The PSO is combined with mutation operation to overcome the shortcomings of local optimum. Moreover, based on the above ideas, multi-swarm optimization and co-evolution mechanism are applied to solve the problem of multiple pipes and branch pipe routing. A prototype system has been developed to conduct SPRD using the proposed algorithms, and the simulation results show the validity of this approach.
The following work will be studied in future: optimization of the piping height to improve layout effect, parallel implementation of the algorithm to improve the performance, consideration of more objectives and constraints, and integration with existing commercial computer aided design (CAD) systems.
Footnotes
Acknowledgements
This study is supported by the National Research Program for High Technology Ship Development, China (No. MIIT 2014-498), the Science and Technology Project of Guangdong Province, China (2015B090904010 & 2016B090918092), and the Marine Renewable Energy Special Fund, China (QDME2013ZB01).
