Computational methodology for the optimal design of steel truss frames integrating MATLAB and FEA platforms

Abstract Seeking to define more robust and executable structures, this article presents a computational framework for the optimal design of steel truss frames, which integrates two software of great prominence in structural engineering, MATLAB and ANSYS. Computational interfaces were created to enable the automation of the iterative optimization process. The optimization algorithm and computational interfaces were developed on the MATLAB platform, while structural analyses were performed with the ANSYS Mechanical APDL platform. Some details of the computational implementation are presented herein. The objective is to minimize the cost of structures by determining the optimal positioning of nodal coordinates and the optimal choice of commercially available structural profiles - shape and size optimization, respectively. For shape optimization, a computational model was defined to automatically generate the geometry of the structure, maintaining some intrinsic relations of symmetry and collinearity between elements. The design constraints are critical nodal displacements, stresses, and slenderness of elements, following the requirements of ABNT NBR 8800:2008. To exemplify the application of the proposed methodology, this article presents the optimal design of trusses for roofs of industrial sheds, considering its non-linear geometric behavior, typical of this type of structure.

Academic studies focused on structural optimization often need to develop their proprietary computational codes for structural analysis and design, and these codes often lack efficiency or robustness.In this context, the use of commercial programs is a more trustworthy and efficient approach to accomplishing these tasks.However, there are few publications detailing the simultaneous use of commercial structural analysis and design programs, working synchronously.
With the evolution of science and technology, the finite element method became a widely used tool for solving numerous engineering problems with good precision.For structural optimization specifically, several finite element analysis (FEA) programs are available, such as ABAQUS, SAP, and ANSYS; the latter of which was adopted for the present study.ANSYS can be used for modeling a wide range of engineering problems, including distinct types of structural analyses, such as static, dynamic, modal, harmonic, spectral, and buckling analyses.On the other hand, MATLAB is a powerful computational platform that not only provides native optimization algorithms but also allows users to create and improve authorial algorithms.The platform features a programming language that is user-friendly, fast, and powerful for numerical analyses.
In this context, a robust and reliable solution was developed by integrating two commercial programs widely used in structural engineering: MATLAB and ANSYS.This computational framework operates interactively throughout the optimization process, allowing users to define and modify important parameters of the structural analysis and optimization.The communication between programs prioritizes user-friendly interfaces so that the optimization process does not require intervention until a solution is found.
Herein, the optimal design of roof trusses for industrial sheds is presented as an application.Steel roof trusses present a wide range of possible designs, which may be determined by selecting the most appropriate structural profiles and geometric arrangements.Various geometric arrangements of the bars are often used, and these generally have angular or tubular cross sections.This level of variety implies that finding the best solution through trial and error becomes impractical.
Industrial buildings are formed by very slender bars connected by hinges and are susceptible to large nodal displacements.Therefore, a nonlinear geometric analysis provides a more realistic representation of their operating conditions.In these cases, FEA programs that have options for different types of structural analysis are needed.
Optimal design optimization of these structures presents three different approaches: topology optimization; shape or layout optimization; and size optimization, which seeks the ideal cross-sections of the members.The design optimization of roofs for industrial sheds is traditionally carried out using one type of optimization, either size and shape or topology.However, when considering the size and layout variables simultaneously, the influence of coupling these two types of variables arises, which, if properly explored, can provide more efficient structures, consequently allowing a more significant reduction in cost than the exclusive consideration of size optimization.In the present study, the profile bars and the structural layout are modified simultaneously using discrete and continuous design variables, aiming to determine the minimum structural weight that meets standardized criteria for ultimate and serviceability limit states.
Several optimization algorithms are currently available, among which genetic algorithms are the most prominent.A genetic algorithm (GA) searches for optimal solutions to a variety of engineering problems using the principles of selection and evolution of species.
There are several studies focused on determining the minimum mass of steel truss roofs in which designs are subjected to stress and displacement constraints, such as Koumousis et al. (1994), Croce et al. (2004), Oliveira & Falcón (2013), Tarabay & Lima (2022); these studies used diverse design variables, including topological variables, such as the number of truss frames and the number of bars; geometric variables, such as nodal coordinates; and dimensional variables related to the cross-section of the bars.Cazacu & Grama (2014) optimized the topology, geometry, and dimensions of plane trusses using genetic algorithms and finite element analysis implemented in MATLAB, the objective was to minimize the mass of the structure while respecting maximum limits of stress and displacements.Kaur et al. (2016) studied the influence of the variation of geometric arrangements in the design of roof trusses, using steel profiles with angle sections; the authors studied the effects of different spacing, span, and pitches, to determine the most financially efficient truss.Kaveh & Zaerreza (2020) used a multicommunity metaheuristic optimization algorithm, named shuffled shepherd optimization algorithm (SSOA), for size and layout optimization of truss structures, the SSOA was inspired by mimicking the herding behavior of shepherds and Varma et al. (2020) presented an integrated strategy for sizing and shape optimization of truss structures, considering buckling restrictions implicitly into truss design.
A small number of studies using MATLAB and ANSYS platforms in an interactive way are found in academic literature.Some authors, such as Gauchía et al. (2014) developed programs for the advanced analysis of vehicle structures and Sztendel et al. (2012) simulated complex interactions between mechanical elements using ANSYS and MATLAB/Simulink.In Brazil, Lopes et al. (2017) used ANSYS and MATLAB programs to optimize a reinforced concrete foundation, designed to support a high-capacity motor-driven compressor.In these studies, it is observed that there are diverse manners of communication between MATLAB and ANSYS platforms.Bekdas et al. (2021) observed that the FEA tools are consolidated and that, currently, the attention of the studies is directed to the development of more efficient optimization methodologies.
Regarding steel shed optimization, few studies were found that are concerned with the optimal geometry of steel truss roofs, which consider the use of commercial structural profiles as design variables and that consider the requirements of Brazilian standards as design constraints.
In this context, this study presents a computational framework for structural optimization based on the integration of MATLAB and ANSYS computational platforms, working interactively and in a fully automated fashion.The first has several optimization algorithms and the second provides reliable and robust tools for determining mechanical structural responses.
The automated coupling between these platforms is performed via computational codes using neutral files.The

