**7. Search of Optimal Control by Direct Method**

The same problem was solved by direct numerical method. Control for each robot was searched as a piece-wise liner function on interval as follows

$$u\_i^j = \begin{cases} u\_i^+ \text{, if } u\_i^+ \le u\_i^j\\ u\_i^- \text{, if } \bar{u}\_i^l \le u\_i^- \\\ \bar{u}\_{i'}^l \text{ otherwise} \end{cases} \tag{56}$$

where

$$
\dot{u}\_1^1 = q\_i + (q\_{i+1} - q\_i) \frac{(t - i\Delta t)}{\Delta t},
\tag{57}
$$

$$\|q\|\_2^1 = q\_{i+K} + (q\_{i+K+1} - q\_{i+K}) \frac{(t - i\Delta t)}{\Delta t},\tag{58}$$

$$
\mu\_1^2 = q\_{i+2K} + (q\_{i+2K+1} - q\_{i+2K}) \frac{(t - i\Delta t)}{\Delta t},\tag{59}
$$

$$
\mu\_2^2 = q\_{i+3K} + (q\_{i+3K+1} - q\_{i+3K}) \frac{(t - i\Delta t)}{\Delta t},\tag{60}
$$

*i* = 1, . . . , *K*, *t* ∈ [*i*Δ*t*;(*i* + 1)Δ*t*), Δ*t* = 0.25,

$$K = \left\lfloor \frac{t^+}{\Delta t} \right\rfloor + 1 = \left\lfloor \frac{2.5}{0.25} \right\rfloor + 1 = 11,\tag{61}$$

Eleven time intervals were used. For each control, it was necessary to find 11 parameters of piece-wise linear function at the boundaries of intervals. Totally, we searched for forty-five parameters **q** = [*q*<sup>1</sup> ... *q*45] *<sup>T</sup>*, forty-four parameters were for control of two robots, and *q*<sup>45</sup> was for terminal time *t* <sup>+</sup> + *q*45. Values of parameters were constrained

$$q\_i^- \lessapprox q\_i \lessapprox q\_i^+, \ i = 1, \ldots, 45,\tag{62}$$

where *q*− *<sup>i</sup>* <sup>=</sup> <sup>−</sup>20, *<sup>q</sup>*<sup>+</sup> *<sup>i</sup>* = 20, *i* = 1, . . . , 44, *q*<sup>−</sup> <sup>45</sup> <sup>=</sup> <sup>−</sup>0.8, *<sup>q</sup>*<sup>+</sup> <sup>45</sup> = 0.8.

The parameter search was also performed by modified SOMA. Vector of obtained parameters was as follows

**q** = [15.0129 17.4687 17.6772 2.2532 12.5488 9.0041 0.3886 19.9999 19.3899 19.01849 −8.8472 − 15.2669 10.5164 19.9044 16.5724 18.0328 17.5597 18.3563 16.8607 8, 2100 −18.7127 4.3724 − 8.9377 − 0.7936 10.6309 18.9660 18.4597 18.9742 17.2781 14.6362 18.4152 − 13.7367 − 2.8521 17.0837 18.1753 17.5278 9.4618 19.5178 17.6007 11.3479 −0.6898 − 5.4015 19.9215 9.6850 0.6628] *T*.

For direct approach, when we searched for 45 parameters by modified SOMA, the complexity of the algorithm was the following: *H* = 32, *P* = 1024, *R* = *H*, *Plength* = 8, *step* = 0.22, *n* = 8/0.22 = 36, *H* + *nRP* = 32 + 36 × 32 × 1024 =1,179,680. Simulation was performed on PC with Intel Core i7, 2.8 GHz. A series of 10 runs was implemented. The CPU time for 10 runs was approx. 3 hours and 10 min, i.e., 1 run was approx. 19 min. We used *P* = 1024 for direct approach, because the number of searched parameters was 45, and it was several times bigger than 11 parameters in the first experiment.

The obtained solution is presented on Figure 6. On Figures 7–10, the plots of direct controls are presented.

**Figure 6.** Trajectories of robots obtained by direct method.

#### **8. An Alternative Non-Deterministic Control**

One of the most important issues for swarm robotics applications is catching up with moving targets and avoiding multiple dynamic obstacles. It is complicated in that it requires an algorithm to work in real time to avoid obstacles that are standing or moving in an unknown environment, where the robot does not know their position until detecting them by sensors arranged on the robot. As an alternative to the method presented above, the use of swarm intelligence algorithms as reported in [9] can be discussed. The paper [9] presents a method for swarm robot to catch the moving target and to avoid multiple dynamic obstacles in the unknown environment. An imaginary map is built, representing *N* targets, *M* obstacles and *N* robots and a swarm intelligence algorithm is used to control them so that targets are captured correctly and in the shortest time. The robot dynamics can be viewed as a flow of water moving from high to low. The flow of water is the robot trajectory that is divided into a set of points created by an algorithm called SOMA [5,6]. Simulation results are also presented to show that the obstacle avoidance and catching target task can be reached using this method. All details about those experiments are discussed in [9]. Results are also visualized in selected videos (https://zelinkaivan65.wixsite.com/ivanzelinka/videa). The typical example is in Figure 11.

**Figure 11.** Swarm robot control by SOMA.

Besides the long-standing methods such as potential field method [10,11], and the vector field histogram [12], several new methods such as "follow the gap method" [13], and barrier function [14], or artificial intelligence methods such as genetic algorithm [15], neural network [16], and fuzzy logic [17,18] also demonstrate their effectiveness. Among the methods of artificial intelligence used to solve the problem as a function optimization problem, the self-organizing migrating algorithm (SOMA) emerges as a fast, powerful and efficient algorithm [5,6].

#### **9. Discussion**

The optimal control problem for two mobile robots with phase constraints was considered. To solve the problem, an approach based on the Pontryagin maximum principle was used. The mathematical model of robots include linear control in the right parts of differential equations; that is why the optimal control has sectors of special control modes. It should be noted that we used two robots to test the proposed technology and partially to test methodology. A larger group is required to fully test the proposed methodology and it will be our future research, but in the case of many robots, the optimization problem will go on backstage and the collision avoidance will become the real problem.

To solve a boundary-value problem and search of initial conditions of conjugate variables, the modified SOMA was used. Additional parameters for terminal conditions check and control in special modes were introduced.

The optimal control problem was also solved by direct approach. Control time was divided into intervals, and control at each interval was a piece-wise linear function. Additional parameter was also a time of terminal conditions check. The direct approach showed another character of objects movement.

The aim of this paper was to show for the first time how modern evolutionary algorithms can be applied to solution of boundary-value problems that occur when we solve the optimal control problem by an indirect method based on the Pontryagin maximum principle. Other known applications of evolutionary algorithms were mainly with direct approach [4].

Thus, one can conclude that the considered problem is multimodal and application of evolutionary algorithms to both direct and indirect approaches is expedient and prospective. The next research will be focused on an extensive comparative study of classical and swarm control based methods.
