Optimal Power Flow (OPF) is a fundamental concept in the management and operation of modern electrical power systems, particularly within the context of smart grids. As the demand for electricity continues to grow and the energy landscape evolves towards greater sustainability, the need for efficient, reliable, and adaptive power systems has become more critical than ever. The primary objective of OPF is to determine the most efficient way to operate the power system while satisfying various technical and operational constraints. This involves the optimization of several variables, including generator outputs, voltage levels, and power flows, to minimize costs, reduce losses, and enhance system reliability. Smart grids can enhance their resilience to disturbances, support the efficient use of renewable energy, and provide reliable electricity to consumers.