Introduction
The first design constraint, presented in Equation (3), considers failure due to material yielding or instability of the bars.Thus, σ adm, i = min( f y,i , σ cr-b, i ), where f y,i is the yield stress of the i-th bar steel and σ cr-b, i is the critical buckling stress; The present article considers three types of inequality design constraints:  & Herskovits (1991). (5) In the present study, the design variables are the commercially available profiles and the coordinates of some nodal points of the structure.
Thus, this modeling uses discrete variables (commercial profiles) along with continuous variables (nodal coordinates).W hen considering size and layout variables simultaneously, results are more versatile due to the different behaviors of the design variables.

Modeling the optimal design problem
The optimization problem consists of finding the values of the design variables, X, limited by lower (lb) and upper (ub) bounds, which minimize the objective function, f(X), and simultaneously satisfy the design constraints of inequality and equality, g(X) and h(X), respectively.Thus, the optimization problem is given by: For each new problem to be studied, the data file "truss_APDL.txt"concerning the structure details must be written in ANSYS/APDL format.The optimization process starts in a MATLAB platform, by randomly generating an initial population.From this point, analyses are required to assess the fitness of individuals.ANSYS/APDL runs in background mode and mechanical responses are calculated.Subsequentially, every individual has its fitness value quantified, and, according to the fitness values, reproduction operators are applied to define a new population with better characteristics than the previous one.The new individuals are obtained from the old generation by using the GA operatorselitism, selection, crossover, and mutation.This procedure is repeated iteratively with the expectation that the best and average fitness values of the population should improve along with the iterations and, therefore, provide the best solution for the problem (Hortencio et al., 2018).
In the present study, the fitness value is calculated considering the total mass of the individual and quantifying how active the design constraints are.In this way, along an iterative process, the population is improved, evolving towards an optimal solution.
Figure 3 shows some details of the MATLAB-ANSYS computational interfaces, and the data flow developed in this study.In the iterative optimization process, verification of the fitness of individuals is based on calculations of the objective function and design constraints performed by the GA.Thus, the following steps are carried out:  The computational methodology developed here considers the interaction of two different computational modules: optimization and structural analysis, which communicate through computational interfaces.The optimization module and computational interfaces were developed in MATLAB, while structural analyses were performed with ANSYS Mechanical APDL. Figure 2 shows the general optimization scheme developed in this study.

Computational methodology
For the second design constraint, Equation (4), λ i and λ adm are the slenderness ratio of the i-th bar and its slenderness ratio limit.In general, the limits for these values are determined by local standards.According to ABNT NBR 8800: 2008, the slenderness ratio of compressed and tensioned bars must not exceed 200 and 300, respectively.
In the third design constraint, Equation ( 5), Δ i and Δ adm are the displacement of the i-th node and its allowable displacement, respectively; and N desl is the number of critical displacements considered. (6) σ i and σ adm, i are the normal and allowable stresses on the i-th bar; N el is the total number of bars in the structure.The critical buckling load is determined with Equation ( 6), where λ i is the slenderness ratio of the i-th bar.The objective of this study is to obtain structures with minimal cost, considering commercial profiles, design restrictions based on Brazilian structural norms and the use of FEA programs with different types of structural analysis.To illustrate the applica-tion of the computational framework developed here, the optimal design of an 18-bar truss and a roof truss for an industrial shed are presented; the first is a classic problem in literature and the second is a large structure with nonlinear geometric behavior.The GA was configured considering 50 individuals in the population, a crossover rate of 85%, elitism rate of 5%, and mutation rate of 0.01.This neutral file contains the values of design variables for every individual of the population.This file is updated iteratively using "table" and "writetable" MATLAB commands.Ex.: x1 = 0.75; x2 = 0.23, etc.

