This article presents a fractional mathematical model of the human immunodeficiency virus (HIV)/AIDS spread with a fractional derivative of the Caputo type. The model includes five compartments corresponding to the variables describing the susceptible patients, HIV-infected patients, people with AIDS but not receiving antiretroviral treatment, patients being treated, and individuals who are immune to HIV infection by sexual contact. Moreover, it is assumed that the total population is constant. We construct an optimization technique supported by a class of basis functions, consisting of the generalized shifted Jacobi polynomials (GSJPs). The solution of the fractional HIV/AIDS epidemic model is approximated by means of GSJPs with coefficients and parameters in the matrix form. After calculating and combining the operational matrices with the Lagrange multipliers, we obtain the optimization method. The theorems on the existence, unique, and convergence results of the method are proved. Several illustrative examples show the performance of the proposed method. Mathematics Subject Classification: 97M60; 41A58; 92C42.