# JAYA Optimization Algorithm for Robot 2D/3D Path Planner in C++

--

In my previous articles, I displayed the performance of a number of metaheuristic algorithms inspired by nature. The output of these algorithms is highly related to the parameters set and often needs extensive tuning during the computational experiments to achieve the desired performance.

The Jaya algorithm is an optimization algorithm that R. Venkata Rao has proposed. The main advantage of the algorithm is the lack of tunable parameters, which have to be optimized during running experiments. During the algorithm run, we need to adjust the number of iterations (evolutions) and particles, taking into account while running the optimization.

The algorithm is straightforward to understand and deployed, which can be also considered a certain advantage. While looking for an optimal solution the algorithm converges the solution by searching the positions of the particles, which are closest to the best current solution and the farthest possible from the worst solution.

I used the JAYA algorithm for robot 2D and 3D path planners. Source code with implementations in C++ you will find on my **GitHub.**

Since the JAYA algorithm uses the idea of particles, we consider the particle as the position of the robot in 2D or 3D space. Of course, for 3D there is some sort of simplification since generally for manipulators we are looking solutions in joint space. On the other hand, we can apply a discuss 3D path planner for the drones.

# JAYA Optimization Algorithm

As I mention above the algorithm is very simple but very powerful. We need to implement only one updated position equation which optimizes the solutions while running the iteration process.

The position update can be expressed as follows,

where X is the position of the particle (robot) in 2D or 3D space.

Pseudo-code for the algorithm can be depicted as follows,

# The objective function of the robot path planner

The cost function that the algorithm is trying to optimize (compute minimum) can be defined as follows,

where,

distance firefly — obstacle,

- for 2D path planner

- for 3D path planner

distance firefly — goal,

- for 2D path planner

- for 3D path planner

K1 and K2 are coefficients taken from the article.

The optimal values of all constants depicted in the above formulas are taken from the article I refer to.

Performance of a discussed algorithm for different parameter setups. Please note it was not possible to plot in 3D the obstacle.

Plotting requires incorporating the header file which has to be in the same folder as your cpp (a file you can clone from my repository).

Your program can be compiled as follows,

`//compile`

g++ my_prog.cpp -o my_prog -I/usr/include/python3.8 -lpython3.8//

//run

./my_prog

//folder tree

├── my_prog

├── my_prog.cpp

├── matplotlibcpp.h

Thank you for reading.