The linear positioning of hydraulic cylinders is used in industrial applications, such as the positioning of flight fins on airplanes, injection molding processes, rock drilling, etc. One of the most used control techniques is the PID (Proportional Integral Derivative) control, the problem with this technique is the tuning of its three parameters. In this work, the experimental identification of the transfer function of the system to be controlled was first done, using the MATLAB toolbox ident. Then the PSO (Particle Swarm Optimization) algorithm was implemented in MATLAB codes. Like any optimization algorithm it requires a performance index or cost function, in this research ITAE (Integral Time Absolute Error) was used. The codes were tested with research papers found in the literature, polished until they were ready for any transfer function. These algorithms were then tested in the transfer function previously identified, achieving satisfactory results in the simulations. Finally, those values of the PID parameters found were tested in the linear positioning module of the Oleohydraulics and Pneumatics Laboratory at the Universidad Católica de Santa María. Also achieving satisfactory results in the performance of the controlled system: minimum establishment time, minimum rise time and minimum overshoot, which matched with the values obtained by data acquisition. Finally, the Ant Colony algorithm (ACO) was tested, looking for better results. The best results were obtained with the ant colony algorithm, for 20 ants, with 1000 nodes, and 100 tours. For the system with load the best solution was Kp = 11.01, Ki = 5.51 and Kd = 3.71. The results were improved by making a better experimental identification of the system. The solution was also improved by increasing the number of tours and the number of nodes, increasing the computational cost. With the controller implemented, the set-up time was reduced from 2.5 to 0.6 seconds without overshoot and with an error of less than 2 mm.