# Design Optimization of Truss Structures Using a Graph Neural Network-Based Surrogate Model
## 3 Materials and Methods
### PSO Implementation  
Various metaheuristic algorithms have been employed to tackle truss size optimization problems. In 1995, [PERSON] et al. [53] developed a new evolutionary algorithm called particle swarm optimizer (PSO). It is a mathematical method imitating the behavior of a swarm of birds flocking or a school of fish searching for food. This algorithm has fewer parameters and, in turn, is simpler to implement than other available methods, such as genetic algorithms. Also, PSO exhibits a faster convergence rate than other evolutionary algorithms for solving several optimization problems [54]. This algorithm involves a swarm of individual particles, each of which represents a point within the \(M\)-dimensional search space, where \(M\) is the number of parameters to be optimized. A particle possesses a fitness value and a velocity, which are continuously updated to steer the particle towards the bestexperience of the swarm. The velocity \(V_{i}^{m}\) and position \(K_{i}^{m}\) of the \(m\)th dimension of the \(i\)th particle are updated as follows [53; 55]:  
\[V_{i}^{m}\gets w\times V_{i}^{m}+c_{1}\times rand1_{i}^{m}\times(pbest_{i} ^{m}-K_{i}^{m})+c_{2}\times rand2_{i}^{m}\times(gbest^{m}-K_{i}^{m}), \tag{6}\]  
\[K_{i}^{m}\gets K_{i}^{m}+V_{i}^{m}, \tag{7}\]  
where \(\mathbf{K}_{i}=\left\{K_{i}^{1},K_{i}^{2},K_{i}^{3},\cdots,K_{i}^{M}\right\}\) and \(\mathbf{V}_{i}=\left\{V_{i}^{1},V_{i}^{2},V_{i}^{3},\cdots,V_{i}^{M}\right\}\) are vectors representing, respectively, the position and velocity of the \(i\)th particle; \(w\) is the inertia weight balancing the global and local search abilities. A large inertia weight facilitates global search, while a small inertial weight is more suitable for local search. In this study, a method of linearly decreasing the inertia weight over the optimization process [56] is employed. By doing so, the inertia weight is set to 0.9 at the initial point (\(w_{0}=0.9\)). During the optimization, the weight decreases linearly to reach 0.4 at the end of the process (\(w_{end}=0.4\)). The vector \(\mathbf{pbest}_{i}=\left\{pbest_{i}^{1},pbest_{i}^{2},pbest_{i}^{3},\cdots,pbest_ {i}^{M}\right\}\) is the best previous position that resulted in the best fitness (objective) value for the \(i\)th particle, and the vector \(\mathbf{gbest}_{i}=\left\{gbest_{i}^{1},gbest_{i}^{2},gbest_{i}^{3},\cdots,gbest _{i}^{M}\right\}\) is the best position yielded by the entire population. \(c_{1}\) and \(c_{2}\) are the acceleration constants reflecting the weighting of each stochastic acceleration terms (\(c_{1}=c_{2}=2\)). They determine the relative amount of particle movements towards \(\mathbf{pbest}\) and \(\mathbf{gbest}\) positions. Also, \(rand1_{i}^{m}\) and \(rand2_{i}^{m}\) are two random numbers sampled uniformly in the range \([0,1]\). There are minimum and maximum possible velocity vectors \(\left[\mathbf{V}^{min},\mathbf{V}^{max}\right]\) as boundaries defined by the user to limit the velocity of the particle. Considering that the search range for a problem is \(\left[\mathbf{K}^{min},\mathbf{K}^{max}\right]\), the minimum and maximum velocity vectors are defined as follows:  
\[\mathbf{V}^{min}=-0.2\Big{(}\mathbf{K}^{max}-\mathbf{K}^{min}\Big{)}, \tag{8}\]  
\[\mathbf{V}^{max}=+0.2\Big{(}\mathbf{K}^{max}-\mathbf{K}^{min}\Big{)}. \tag{9}\]  
Algorithm 1 outlines the step-by-step procedure of the PSO algorithm, which is programmed based on Reference [55]. Subsequently, the program is enhanced to incorporate the fitness (objective) function and manage the constraints, specifically to solve truss size optimization problems. ```
1:Initialize the population of particles: Set the maximum number of iterations. Set the number of particles in the swarm. Randomly initialize the position and velocity of each particle. Determine the fitness value of each particle. Set the personal best position (\(\mathbf{pbest}\)) of each particle as its initial position. Determine the global best position (\(\mathbf{gbest}\)) of the population. 2:gbest and its fitness value found in the final iteration.