This document describes using particle swarm optimization (PSO) and genetic algorithms (GA) to tune the parameters of a proportional-integral-derivative (PID) controller for an automatic voltage regulator (AVR) system. PSO and GA are used to minimize the objective function by adjusting the PID parameters to achieve optimal step response with minimal overshoot, settling time, and rise time. The results show that PSO provides high-quality solutions within a shorter calculation time than other stochastic methods.