Intelligent Search of Values for a Controller Using the Artificial Bee Colony Algorithm to Control the Velocity of Displacement of a Robot

The optimization is essential in the engineering area and, in conjunction with use of metaheuristics, has had a great impact in recent years; this is because of its great precision in search of optimal parameters for the solution of problems. In this work, the use of the Artificial Bee Colony Algorithm (ABC) is presented to optimize the values for the variables of a proportional integral controller (PI) to observe the behavior of the controller with the optimized Ti and Kp values. It is proposed using a robot built using the MINDSTORMS version EV3 kit. The objective of this work is to demonstrate the improvement and efficiency of the controllers in conjunction with optimization meta-heuristics. In the results section, we observe that the results improve considerably compared to traditional methods. In this work, the main contribution is the implementation of an optimization algorithm (ABC) applied to a controller (PI), and the results are tested to control the movement of a robot. There are many papers where the kit is used in various domains such as education as well as research for science and technology tasks and some real-world problems by engineering scholars, showing the acceptable result.


Introduction
Today is the digitalization era, with robotics, artificial intelligence, IoT (Internet of Things) and automation. Since ancient times, the human being has sought to automate all its activities, avoiding the effort and intervention of the human hand. In recent years, the combination of different intelligent techniques helps different areas of science to improve and optimize time, performance, accuracy, and computational cost when solving any problems [1]. In this paper, an innovative proposal is presented where a combination of meta-heuristics and control are used for the intelligent search of values of the variables K p and T i and applied in a LEGO EV3 robot. K p represents the proportional gain and refers to the constant of proportionality in the action to proportional control. If the value of K p is small, the proportional action is small, but if K p is high, the proportional action is high. The variable T i refers to the time required for the integral action to contribute to the controller output. If T i is small, the integral action is high, but if T i is high, the integral action is small.
Today actually is the era of robotics, where, in conjunction with artificial intelligence, humanity has managed to achieve significant advances in some areas, for example: home robots, academics, medicine, agriculture, combat robots, scout robots in other planets (example: Mars exploration rover), and intelligence implemented in other entities such as autonomous land and aerial vehicles and virtual assistants [2], for mention of some areas. It is important to mention the new term that emerged recently: machine learning (ML). ML is the science of getting machines to learn and act like humans, and improve their learning over time autonomously, by feeding them data and information in the form of observations and real-world interactions [3].
Each of the entities mentioned above integrate some of the following: neural networks for learning in conjunction with other sciences for the collection and processing of information, audio and image, and some type of controller to coordinate and activate some actuators of the robot such as: arms, legs, engines, and others. There are several types of controllers that are used for the control of some system such as: proportional integral derivative control (PID) [4], fuzzy logic control (FLC) [5], and its extension, type 2 fuzzy logic control [6].
In this case, a proportional integral controller (PI) is used, where the values for the constants are adjusted in execution time using a bio-inspired algorithm in the behavior of bees in nature in the process of searching and collecting the nectar.
The objective of this work is to demonstrate that bio-inspired algorithms can significantly improve the results in solving optimization problems. It is important to mention that, in the literature, there are many published works with implementations of the ABC algorithm in control problems, for example: PID, type 1 and type 2 fuzzy logical control, and approximation of mathematical functions. However, a few studies have found that this algorithm can be used to optimize the parameters of a PI and observe the behavior. There are many bio-inspired algorithms in the literature, each with different characteristics. The selection of the algorithm for this proposal was determined after analyzing its characteristics and based on [7][8][9].

