I’ve been doing a deep dive into the R programming language. Whenever I’m learning a new language, there are certain algorithms/problems I tackle because these problems use lot of key features of the language (different loops, if-then, functions, classes, random numbers, and so on).

One of my standard problems is writing code to solve Rastrigin’s function using particle swarm optimization (PSO). Rastrigin’s function is just a dummy benchmark math problem that’s very difficult to solve. PSO loosely models the behavior of swarms. You use multiple particles. Each particle has a position that represents a possible solution to the problem. Particles move (that is, update their tentative solutions) towards other, better particles.

Anyway, I coded up PSO using the R language. As I expected, I learned a lot about the features and nuances of the R language. Good fun.

### Like this:

Like Loading...

*Related*