"Truss_APDL.txt"
This neutral file contains commands compatible with ANSYS/APDL language for pre-processing, solution, and post-processing stages.In it, the following parameters are defined: geometric and physical properties of the structure; loads; boundary conditions (supports); type of analysis and required results.Example: In this example, for everyone in the population, the structural parameters x1, x2, etc. are updated according to the corresponding design variable values x(1), x(2), etc. contained in the "Design_variables.txt"file.

"Results_ANSYS.txt"
This neutral file contains stresses and nodal displacements on the bars obtained from the structural analysis performed with ANSYS.Tables 1 and 2 show the files and functions developed as computational interfaces between MATLAB and ANSYS platforms.

Applications
• Every time the GA defines a new vector of design variables, the files "Design_variables.txt" and "truss_APDL.txt"are updated, using "table" and "writetable" MATLAB commands, and the APDL command INPUT.
• The structural analysis is performed in ANSYS (executing APDL com-mands listed in the "truss_APDL.txt"file).ANSYS is invoked from the MATLAB platform using the command "dos".
• The mechanical results (stresses in the bars and nodal displacements) are saved in the file "Analysis_ANSYS.txt"and these results are sent back to MATLAB via the computational interface "Results_ANSYS.m".Thus, generating all data necessary to calculate the fitness of individuals.
• Iteratively, individuals are evaluated using genetic operators and a new population is generated.This process is repeated several times until convergence criteria are met.
in Figure 4.The design variables are the cross-sectional areas and the coordinates of the nodes on the lower chords.Exter-nal forces of 88.96 kN (20,000 lb) were applied to the fixed upper chord nodes.Truss geometry was optimized consider-ing nodes 3, 5, 7, and 9 free to move, while nodes 1, 2, 4, 6, and 8 were considered geometrically fixed.Figure 7 -Geometry and numbering of roof truss bars.
This study resembles the procedure followed by Moura et al. (2010).Thus, the first two mechanical design constraints, Equations ( 3) and ( 4), were applied in all bars and the third design constraint, Equation ( 5), was applied in node 1, expected to present the largest displacement in the truss.The allowable stress for all members was set at 13.85 kN/cm 2 and allowable displacement on nodes at 53.14 cm.For modulus of elasticity and specific gravity were considered 6894.76kN/cm 2 and 2.72 10 -5 kN/cm 3 , respectively.
Size optimization was performed by dividing the bars into four groups sharing the same structural profile, taken as discrete design variables.For layout optimization, nodes 11, 9, 7, 5, and 3 must maintain collinearity, internal nodes (9, 7, and 5) move in local coordinates, and extreme nodes (11 and 3) move in global coordinates.Thus, the vector of design variables was X=[ A 1 ; A 2 ; A 3 ; A 4 ; X 3 ; Y 3 ; t 9 ; t 7 ; t 5 ].For layout optimization problems, in which some nodal coordinates are considered as design variables, it is extremely important to consider the slenderness ratios of the elements.NBR8800 indicates the slenderness limit of the elements, as previously mentioned.
Industrial roof truss optimization -The optimal design of the geometry and dimensions of a 20 m x 150 m industrial roof support was carried out using commercial structural profiles.This shed was studied by Croce et al. (2014), and it is composed of 22 plane truss frames, as shown in Figure 6.The bars are composed of double-angle rolled profiles with equal legs.The database with 49 structural profiles available in Table C-11 of Bellei ( 2010) was adopted for this study, thus making this a real case of steel roof design.The geometry and numbering of the bars and nodes are shown in Figure 7.The symmetry of the initial geometry was preserved.
The design variables are the crosssectional areas and the coordinates of the nodes on the upper chords.Truss geometry was optimized considering nodes 1 to 9 free to move, while nodes 10 to 18 were considered as geometrically fixed.For layout optimization, nodes 1 to 5 must maintain collinearity, internal nodes (2, 3, and 4) move in local coordinates, and extreme nodes (1 and 5) move only in the vertical global coordinate (Y axis).Thus, the vector of design variables was X=[ P 1 ; P 2 ; P 3 ; Y 1 ; Y 5 ; t 2 ; t 3 ; t 4 ].
To calculate the mechanical response of the structure, only the plane truss frame of the shed subjected to the largest load was considered.Based on the tributary area between consecutive frames of the shed, a linear load of 10.5 kN/m along the truss frame was considered.The structural analysis was performed considering geometric nonlinearity.
The three proposed design constraints, Equations ( 3), (4), and (5), were applied for the optimization of the truss.The design constraints follow the prescriptions of ABNT NBR 8800: 2008 for Ultimate and Serviceability Limit States.Thus, stresses and slenderness ratios are assessed for all bars, along with the displacement of node 14, expected to exhibit the largest displacement on the truss.Stresses were calculated by performing a geometrically nonlinear analysis.The following admissible values were considered: Yield strength of steel f y = 250MPa; critical buckling stress σ cr-b given by Equation ( 6) and admissible displacement Δ adm = 5cm.Also, modulus of elasticity E = 200 GPa and specific mass ρ = 7850 kg/m 3 .These applications aim to validate the computational framework developed in this research.The results obtained are compared with solutions available in literature.
18-bar truss -Figure 5 shows the optimal geometry and the optimization history for this problem.Note that the convergence is monotonic, and the optimal solution was found in the 69th generation .Table 3 presents the groups of bars and corresponding lower bound X min , upper bound X max and the optimal solution obtained X opt .In the optimized design, stress constraints of bars 4, 5, 10 and 18 reached the allowable value (13.85 kN/cm 2 ) and node 1 reached the allowable displacement -being active constraints.The minimum weight obtained was 16.64 kN; Moura et al. (2010) obtained results between 15.12 to 17.87 kN, using different optimization algorithms.The results presented here are consistent with the results of the cited reference.Thus, confirming the validity of the proposed computational methodology.
In Table 3, design variables 1 to 4 are in cm 2 , 5 and 6 in cm, and 7 to 9 in percentage of their respective principal bar.
Industrial roof truss -The optimization history is shown in Figure 8.The convergence exhibits monotonic behavior, and the optimal solution was found in the 68 th generation.Table 4 shows the vector of design variables X=[ P 1 ; P 2 ; P 3 ; X 1 ; X 5 ; t 2 ; t 3 ; t 4 ] and their corresponding lower and upper limits X min and X max , respectively.The discrete design variables were the structural profile of each group of bars 1, 2 and 3 -P 1 , P 2 and P 3 , respectively; and the continuous design variables were taken as the lateral and central height of the truss (coordinates Y 1 and Y 5 ), as well as the local coordinates of nodes 2, 3 and 4 (t 2 , t 3 , t 4 , respectively).When the coordinates of nodes are altered, the structure behaves differently, since the loading and bar stiffness change.The proposed framework, then, recalculates the value of the loads in each bar, and consequently, recalculates the optimal area of each bar.

