Sizing and Topology Optimization of Trusses Using Genetic Algorithm

Genetic algorithms are a robust method for a solution of wide variety optimization problems. It explores a big space of design variables in order to find the best solution. From the point of view of a user, the algorithm requires the encoding of design variables into the form of strings and the procedure of optimization uses them for optimization. Here, for the structural engineer, it is crucial to find the form of objective function including the constraints of the task and also to avoid critical states during the solution of structural responses. This paper presents the use of genetic algorithm for solving truss structures. The use of genetic algorithm approach is shown on three cases of truss structures.


Introduction
The essence of structural optimization is to find the lowest possible "cost" of objective function in general meaning while meeting the prescribed conditions.
The goal of structural optimization problems is usually to minimize its structural weight, which is subjected to certain design constraints relating to dimensions, stresses, point displacements and so on. Contemporary research has been conducted either to improve the optimization method or to speed up the structural analysis process. With the advent of computer technology, there has been a development in the field of numerical structural analysis methods based on the finite element method (FEM) [1][2][3], but also on other numerical methods [4,5]. There are many types of optimization problems in structural engineering, and here we will focus our attention on sizing and topology optimization of truss structures using genetic algorithm.
Some studies for the optimization of truss structures consider discrete cross-sectional areas [16][17][18][19][20]. Tiachacht et al. [21] have used a methodology for identifying and quantifying damage in two-dimensional and three-dimensional structures based on a combination of a modified Cornwell indicator and a genetic algorithm. Nobahari et al. [22] have defined an approach based on the beam element damage index using the concept of a residual force vector that helps in the quick and reliable prediction of damaged elements. Sadollah [11] has introduced a new optimization method, the so-called mine blast algorithm (MBA). The efficiency of the proposed optimizer was tested by optimizing several beam structures with discrete variables and comparing its performance to several well-known metaheuristic algorithms. Garg [23] has described a new hybrid gravitational search algorithm-genetic algorithm (GSA-GA) process for solving non-linear optimization problems with mixed variables. The metaheuristic optimization method, or search group algorithm (SGA) applied in the optimization of beam structures, is able to provide the lightest structures [24][25][26][27]. Wang and Ohmori [28] have used an incremental elasto-plastic analysis method to predict the collapse load factor of lattice structures. The obtained collapse load factor is then integrated into the beam optimization using a genetic algorithm. Tejani et al. [29] have introduced a multi-objective adaptive search for symbiotic organisms (MOASOS) and its two-archives technique for lattice optimization problems. The symbiotic organisms search (SOS) algorithm considers the symbiotic relationship among various species, such as mutualism, commensalism, and parasitism, to live in nature.
Kelesoglu [30] has proposed a fuzzy multi-objective method of truss optimization by means of GA. This method is suitable for designing an optimal system with fuzzy goals and constraints. The particle swarm optimization with an aging leader and challengers (ALC-PSO) algorithm, which applies the aging mechanism to particle swarm optimization (PSO) method and HALC-PSO that transplants harmony search mechanism to ALC-PSO as a variable constraint handling, has been published by Kaveh and Ghazaan [31]. Metaheuristic algorithms are suitable for discrete optimization problems because they do not require gradients. Jaya algorithms (JAs) [32,33] have been designed to measure and optimize truss structures. Jaya algorithms have been proven to be very effective for real technical problems.
Assimi and Jamali [34] describe a hybrid algorithm coupling genetic programming and Nelder-Mead for topology and size optimization of trusses with static and dynamic constraints.
Besides optimization of cross-sectional area of truss structures, topological optimization [35][36][37] can be used. When using it, we can change the size of the cross-section area of the bars as well as their mutual relationships. In practice, we can design the shape of the structure with considerable savings in volume and therefore weight. To start the topological optimization calculation, it is necessary to have a rough body shape design that will be optimized. It is also necessary to know the boundary conditions such as removing the necessary degrees of freedom in space, the magnitude and direction of the forces and moments, and the assignment of material properties. Introducing a change in topology makes the solution of the task more difficult and raises the issues that are being explored in graph theory. The objective function of the optimization task is generally multimodal in nature; therefore, a genetic algorithm can be used to search for an optimum whose advantage is no need to calculate the gradients of the objective function. A topological bit is introduced to determine the presence of a bar in the structure. The introduction of the topological bit during encoding allows for a faster variation of the topology compared to when only a bar with a zero-cross-section size serves to change the topology. In the optimization, the constraints for the stresses in the bars as well as the constraints for displacements of the nodal points of the structure can be used. The program has a built-in pseudo-random number generator in the genetic algorithm that determines the unequivocal dependence of the outputs on the input parameters of the task. By analogy with natural selection and genetics in reproduction, genetic algorithms have been successfully adopted to solve many scientific and technical problems and have been proven as an effective means of finding optimal solutions in a large area of problems [38].