Related Work
There are multiple publications in the literature of different bio-inspired meta-heuristics in the behavior of the bees in the nature; for example, in [10], the authors present their proposal of a new powerful meta-heuristic for the resolution of complex problems, and years later, authors of [11,12] present a modification of the ABC algorithm for unrestricted searches. Other authors also present some variants similar to this meta-heuristic mentioned above (e.g., [7,[13][14][15]).
During the last several years, multiple variants of the algorithm proposed in this work have been developed. It is important to mention that each variant was developed to solve a specific problem: optimization of neural networks, optimization of fuzzy logic controllers type 1 and type 2, and optimization of mathematical functions, to mention some. The authors of this proposal consider that is important to mention in this paper.
The original version of the ABC algorithm proposed by [10] to dynamically adjust the values of the constants of a controller (PI) is used in this paper. There are also published works by other authors where they use different controllers applied to the LEGO MIND-STORMS EV3 kit, such as: proportional integral derivative controllers (PID) [16,17], fuzzy logic controllers (FLC) [18], fuzzy logic proposed by Zadeh [5], and proportional integral controllers (PI) [19].
It is also necessary to show the reader of this manuscript some works related to our proposal. For example, in [20], "Real-Time PID Control of Wireless Two-Wheeled Balancing LEGO EV3 Robot", a two-wheeled balancing LEGO EV3 robot is modeled in a state space and controlled by a PID controller, which we find very interesting. In [21], the authors present an application for mobile devices to operate and read the status of motors and controller of the LEGO robot and affirm that this app can operate with different sizes of motors. In [22], the authors use a LEGO robot NXT version with infrared sensor to follow a trajectory with reference to a line and use a control (PID) to control the motors. Furthermore, the use of fuzzy logic is present in the LEGO kits, for example.
In [23,24], a fuzzy logic controller is used as a controller to stabilize the two-wheeled EV3 LEGO robot. In recent years, fuzzy controllers in combination with meta-heuristics have had a great impact in different areas [24]. EV3 MINDSTORMS LEGO characteristics: The brick or block EV3 is the unit of control and electrical feeding of motors and sensors of the robot. It connects to the computer (via USB, Bluetooth, or Wi-Fi) to receive and execute the control programs, and it is the successor of LEGO MINDSTORMS NXT 2.0. The LEGO EV3 kit is the third generation of the LEGO robotics line and recommended for teaching and learning school robotics. It has a 300 MHz ARM9 processor, 16 MB of flash memory, 64 MB of RAM, and a Linux operating system, with an open-source license. The EV3 was implemented to test the optimized PI model with the ABC algorithm and observe the displacement behavior.
However, some researchers have used it for scientific purposes to test their models and observe behavior in different areas and types of problems [25,26].
Proportional integral controller (PI): There are two types of forms in a control algorithm to decide on an action. The open loop system and the parameters of the algorithm are pre-set and do not change. While the system is running, the closed loop system sensors measure the error between the desired state of the system and its real state, and this error is used to decide what action to take. To achieve speed control in a EV3 LEGO MINDSTORM, open circuit control systems were used. Figure 1 shows the general scheme of a loop control system [19,26], where the values of the constants K p and T i are calibrated at runtime using the ABC algorithm. In [23,24], a fuzzy logic controller is used as a controller to stabilize the two-wheeled EV3 LEGO robot. In recent years, fuzzy controllers in combination with meta-heuristics have had a great impact in different areas [24].
EV3 MINDSTORMS LEGO characteristics: The brick or block EV3 is the unit of control and electrical feeding of motors and sensors of the robot. It connects to the computer (via USB, Bluetooth, or Wi-Fi) to receive and execute the control programs, and it is the successor of LEGO MINDSTORMS NXT 2.0. The LEGO EV3 kit is the third generation of the LEGO robotics line and recommended for teaching and learning school robotics. It has a 300 MHz ARM9 processor, 16 MB of flash memory, 64 MB of RAM, and a Linux operating system, with an open-source license. The EV3 was implemented to test the optimized PI model with the ABC algorithm and observe the displacement behavior.
However, some researchers have used it for scientific purposes to test their models and observe behavior in different areas and types of problems [25,26].
Proportional integral controller (PI): There are two types of forms in a control algorithm to decide on an action. The open loop system and the parameters of the algorithm are pre-set and do not change. While the system is running, the closed loop system sensors measure the error between the desired state of the system and its real state, and this error is used to decide what action to take. To achieve speed control in a EV3 LEGO MIND-STORM, open circuit control systems were used. Figure 1 shows the general scheme of a loop control system [19,26], where the values of the constants and are calibrated at runtime using the ABC algorithm. The parameter SP represents the reference value; the variable transformed into a control value is represented by MV; and the parameter PV represents the output, which is calculated with the equation e = SP − PV.
Artificial Bee Colony Algorithm (ABC): The algorithm of artificial bee colony is a meta-heuristic inspired by the behavior of bees in nature and was created by Dervis Karaboga in 2005 [10]. The algorithm (ABC) uses the principle of collective intelligence where the individuals (bees) collaborate with each other to achieve an objective. After the proposal made by Dervis Karaboga in 2015, many variants and improvements have been developed in this work, the original version is used. This algorithm has very interesting characteristics. Bees are classified into three roles according to their fitness value. For example: 1. Initialization Phase: All the vectors of the population of food sources, ( )'s, are initialized ( = 1, … : population size) by scout bees, and control parameters are set.
Since each food source, ( ), is a solution vector to the optimization problem, each ( ) vector holds variables, ( , = 1 … ), which are to be optimized so as to minimize the objective function.
The following definition might be used for initialization purposes: The parameter SP represents the reference value; the variable transformed into a control value is represented by MV; and the parameter PV represents the output, which is calculated with the equation e = SP − PV.
Artificial Bee Colony Algorithm (ABC): The algorithm of artificial bee colony is a metaheuristic inspired by the behavior of bees in nature and was created by Dervis Karaboga in 2005 [10]. The algorithm (ABC) uses the principle of collective intelligence where the individuals (bees) collaborate with each other to achieve an objective. After the proposal made by Dervis Karaboga in 2015, many variants and improvements have been developed in this work, the original version is used. This algorithm has very interesting characteristics. Bees are classified into three roles according to their fitness value. For example:

1.
Initialization Phase: All the vectors of the population of food sources, (x m )'s, are initialized (m = 1, . . . SN : population size) by scout bees, and control parameters are set. Since each food source, (x m ), is a solution vector to the optimization problem, each (x m ) vector holds n variables, (x mi , i = 1 . . . n), which are to be optimized so as to minimize the objective function.
The following definition might be used for initialization purposes: where l i and u i represent the lower and upper bound of the parameter x mi , respectively. 2. Employed Bees Phase: New food origins are being searched (v m ); the one that has more nectar in the food neighborhood (x m ) is put in memory. Once the food origin neighbors are found, then rentability (aptitude) is evaluated. For example, a food origin can be determined by using the formula of the following Equation (1) [27].
where x k is a randomly selected food source, i is a randomly chosen parameter index, and φ mi is a random number within the range [−a, a]. After producing the new food source v m , its fitness is calculated, and a greedy selection is applied between v m and x m. The fitness value of the solution, f it m (x m ), might be calculated for minimization problems using the following Equation (2) [27].
where f m (x m ) represent the objective function value for solution x m .

3.
Onlooker Bees Phase: In this optimization algorithm, an observer bee chooses a food source based on the calculated fitness value with Equation (2). Data from food sources are provided by the bees employed. The roulette method is used for selection [28].
The probability value P m with which X m is chosen by an observer bee can be calculated using the expression given in the Equation (3) [27]: After choosing a food source x m for a spectator bee, a neighborhood source v m is determined using Equation (2), and the fitness value is calculated. As in the phase of bees used, a greedy selection between v m and x m is applied.

4.
Scout Bees Phase: The bees without jobs who choose their food origins randomly are called scout bees. Then the converted scouts begin to look for new random solutions. For example, if solution x m has been abandoned, the new solution discovered by the scout who was the used bee x m can be defined using Equation (4). Therefore, all food origins with a low fitness value are abandoned due to exploitation [27].
The population of food sources is generated by the exploratory bees. x m (m = 1 . . . , SN: population size) and the parameters of the algorithm are configured. In the solution vector for the optimization problem, each vector x m , represents each food source, x m , and contains n variables (x mi , i = 1 . . . n), which must be optimized to minimize the Objective Equation (4): where l i and u i represent the lower and upper bound of the parameter x mi , respectively. In summary, the ABC algorithm: 1.
Is inspired by the foraging behavior of honeybees; 2.
Is a global optimization algorithm; 3.
Can be also used for combinatorial optimization problems [22]; 5.
Uses only three control parameters (population size, maximum cycle number, and limit) that are to be pre-determined by the user; 7.
Is quite simple, flexible, and robust (some of the relevant publications expressing these merits of the ABC algorithm are [10,11]).

Proposed Approach
In this work, we present a dynamic adaptation of variables for a proportional integral controller using the algorithm of artificial bee colony modeling in a EV3 LEGO MIND-STORM robot. As mentioned above, the LEGO kit is used in multiple domains such as: research and education for science and technology tasks and some real-world problems by engineering scholars.
The main contribution is the use of a meta-heuristic to adjust the variables of a (PI) control in a runtime and, at the same time, to model it in a LEGO robot. This process is carried out in wireless mode using the language of MATLAB programming in conjunction with Simulink.
In Figure 2, a flow diagram is shown that represents the sequence of steps to follow to achieve an optimal communication between the algorithm, Simulink block diagram, and LEGO EV3 robot.
Algorithms 2021, 14, x FOR PEER REVIEW 5 of 13 7. Is quite simple, flexible, and robust (some of the relevant publications expressing these merits of the ABC algorithm are [10,11]).

Proposed Approach
In this work, we present a dynamic adaptation of variables for a proportional integral controller using the algorithm of artificial bee colony modeling in a EV3 LEGO MIND-STORM robot. As mentioned above, the LEGO kit is used in multiple domains such as: research and education for science and technology tasks and some real-world problems by engineering scholars.
The main contribution is the use of a meta-heuristic to adjust the variables of a (PI) control in a runtime and, at the same time, to model it in a LEGO robot. This process is carried out in wireless mode using the language of MATLAB programming in conjunction with Simulink.
In Figure 2, a flow diagram is shown that represents the sequence of steps to follow to achieve an optimal communication between the algorithm, Simulink block diagram, and LEGO EV3 robot. The algorithm consists of the following phases: The algorithm consists of the following phases: Step 1: the population of bees is initialized. Considering the search universe, this universe is defined by the problem to be solved; in this case, [−1, 9] is proposed, and the solutions generated so far are evaluated.
Step 2, 3, 4, 5: in these steps, each new solution is evaluated, and the best one found so far goes to the next iteration to be optimized.
The best solution is determined after simulating the path given by ABC in the robot, and its fitness value is calculated using the mean square error Equation (5).

Methodology
In Figure 2, we can see a general illustration of our proposal. For the development of the proposal, as mentioned above, the role of the meta-heuristic bee colony algorithm is to explore the search space in order to find the optimal values for the constants (K p , T i ) of the PI controller.
Each value found by the meta-heuristic is assigned to the variables of the controller and is modeled in the LEGO robot, and the fitness value is obtained for that model. The connection with the brick LEGO is performed by wireless mode using a block model in Simulink and a Wi-Fi router to obtain the values and calculate the error of the motors (see Figure 2).
Before starting with the dynamic adaptation of variables of the (PI controller), we decided to use a reference method to use it as a guide in this work, there are many open loop tuning methods for self-regulating process (reaches a steady-state value after a step change in the manipulated variable) that use a first-order plus dead time model of the process (FODT) [29][30][31]. The transfer function of a general first-order plus dead time model is where K = Gain Process θ D = Dead time τ = Time constant The graphical procedure for determining the model is based on Ziegler-Nichols, according to Kelvin T. Erickson in his book Programmable Logic Controllers [31]. The method consists of obtaining the features of the response in a step input of magnitude such as demonstrated by Figure 3. The response to this input is obtained experimentally. so far goes to the next iteration to be optimized.
The best solution is determined after simulating the path given by ABC and its fitness value is calculated using the mean square error Equation (5).

Methodology
In Figure 2, we can see a general illustration of our proposal. For the dev the proposal, as mentioned above, the role of the meta-heuristic bee colony to explore the search space in order to find the optimal values for the constan the PI controller.
Each value found by the meta-heuristic is assigned to the variables of t and is modeled in the LEGO robot, and the fitness value is obtained for tha connection with the brick LEGO is performed by wireless mode using a blo Simulink and a Wi-Fi router to obtain the values and calculate the error of the Figure 2).
Before starting with the dynamic adaptation of variables of the (PI co decided to use a reference method to use it as a guide in this work, there are loop tuning methods for self-regulating process (reaches a steady-state valu change in the manipulated variable) that use a first-order plus dead time m process (FODT) [29][30][31]. The transfer function of a general first-order plu model is The graphical procedure for determining the model is based on Zieglercording to Kelvin T. Erickson in his book Programmable Logic Controllers [31]. consists of obtaining the features of the response in a step input of magnit demonstrated by Figure 3. The response to this input is obtained experiment It is important to analyze the response obtained, since it must have an type of response has two parameters: the dead time and the time constan process reaches the steady state, the parameters could be determined by straight-line tangent to the inflection point of the response obtained, as show 4. It is important to analyze the response obtained, since it must have an S shape; this type of response has two parameters: the dead time θ D and the time constant τ. After the process reaches the steady state, the parameters could be determined by drawing a straight-line tangent to the inflection point of the response obtained, as shown in Figure 4.  The term 1 is the time at which the step change in the manipulated variable was imposed. 2 is the time at which the tangent drawn in the previous step intersects the time axis. To obtain the dead time, = 2 − 1 . The term 3 is the time at which the process variable response has made 63% of its total change. To obtain the time constant, = 3 − 2 .
The process gain is the change in the process variable divided by the change in the control variable; see Equation 6.
The values obtained are shown below: The first-order plus dead time model of the process (FODT) is presented in Equation  Table 1, we can see the tuning rule.  The term T 1 is the time at which the step change in the manipulated variable was imposed. T 2 is the time at which the tangent drawn in the previous step intersects the time axis. To obtain the dead time, The term T 3 is the time at which the process variable response has made 63% of its total change. To obtain the time constant, The process gain is the change in the process variable divided by the change in the control variable; see Equation (6).
The values obtained are shown below: The first-order plus dead time model of the process (FODT) is presented in Equation (7).
According to the Ziegler and Nichols open loop tuning method, values of K p , T i , and T d are established and calculated from the parameters θ D , τ, and K. In Table 1, we can see the tuning rule. The proposed controller for this test was PI, and the values obtained are shown below: The values for the variables of the PI were implemented in the Simulink model. In Figure 5, the three signals are shown: Yellow signal is the pulse input to the system (reference). The magenta and cyan signals are the responses of motor one and two. The type of input to the system was a pulse signal with an amplitude of 150 square. The values for the variables of the PI were implemented in the Simulink model. In Figure 5, the three signals are shown: Yellow signal is the pulse input to the system (reference). The magenta and cyan signals are the responses of motor one and two. The type of input to the system was a pulse signal with an amplitude of 150 square. The objective of this work is the implementation of a meta-heuristic to the automatic adjustment of the value of the variables of the PI. The method of Ziegler and Nichols is used to analyze the behavior of the block model and response of the LEGO robot EV3. Using Equation (5), an error of 16.6874 was obtained for this test.

Results Obtained from The Tests Performed
In this section the performance, stability and behavior of the robot is presented using the PI control with intelligent adjustment in the variables ( , ). Each experiment has 15 tests performed with the following configuration of parameters in the meta-heuristic ABC: population size = 20, iterations = 50, and search range [−1 9], using as a reference the results obtained with the Ziegler and Nichols method. The results obtained are shown in the Table 2. The objective of this work is the implementation of a meta-heuristic to the automatic adjustment of the value of the variables of the PI. The method of Ziegler and Nichols is used to analyze the behavior of the block model and response of the LEGO robot EV3. Using Equation (5), an error of 16.6874 was obtained for this test.

Results Obtained from The Tests Performed
In this section the performance, stability and behavior of the robot is presented using the PI control with intelligent adjustment in the variables (K p , T i ). Each experiment has 15 tests performed with the following configuration of parameters in the meta-heuristic ABC: population size = 20, iterations = 50, and search range [−1 9], using as a reference the results obtained with the Ziegler and Nichols method. The results obtained are shown in the Table 2. In Table 2, we can observe the results obtained from the tests performed on the robot. We consider it important to show the values found for the variables (K p , T i ) and the error obtained. The error was calculated using the equation of the root of the mean square error (RMSE); see Equation (8): where y re f represents the reference to follow, y data represents the data obtained from the motors of the robot, and N is the number of data. The behavior of the robot motors when following the reference for tests 19, 1, and 3 is shown in Figures 6-8. Observing the fitness value obtained, we determined that they are the best results obtained from the tests carried out with the robot and the meta-heuristics; moreover, the values for the constants of the controller (PI) are shown.
The yellow signal is the pulse of input to the system (reference); the magenta and cyan signals are the responses of motor one and two. The type of input to the system was a pulse signal with an amplitude of 150 square.
For greater ease for the readers of this work, in Table 3, we can observe a comparison of the results obtained with the different approaches. It is important to mention that the error obtained with "Integral proportional control (PI), traditional" used the values defined by [29][30][31], and the error was 16.6874, which is high. When the optimization is used with values 7.5682 in K p and 0.2836 in T i , the error decreases considerably.     For greater ease for the readers of this work, in Table 3, we can observe a comparison of the results obtained with the different approaches. It is important to mention that the error obtained with "Integral proportional control (PI), traditional" used the values defined by [29][30][31], and the error was 16.6874, which is high. When the optimization is used with values 7.5682 in Kp and 0.2836 in Ti, the error decreases considerably. The values shown for Kp and Ti with "Intelligent integral proportional control" were found in a dynamic and intelligent way by the proposed algorithm (ABC), as we can see in the comparison: the error difference is very significant compared with that obtained using the traditional PI control. As mentioned in the introductory section, bio-inspired algorithms provide a great variety of solutions to different problems in engineering and other areas with a low computational cost.

Discussion
Throughout this work, we have presented a proof of concept of bio-inspired metaheuristics in the behavior of bees in nature applied to the dynamic adaptation of values to control the speed of movement of a robot. In this work, the Artificial Bees Colony (ABC) algorithm is proposed for the intelligent search of values Kp and Ti for Equation (5).
Based on the results obtained, we can conclude the feasibility of implementing bioinspired optimization algorithms for the intelligent search of values for complex search  The values shown for K p and T i with "Intelligent integral proportional control" were found in a dynamic and intelligent way by the proposed algorithm (ABC), as we can see in the comparison: the error difference is very significant compared with that obtained using the traditional PI control. As mentioned in the introductory section, bio-inspired algorithms provide a great variety of solutions to different problems in engineering and other areas with a low computational cost.

Discussion
Throughout this work, we have presented a proof of concept of bio-inspired metaheuristics in the behavior of bees in nature applied to the dynamic adaptation of values to control the speed of movement of a robot. In this work, the Artificial Bees Colony (ABC) algorithm is proposed for the intelligent search of values K p and T i for Equation (5).
Based on the results obtained, we can conclude the feasibility of implementing bioinspired optimization algorithms for the intelligent search of values for complex search and optimization problems. In this case, the ABC is used to control the speed of movement of a mobile robot. As we can see in Table 2, the results obtained were better achieved using the values proposed by Ziegler and Nichols [29]; see the results with values proposed by Ziegler and Nichols in Figure 6.
This work can be used as a basis to show readers the implementation of a bio-inspired algorithm to optimize the trajectory in an EV3 MINDSTORMS LEGO robot. It is important to mention that there are many application areas of algorithms such as: electronics, finance, construction, and telecommunications, to mention some. The applications are numerous and very varied due to their great adaptability and generate acceptable results with a low computational cost. As future work on the proposal, machine learning techniques can be implemented, which allows us to improve the models (ABC).

Conclusions
In this paper, a dynamic optimization of the parameters in the PI was performed. In the optimization, the search space was based on Ziegler and Nichols (see Table 1). As we mentioned, values were between −1 and 9. One of the objectives is to reduce the error of 16.6874 found with the Ziegler and Nichols method. After the experiments with the implementation in the robot, results show that bee colony optimization can obtain good parameters to the PI and improve it.
In many applications, a simple conventional PI is used to control the application, but we can use the best parameters for the PI, improving the controller even more, and obtain better results than using static values. In Table 2, important results were obtained and were better than Ziegler and Nichols. We were confident in a statistical comparison using Ziegler and Nichols, as the results obtained in this paper show. That is because the values of the K p and T i can change. The main objective was obtained, because the results were less than the reference.