As industrial technology advances, there is an increasing need for very precise position control mechanisms for highly integrated and accurate products. Therefore, high precision positioning systems play an essential part in today's manufacturing processes. Piezoelectric actuators offer the requisite stiffness and positioning precision, but they have a limited traveling range. The combination of a linear motor with air bearings is a typical method for achieving long stroke movement at high speeds. However, to accomplish extensive and precise motion in several degrees of freedom with a linear motor and non-contact bearing, a sophisticated system setup is required. In this paper, a proportional-integral-derivative-proportional (PID-P) controller is presented for magnetic levitation system position control. Particle swarm optimization (PSO) and Black window optimization (BWO) algorithms are proposed for tuning the PID-P controller parameters. The PSO and BWO algorithms are employed by considering Integral Time Absolute Error (ITAE) as an objective function with rise-time and percentage peak overshoot as constraints. Furthermore, the performance of PSO and BWOA tuned PID-P controllers is compared to conventional PID-P and PID controllers using time response specifications such as rise time, settling time, and percentage peak overshoot. The graphical and numerical simulation results show that the PSO and BWOA tuned PID-P controller outperforms the conventional PID-P and PID controllers. The BWOA tuned PID-P controller outperformed the PSO tuned PID controller and the classical PID-P controller by 8.5 % in rise time, 46.77 % in settling time, and 86.6 % in percentage peak overshoot.