Genetic Algorithm and the Formulation of Objective Function
Because the principles of GA are well-known, only the necessary basics will be mentioned here. The genetic algorithm is a search algorithm based on the principle of natural selection. It was established by observing the principles governing the development of living matter in nature. The first monograph on the genetic algorithm was Holland's 1975 work [39]. Since then, a great deal of work has been done to develop the method of the genetic algorithm itself, as well as its application in various fields [40]. Goldberg's monograph from 1989 [40] is considered to be the best known of those.
The aim of the genetic algorithm is to create increasingly strong individuals in a population of individuals. This feature predetermines the algorithm to use problems in solving optimization, i.e., when we are looking for the best of possible solutions to a given problem [41,42].
In the genetic algorithm, design variables are encoded using a bit chain, which is an analogue of chromosomes in biological systems. The genetic algorithm operates in an iterative mode. Each iterative step consists of one generation of individuals, and within it the selection of candidates for the solution is made. The set of these candidates is called the population. In order to find the optimal truss structure, the combination of genetic algorithm and FEM is used. In the FEM, the behavior of a structure is expressed by a system of linear equations: where K is the stiffness matrix of the structure, u j is the vector of nodal displacements, P j is the load vector, n is the number of load cases, j is the load state number, and a is the vector of bar cross-section areas.
From the node displacement vector, the stress in the bar i can be calculated using the relationship: where m is the number of bars in the structure, d i is the vector relating to the dependence of stress on the displacements in the bars, and u jk is the kth component of vector u j . Let us consider that the stress in the bar i cannot exceed in its absolute value σ i and the kth displacement component magnitude u k . Then, the following relationships apply: Considering the limits of absolute value of resulting displacement vectorû t in node t, the following relationship can be written: The goal of optimization is to minimize the function: where c is the cost coefficient per unit volume of structure, b k is the cost per node k, h is the number of nodes, and i is the length of the bar i. The number of nodes h and the number of structural elements m vary during the optimization process. If we consider by the user-defined lower limit value of the crosssection of element a, then all elements with a cross-section smaller than a will be excluded from the structure and similarly, nodes to which no element is connected will be removed.

Program Description
The program was created on the basis of genetic algorithm and the FEM [1]. The program does not have a user-friendly graphical environment; it works in batch mode with a system of input and output files in ASCII format.
The task of minimizing function C in Equation (6), when the Equations (3)-(5) are satisfied, is transformed into the task to maximize the objective function V.
The transformed objective function is: where N 0 is a large positive number to prevent the objective function from obtaining negative values. The penalty functions for constraint equations are: where e is a chosen constant. If Equations (4)-(6) are violated, i.e., if at least one of the following inequalities applies: Then, the penalty is done directly by substituting the value V = 0 and terminating the evaluation part of the program. This achieves under considering the appropriate N 0 that the function V reaches a minimum value.
The correct choice of coefficients occurring in the objective function is very important. As a rule, for example, the value of the penalty functions should be lower than the smallest possible change in value associated with the change in volume.
The flow chart of the optimization process is shown in Figure 1. The input data of the task contain a complete description of the optimized truss structure and the control parameters of the optimization program (GA) itself. Subsequently, the optimization variables are encoded in binary form, and the entire population of first-generation structures is created based on this. This first population is formed by modifying the encoded variables of a given structure using a random number generator. The next step is the transformation of the data to enter the analysis using FEM and the solution of all structures in the generation using FEM. All future generations are created by a genetic algorithm. The subsequent decision block decides on the continuation of the optimization process, or the completion of the solution of the problem. The optimization process itself using GA also includes the evaluation of the objective function of the subtask. If during the finite element analysis, the stiffness matrix of the structure is singular, the finite element analysis is completed. In this case, the structure is considered problematic, and it is assigned an objective function value that makes it less suitable for further "reproduction" in the GA process. The genetic algorithm contains known steps: selection of members of a given generation for further reproduction (selection), crossover, and random mutations of certain bits in the chromosome representing the description of a certain structure (mutation).  Forms of implementation of these procedures can be various and are sufficiently described in the literature. In the coding process, a bit is assigned to each bar in the chromosome, allowing its inclusion or exclusion from the structure. In the end, in addition to size optimization, optimization also involves optimizing the topology of the bar structure.
The input data are stored in three files. One contains a complete description of the initial optimized structure in the form normally occurring in the FEM. The second file contains objective function coefficients and constraints for individual bars. The last of the input files contains control parameters for the subroutine of the genetic algorithm itself. The output files consist of data output from the FEM program for the most successful individual of the last generation, the course of the objective function values, and the size of the structure volumes in each generation.
Each design variable is described by a string of bits that represents the cross-sectional size of the bars. In addition, a topological bit is used for each variable in the program to speed up the search for the optimum by changing the topology. A bar is excluded from the structure if the size of its cross-section is zero, or if it is lower than the specified limit size, or if the topological bit is zero.
The program allows us to restart the task by means of rebooting and then to use the best solution attained so far. In addition to the three already mentioned classical steps of the genetic algorithm, the program also incorporates a strategy to preserve the best individuals of the population ensuring that the best solution is transferred to the next generation.

