# An Optimization Routing Algorithm Based on Segment Routing in Software-Defined Networks
## 3 Algorithm Design
### Algorithm Summary  
In this paper, we focus on the evaluation of path quality in order to get a better transmission quality under the condition of satisfying the overall service quality of the network. So, we combine the optimization of link weight with the comprehensive evaluation of paths to find the best path for SR in SDN. In order to avoid partial link congestion caused by excessive energy consumption and the unbalance of traffic distribution in the network, we take the path cost and load balance as the two optimization objectives to establish the optimization algorithm model and apply the MOPSO algorithm or our proposed improved MOPSO algorithm to solve the optimal link weight. Then, in order to guarantee the specific need of the business performance of the users or the actual requirement, we use a performance assessment model to make a comprehensive assessment from the first \(k\) shortest paths to find the path of best performance. For example, there is a routing request whose source address is A and destination address is B. The SDN controller first uses the improved MOPSO algorithm to optimize the weight of the link, and make the path cost and load balancing index in the network smaller. Then the first \(k\) shortest path is calculated. Assuming that user uses Web interactive services to book online tickets, user requires the network to respond quickly, minimizes network delay and packet loss rate. At this time, the weight of the scheme can be set to \(W^{\prime}=[1,0,0]\). Then the fuzzy judgment matrix can be established according to the importance of network parameters to determine the weight vector of the criterion. Through the measurement of the indicators of \(k\) paths (bandwidth, jitter, packet loss rate), the indicators can be standardized, and the service performance evaluation value of \(k\) paths can be calculated. That is, an optimal path is chosen according to the user's requirement for service and the network performance index of \(k\) paths. The steps of Algorithm 1 are as follows: First, we use the MOPSO algorithm to optimize the link weight for link cost and load balance. Then, we find the first \(k\) shortest paths. Finally, we use the comprehensive evaluation model to find the best path. Furthermore, in order to make the optimization result more accurate, we propose an improved MOPSO algorithm in the first step of Algorithm 2. The MOPSO algorithm and the improved MOPSO algorithm both need multiple iterations to update the velocity and position of a large number of particles to find the optimal solution. If the size of the archive is not restricted, all non-inferior solutions that satisfy the basic conditions can be entered into the archive. However, as the archive is updated in each iteration, the disadvantage of establishing the archive according to the MOPSO algorithm is that the size of archive is too large and the cost of calculation is increased. In the worst case, if the location of all the particles found in every generation can be entered into the archive, the computing complexity of each generation is \(O(mN^{2})\), where \(m\) is the number of objects, and \(N\) is the size of the population. So the calculation complexity of running an algorithm is \(O(mT_{max}N^{2})\), of which \(T_{\max}\) is the largest iteration. The improved MOPSO algorithm restricts the size of the archive. When the size of the archive reaches a predetermined upper limit, it is necessary to delete some non-inferior solutions in the archive and reduce the computational complexity to a certain extent. So the computational complexity of two algorithms is large. And the two algorithms need a longer running time than other traditional algorithms when link weights are optimized. So, our proposed algorithms are more suitable for systems that require more accurate experimental results, better equipment performance, and real-time requirements that are not too strong. How to design a multi-target algorithm with lower complexity and faster speed is also a problem to be solved in the future.