# GA and PSO formulas, symbols and memory rules

Subject: Intelligent Systems II

Exam: M2

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/formulas/m2-formulas-v2/ga-pso

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/formulas/m2-formulas-v2--ga-pso/

One place for the formulas, meanings, conditions and links to full worked examples.

### Binary decoding



$$
x=\sum_{i=1}^{n}b_i2^{n-i}
$$



bᵢ is a bit; the maximum n-bit unsigned integer is 2ⁿ−1.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--encoding/)

### Roulette selection



$$
P_i=F_i/\sum_jF_j\quad C_i=\sum_{j=1}^iP_j
$$



Fitness weights must be nonnegative with a positive total. For minimisation use the specified transformation or selection method. C is cumulative probability.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--selection/)

### Population average



$$
\bar f=\frac{f_1+\cdots+f_N}{N}
$$



N is the number of individuals. Compare both best and average; mutation need not improve either.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--two-generations/)

### PSO velocity



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$



w weights inertia; c₁r₁ weights personal pull; c₂r₂ weights social pull. Apply the same equation separately to each coordinate.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--equation/)

### PSO position



$$
x^{t+1}=x^t+v^{t+1}
$$



Use the new velocity, not the old one. Then reevaluate the objective.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--two-particles/)

**Memory updates:** minimise → replace a pbest only for a lower score; maximise → only for a higher score. gbest is a position selected from the personal bests. Store the corresponding objective score alongside it. Keep previous best on ties unless instructed otherwise.

**Yaad rakho:** Formula ke pehle objective direction aur old state likho. Iteration 2 mein fresh positions aur retained memories use karo.

## Encoding and minimisation conventions



$$
x=L+\frac{d}{2^n-1}(U-L)
$$



For the specified uniform real-range encoding: decode n bits into unsigned integer d first. L and U are the physical limits. [Endpoint examples →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--encoding/)



$$
F=\frac{1}{1+f(x)}
$$



This is the stated roulette transformation in our nonnegative-cost minimisation example. It is not required for every GA. It converts a smaller cost into a larger selection weight. [Complete minimisation example →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--minimisation/)