Examples of Truss Structure Optimization
In the following three examples, truss structure optimization will be shown. Example I. In Table 1, the coordinates of the point of the truss structure ( Figure 2) are shown.   In the first case, the 25 bar structure shown in Figure 2 loaded by self-weight is optimized. No constraints relating node displacements were applied here. The maximum allowed stress in the bar is 90 MPa. The load force (beside self-weight) is P y = −28 kN and acts in node 9. The other parameters necessary for the solution were Young modulus E = 2.058 × 10 5 MPa, N 0 = 200,000, c = 1, e = 10, a = 0.11, b k = 0 for k = 1, . . . , 10. Five bits were used to parameterize one variable and the maximum size of cross-section was 9.1 cm 2 . The population sizes were 20 and 40 individuals, respectively.
In Figure 3, there is a graphical representation of volume change during optimization for the generation size of the above-mentioned populations.   The results of the optimization are given in Table 2, as well as in Figure 4.   Example II.
In the second case, the truss structure consisting of 29 bars was optimized considering the self-weight of the structure. There were no constraints on the displacement of the nodal points. The maximum allowable stress in the bar was 60 MPa. A load force (beside self-weight) P y = −65 kN was applied at node 9 ( Figure 5). Other parameters needed for solution were E = 2.058 × 10 5 MPa, N 0 = 4,000,000, c = 1, e = 10, a = 0.01, b k = 0 for k = 1, . . . , 11. Five bits were used to parameterize one variable and the maximum bar cross-section was 15.3 cm 2 . In this case, the solution was computed in three ways:  In Table 3, the coordinates of the point of the truss structure are shown. Table 3. Coordinates of the nodes.  The results of the optimization are given in Table 4. Graphical outputs displaying individual cases are shown in Figures 7-9.     Example III. In this case, the structure on Figure 10 consisted of 15 bars, considering the load from the weight of the bars as well as several load cases is optimized. The specific weight of the material was γ = 7.8 × 10 4 Nm −3 . The design was optimized sequentially for three load cases; the third case consisted of two forces. The forces for individual cases were:  Superscript denotes the node number where the force acts. Other parameters needed for the solution are E = 2.1 × 10 5 MPa, N 0 = 80,000,000, c = 1, e = 10, a = 0.51, b k = 0 for k = 1, . . . , 7. Seven bits were used for parameterization of one variable, and the maximum bar cross-section could be 63.5 cm 2 . The population consisted of 30 individuals. The maximum allowed stress was 50 MPa.
In Table 5, the coordinates of the point of the truss structure are shown.  The cross-section areas as well as the stresses in the individual bars are shown in Table 6. Figures 11-13 illustrate the optimized structures as they were computed for the individual load cases. The course of the change in the volume of the structure is shown in Figure 14. Stress (MPa)  Figure 11. Initial 15 bar structure optimized for load case 1. Figure 11. Initial 15 bar structure optimized for load case 1.     On the basis of Table 3 and the fact that for the load case No. 1 the resulting structure is statically determinate, it can be stated that bar number 7 should preferably have a crosssectional area of 15.5 cm 2 .The use of this cross-section would achieve the maximum possible stress in the structure at the prescribed set of cross-sections. The program, therefore, came close to the optimum value. The calculation could be continued by a simple restart, or it could continue on a set of bars that have a non-zero cross-sectional size based on the previous calculation.

Conclusions
Genetic algorithms are an effective tool for the optimization of nonlinear tasks. Its advantage in topological optimization of truss structures is that it is not necessary to calculate gradients of objective and constraint functions. This method is able to search a large space of design variables and is not dependent on the input parameters of the task. Of course, the generated structures also include cases where the structure has all bars with a zero cross-section, individual bars form a mechanism, parts of the structure are not interconnected, etc. However, even after excluding such incorrect cases, the set of potential solutions is very large. The solution resulting from the program cannot be considered a global optimum in a given space because, given the size of the space, it is virtually impossible to search it entirely. However, the program can serve as one of the means of optimizing the truss or frame structures.
The benefit of the article lies in the combination of topological and size optimization, while for each bar an additional bit is introduced, which decides on the presence, of the bar in structure independent of cross-section area proposed by optimization program. Thus, the bar can be removed from the structure by making its cross-section area very small, or by switching the above-mentioned bit. This speeds up the topological optimization process. In the optimization process, the limiting parameters can be considered allowable stresses, allowable displacement of the nodes in the direction of coordinate axes, resulting in node displacements. In addition, because there are costs associated with joining bars in the truss, these costs can potentially be included in the target function. Included can be the costs of individual bars connected with the unit volume cost of specific material.
In the first case, a spatial bar system with 25 bars was solved, loaded by its own weight and force specified in one node. In the next two problems, planar bar structures are solved. In the first of these, it is a 29 member structure loaded again by its own weight and force in one node. In the third case, it is a structure with 15 bars loaded by its own weight and three load cases. In all three cases, the number of bars is given for the initial state of the structure before optimization. As a result, it can be seen that, in all three cases, optimization was performed and a more favorable state in terms of weight and stress ratios was achieved.
Another goal of the authors was to develop a user-friendly graphical environment for input and output data. We also wanted to use the system developed by us to optimize specific tasks from practice.

Data Availability Statement:
The data presented in this study are available on request from the corresponding author.