In this study, the nonlinear model of the longitudinal motion and altitude of a fixed-wing unmanned aerial vehicle with assured geometrical features and aerodynamic parameters is linearized under certain conditions. A cascade Proportional Integral Differential Controller is designed on the linear model. The controller coefficients that applied to the model of the UAV were optimized with an artificial intelligence technique, which is based on a metaheuristic search algorithm. The four different controller gains in the system are optimized using four different objective functions. Controller performances were tested in simulation environment for unit step input responses., Considering the longitudinal dynamics of the aircraft, among the ITAE, ISE, MSE, and IAE fitness functions, IAE can be shown as the optimum result for altitude control.