# PSO – how Dimensions are set up?

I am coding a Particle Swarm Optimization in C++. I have been for days trying to understand the theory of how dimensions work in each different problem.

In the many examples I have seen, all of them only shows how can a simple problem (f(x) = pow(x,2)+5*x+20) can have 2 dimensions. Usually the “x” axis is one and the “y” axis the other one. And by combining both in a 2 dimensional search space you get a single position in the search space. Very simple.

I have seen people showing some code examples where they had 20 or 50 dimensions set up. How come is that??

My problem to be solve works like this: I have parameters, each parameter has variations that goes from 1 to 4. Example: Parameters A and B. Each has 3 variations – A0, A1, A2 – B0, B1, B2. Basically there will be 9 combinations of them like this:

A0-B0, A0-B1, A0 - B2
A1-B0, A1-B1, A1 - B2
A2-B0, A2-B1, A2 - B2

3*3 = 9

Note: Each combination will have a fitness based in some tests. There is no big deal about it.

If I had a 3rd parameter with also 3 variations, my total number of combinations would be 27(3*3*3) So lets say I have 5 parameters, A, B, C, D and E. A - 3 variations, B - 4 variations, C - 3 variations, D – 2 variations, E – 4 variations.

3, 4, 3, 2, 4 – number of variations

So 3*4*3*2*4 = 288 – maximum number of possible combination and is my upper boundary.

So each of the 288 position would represent a combination. Each particle, initialized randomly would have a random combination.

So using PSO I hope to do as less tests as possible and still reach the global optimum.

My questions are:

• How many dimensions should I set to my problem?
• Am I missing something?/ Did I understand something wrong?
• How can a problem have more than 20 dimensions?
• Are dimensions optional?