# Social Group Optimization for Robot Path Planner in C++

Social Group Optimization (SGO) is a cutting-edge optimization method that emphasizes people’s capacity to solve problems in groups (Satapathy and Naik 2016).

In this method, a group of individuals is picked and each individual is strengthened with knowledge of various capacities, enabling the entire group to cooperate in performing a specific function. **The main concept is the learning (transfer of knowledge) amount the individual in the group.** **The algorithm is divided into two phases: the improving phase, and the acquiring phase, also known as the exploitation phase.**

I used this optimization method to solve the robot path planner problem for the simple 2D robot. There is one obstacle and the robot searches obstacle-free path between the start and the goal. The optimization method discussed here solves the minimization problem for the objective function (cost function) which I used in one of my previous articles.

The source code for this article in C++ can be found on my GitHub.

# Social Group Optimization

In the **improving phase**, the impact of the most knowledgeable member of the group raises everyone’s degree of knowledge. The member of the group with the greatest level of expertise and ability to solve the issue is **the best in the group** (improvement by the influence of the best in the group).

During the **acquiring phase**, each person deepens his or her understanding by contact with the best member of the group at the moment and with others in the group (improvement by the influence of the best in the group and the other randomly chosen member of the group).

As we can expect for the robot path planner the best position of the robot will be populated to the other robot positions (initialized randomly) in order to minimize the objective function.

In each phase of running the optimization, the robot positions are updated according to the following formulas,

During the improvement,

C is known as the self-introspection parameter. The value can be set from (0, 1).

During the acquiring phase,

x is a vector, here 2D (x,y). x(rand) is the randomly chosen position of the other member of the group. x(imp) is a position from the improvement phase.

The intuition about how the algorithm works can be depicted as follows,

Now we can specify pseudo-code for the discussed algorithm, which has its implementation in my C++ program.

# 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,

distance firefly — goal,

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.

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.