# An Optimization Routing Algorithm Based on Segment Routing in Software-Defined Networks
## 3 Algorithm Design  
### Proposed Optimization Algorithm for Link Weight  
With the increase in traffic in the network, if the traffic cannot be reasonably allocated, it is possible that some links may be congested, whereas other links are not fully utilized. In order to make full use of network resources, the setting of link weight is decisive for path cost and load balance. In this paper, we use multi-objective particle swarm optimization (MOPSO) algorithm [10] to optimize the link weight for path cost and load balance. We set up multiple populations to find the optimal solution through the evolution of collaboration between populations. The two objective functions are used to measure path cost and load balance, respectively. Then, we calculate the first \(k\) shortest paths between the source node and the destination node. Finally, an optimal path is selected from the first \(k\) shortest paths according to the comprehensive evaluation model. We refer to the whole procedure above as Algorithm 1. In addition, we propose an improved MOPSO algorithm in order to better optimize the link weight in the first step. And we call Algorithm 2. ```
1. Input: objective function fitness1, fitness2, source node and destination node
2. Traffic matrix \(\mathbf{G}\) is updated by SDN controller after a certain number of requests
3. Weighted matrix \(\mathbf{G}1\leftarrow\) MOPSO (fitness1, fitness2, \(\mathbf{G}\), source, destination)
4. Find the first \(k\) shortest paths from the source to the destination based on the weight matrix \(\mathbf{G}1\)
5. Find the optimal path \(p\) according to the comprehensive performance evaluation model. 6. Output: the path \(p\)
```  
**Algorithm 1**Find the optimal path \(\mathbf{p}\)  
The particle swarm optimization (PSO) algorithm is a group of intelligent algorithms that achieves optimization through collective collaboration between birds. The MOPSO algorithm is used to solve the multi-objective optimization problem [22] and set up multiple populations. The optimal solution is found by the cooperative evolution between populations. The main steps of the MOPSO algorithm are as follows:  
1. Initialize the population of particles, and customize the particle initial velocity and position;
2. According to the objective function, determine the value of objective function of each particle initialized;
3. According to the definition of the Pareto dominance relationship, the non-inferior solution is stored in an external archive;
4. Select the global optimal value from the external archive;Update the velocity and position of the particle at the next moment by the updating formula of velocity and position;
6. Calculate the new fitness of particles;
7. Update the individual extremum and global extremum;
8. Update the external archive;
9. If the termination conditions are not satisfied, then jump to the third step and then run. Recently, various improved approaches to MOPSO have been developed, e.g., in [23; 24; 25; 26]. [PERSON] et al. [23] propose a MOPSO algorithm with asynchronous updates. When a particle in the swarm is regulated, the Pareto front is immediately evaluated. New positions of the subsequent particles not only depend on the message of the previous iteration but are also partially based on the optimal solutions of the current iteration. In [24], aiming at multi-objective large-scale optimization, many-objective optimization, and distributed parallelism, the authors propose some methodologies and discuss other prospective research trends. In [25], multi-objective optimization problems (MOPs) are transformed into a set of sub-problems based on a decomposition approach, and then each particle is allocated according to each optimized sub-problem. [PERSON] et al. [26] propose an adaptive MOPSO (AMOPSO) algorithm based on a hybrid framework to solve the distribution entropy and population spacing (SP) information. The proposed algorithm improves the search performance in terms of convergent speed and precision.