Numerical results
A computational framework for the design optimization of steel structures was presented that uses two important commercially available platforms, MATLAB and ANSYS, working interactively and automatically.Application of the proposed methodology to both an academic problem and an industrial shed problem provided results like those found in literature.
The weight minimization of a roof truss was presented as an application test.Continuous and discrete variables were used for modeling the optimization problem, associated with global and local nodal coordinates and structural steel profiles, which in turn attributed to geometric and dimensional optimization, respectively.
Structural analyses performed with ANSYS were efficient and reliable.Results from the validation example were compatible with those from the literature.It is worth highlighting that any other FEA software may be coupled with MATLAB.
In this stage of the study, the focus was the development of computational codes referring to the computational interfaces necessary for interaction between MATLAB and ANSYS, in the next stages of this study, better adjustments regarding the modeling of the optimization problem will be performed.This computational methodology can be applied to plane and spatial structures, using diverse structural models while generating robust and efficient solutions.The methodology has also been tested on several other problems, attesting to the versatility of the computational framework presented.In Table 4, the number in parentheses indicates the position of the commercial profile in the adopted database.Thus, the minimum weight obtained was 119.84 kN; Croce et al. (2004) obtained 117.64 kN, but this reference did not use commercial profiles, and did not consider the slenderness ratio constraints on bars.The authors did not find in the literature other studies that consider the geometric and dimensional optimization of industrial sheds.
In both problems presented herein, all design variables were above the lower limit, which implies that the optimal solution was defined by mechanical restrictions (stresses and displacements), in turn indicating a final design featuring good mechanical efficiency.
Regarding the computational per-formance of the developed computing framework, the computational cost using GA was strongly dependent on adopted population size, for the 18-bar truss, it was 126 sec and for the industrial roof truss, it was 175 sec.It was observed that even with the ANSYS platform in background mode -without an active graphical interface -the computational cost was above that of programs on a single platform.
-This problem was studied by Moura et al. (2010), among others.The geometry and loads are shown

Figure 5 -
Figure 5 -Optimal geometry and optimization history.
Table 4 presents the optimal steel profiles indicated by the program.

Table 3 -
Design variables -lower and upper bounds and optimal values.

Table 4 -
Design variables in optimal configuration.