## 4 Nature-Inspired Algorithms  
The optimizer is implemented as a comprehensive suite of native ANSYS macros [20] and is therefore fully embedded within the ANSYS APDL environment. This close integration means that no external executables or wrappers are required to drive the optimization loop; instead, all logic resides within ANSYS itself. Communication between the optimization routines and the finite-element solver is handled entirely via ANSYS parameter objects (for passing design variables, convergence thresholds, and constraints) and result objects (for retrieving objective function values and constraint data). In practice, this means that in each generation, the primary control script (the \"master macro\") sequentially invokes the following:  
(1) Parameter Initialization (file _parameters.mac_): Here, the number of design variables, their initial bounds, convergence criteria, and any user-defined constraints are established. Because this is coded as an ANSYS macro, these settings are loaded directly into the APDL parameter table, eliminating the need for separate data files or manual transfers.  
(2) Geometry and Mesh Generation (_geometry.mac_): Once the parameters are in place, the master macro calls geometry.mac. This routine constructs or updates the CAD/finite  
Figure 5: (**a**) Structure of the array of design variables; (**b**) dimensional variables of a generic bar in the truss structure.  
Figure 6: Optimal solution array structure.  
element model entirely within ANSYS. Any change in design variables, such as dimensional values, material property assignments, mesh controls, loads, or boundary conditions, propagates immediately to the model because geometry.mac interfaces directly with ANSYS's geometry kernel and meshing routines. After the geometric model is defined, the same _geometry.mac_ applies mesh controls, defines element type, assigns material properties, and establishes loads and boundary conditions. The ANSYS solver is then launched in the same session. Once the analysis completes, the resulting data (e.g., nodal displacements or stress distributions) are stored in ANSYS result objects.  
(3) Metaheuristic Algorithm (_FA.mac_, _GA.mac_, or _GSO.mac_): Depending on the chosen metaheuristic, the master macro transfers control to one of three algorithm-specific macros: FA.mac (for Firefly Algorithm), GA.mac (for Genetic Algorithm), and GSO.mac (for Group Search Optimization). Each of these macros follows a similar overarching procedure:  
* Fitness Evaluation: Using \"GET commands, the macro determines objective function values (total weight) and constraint metrics (such as maximum stress or displacement) directly from the result objects generated by the solver.
* Population/Agent Update: Based on the retrieved values, the macro applies the respective metaheuristic's update rules to generate new candidate designs (e.g., firefly movement equations in FA, crossover/mutation in GA, or member movement in GSO).
* Parameter Overwrite: The newly computed design variables are written back into the ANSYS parameter table, ready for the next call to geometry.mac.  
Because all of these routines are native ANSYS macros, each generation's new designs are fed back into the master routine without ever leaving the APDL environment. This coupling (geometry \(\rightarrow\) mesh/solver \(\rightarrow\) result extraction \(\rightarrow\) design update) continues iteratively until the convergence criteria defined in _parameters.mac_ are satisfied. The result is an in-memory optimization loop in which both the optimizer and the solver coexist in a single ANSYS session. In the following sections, \(t\) denotes the current iteration index, while \(N_{lim}\) refers to the maximum number of iterations allowed for each optimization run.