In the automatic system, the presence of an object with a delay that exceeds the value of the maximum time parameter of the controlled object reduces the operating quality of generic controllers (integral, proportionally-integral, proportionally-integral-differential). The occurrence of this kind of delay in the system requires addressing a particular class of regulators that compensate for the negative effects of the delay. This paper examines the PI controller known for its advantages with variable or switchable parameters, which belongs to the class of controllers with variable structure (henceforward — VSC) that do not use sliding mode. Due to the fact that the controller used contains switchable parameters and the object with delay is considered, it is extremely difficult to use analytical approaches to parametric optimization of the system. This lays one under a necessity to use algorithmic methods. This work employs a gradient-based algorithm in which the components of the gradient are calculated using sensitivity functions with their known advantages. The generated Automatic Parametric Optimization (APO) Algorithm calculated the optimal VSC parameters for a given object, based on the minimum of the integrated quadratic criterion. The reliability of the found vector of the controller setting, formed by the APO algorithm, is confirmed by the computational methodology. With accuracy sufficient for practice, the APO algorithm solved the problem of parametric optimization. The positive experience of optimizing the PI controllers with variable parameters allows one to apply it to other VSC, which do not use a sliding mode, and thus further expand the practice of using a gradient-based algorithm based on sensitivity functions for such a class of VSC under various laws of switching structures of the controller.