# GSA Search Algorithm in C++

Is there any version of GSA (Gravitational Search Algorithm)[1] implemented with C++ or even C#?

What I found was implemented using MATLAB which is not good for me.

[1] Rashedi, Esmat, Hossein Nezamabadi-Pour, and Saeid Saryazdi. "GSA: a gravitational search algorithm." Information sciences 179.13 (2009): 2232-2248.

• In theory you can use the GSA code in matlab, and rewrite it in C++/C#. Is that possible for you? – arc_lupus May 30 '16 at 21:35
• What is GSA? Other users might not know the algorithm. I think that this question is off-topic here since it asks for an implementation of a particular algorithm and not about the algorithm itself. – nicoguaro Jun 9 '16 at 16:10
• You can find a C version here: github.com/edgnik/gsa-cpu-gpu – nicoguaro Jun 9 '16 at 16:11
• I'm voting to close this question as off-topic because it asks about a particular implementation of an algorithm. – nicoguaro Jun 9 '16 at 16:11
• @nicoguaro I disagree -- it's a perfectly reasonable (if poorly formulated) question, which your comment seems to answer (please consider expanding on it in an answer). At most, it could be closed as "unclear what you're asking", since it's not explained why Matlab is not good. – Christian Clason Jun 9 '16 at 22:25

Doing a fast search in GitHub you can find

The algorithm described by Rashedi et al in the paper you mentioned is not strictly a gravitational search algorithm.

In their equation (7), the magnitude of the force of attraction is inversely proportional to the distance between agents.

Rashedi et al claim that they get better results with equation (7) instead of the (classically) correct inverse square law. Therefore, the descriptor "gravitational" is misleading.

For an inverse square law, the denominator should be $R^3$, not $R$, in equation (7).

• Any idea on how to implement inequality constraints for GSA? – user5510 Dec 15 '16 at 17:58