FuzzyFi

Introduction

Soft Computing mini project · BMS College of Engineering

FuzzyFi

Wi-Fi router placement using Particle Swarm Optimization and fuzzy logic

Use the arrow keys, or swipe on a phone

The problem

Where should the routers go?

A router in the wrong place leaves some rooms with weak Wi-Fi. FuzzyFi finds where to put two routers on a hostel floor, so that as much of the floor as possible gets a good signal.

30 × 18 mhostel floor
960spots tested
2routers
The hostel floor: rooms on both sides of a corridor. Gaps in the corridor walls are doors.

Why soft computing?

Trying every position is too slow

460,320 possible pairs, even if routers could only stand on the 960 test spots. Checking all of them takes 10 minutes or more.

vs

820 placements checked by PSO: 20 particles at the start, then 20 more in each of 40 iterations.

Walls make the score jump suddenly, so no simple formula gives the best position. Soft computing finds a very good answer quickly, instead of a perfect answer slowly.

The two techniques

PSO is the searcher. Fuzzy logic is the judge.

The searcher

Particle Swarm Optimization

Moves the routers towards better positions.

Like 20 friends searching a dark field for the best phone signal, who keep telling each other the best spot found so far.

The judge

Fuzzy logic

Rates how good the signal is at each spot.

Instead of only good or bad, a spot can be 30% weak and 70% medium, the way people describe things.

Everything else, like the signal formula, the server and the drawing, is normal programming.

Signal model · signal_model.py

How strong is the Wi-Fi at a spot?

signal = −30 − 30 × log10(distance) − 6 × walls

−30The signal 1 metre from the router, in dBm.
30 × log10(distance)Makes the signal fade with distance.
6 × wallsRemoves 6 dBm for each wall crossed.

Example: a spot 10 m from a router, through 2 walls: −30 − 30 × log10(10) − 6 × 2 = −72 dBm. Closer to 0 is stronger. Each spot uses whichever router gives it the stronger signal.

Fuzzy logic · Step 1

Fuzzify

Each number gets a percentage for each group, called its membership. The groups overlap, so a spot can belong to two groups at once.

With one hard cut-off, −64 dBm could be good and −66 dBm bad, although they are almost the same. Fuzzy logic avoids this sudden jump.

  • Weak0.47
  • Medium0.53
  • Few walls0.67
  • Many walls0.33

The example spot: −72 dBm and 2 walls.

Weak Medium Strong −72 dBm 100% 0% -80 -65 -50 Signal in dBm Few Many 2 walls 100% 0% 0 1 2 3 4 5 6 Walls crossed

Fuzzy logic · Step 2

Apply the rules

A rule is only as true as its weaker condition, so AND takes the smaller of the two percentages. For the example spot, four rules apply.

If signal isAnd walls areThen quality isStrength for the example
StrongFewExcellent (100)min(0.00, 0.67) = 0.00
StrongManyGood (70)min(0.00, 0.33) = 0.00
MediumFewGood (70)min(0.53, 0.67) = 0.53
MediumManyFair (40)min(0.53, 0.33) = 0.33
WeakFewFair (40)min(0.47, 0.67) = 0.47
WeakManyPoor (10)min(0.47, 0.33) = 0.33

Walls are used twice on purpose. The formula lowers the signal for each wall, and fuzzy logic then treats a spot behind many walls as less reliable.

Fuzzy logic · Step 3

Combine into one rating

Each rule votes for its output number, and stronger rules count for more. The final rating is the weighted average. Because the outputs are fixed numbers, this is a Sugeno-style fuzzy system.

rating = sum of (strength × output) ÷ sum of strengths

(0.53 × 70 + 0.33 × 40 + 0.47 × 40 + 0.33 × 10) ÷ 1.67 = 72.7 ÷ 1.67 = 43.6

43.6 · Fair Poor 10Fair 40Good 70Excellent 100

Particle Swarm Optimization · pso.py

A swarm searches together

  • Particle: one possible answer, stored as four numbers: x1, y1, x2, y2. These are the positions of the two routers.
  • Fitness: the average fuzzy rating across all 960 spots. Higher is better.
  1. 1Place 20 particles at random positions.
  2. 2Score every particle with the fitness function.
  3. 3Each particle remembers its own best. The swarm shares the best found by anyone.
  4. 4Move every particle, then repeat for 40 iterations.
Iteration 0: particles start at random.
Iteration 40: the swarm has gathered at the best spots.

Particle Swarm Optimization

How a particle moves

new speed = 0.7 × old speed + 1.5 × r1 × (own best − position) + 1.5 × r2 × (swarm best − position)

new position = position + new speed

PartValueMeaning
Inertia0.7Keeps part of the old speed, so a particle keeps exploring
Own pull1.5Pull towards the particle's own best
Swarm pull1.5Pull towards the swarm's best
r1, r20 to 1Random, so particles do not all move the same way

Worked example

Position 10, speed 1, own best 12, swarm best 14, r1 = 0.4, r2 = 0.6.

Speed: 0.7 + 1.2 + 3.6 = 5.5

Position: 10 + 5.5 = 15.5

It went past the swarm's best. That is normal, and it helps the swarm explore nearby.

Implementation · Python, Flask, HTML/CSS/JS

How the code fits together

  1. app.jsBrowser asks for /run
  2. app.pyFlask starts the search
  3. For every particle, every iteration

    1. pso.pyTakes one placement
    2. signal_model.pySignal and walls at 960 spots
    3. fuzzy.pyRates each spot 10 to 100
    4. pso.pyAverages, then moves
  4. app.pySends results as JSON
  5. app.jsDraws the heat map

All the soft computing runs in Python. The browser only draws the results.

Results

PSO against random placement

Random placement: score , % of the floor good
PSO placement: score , % of the floor good

Swarm's best score by iteration

Over 10 runs, PSO scored 82.5 to 83.5 and gave 94% to 99% of the floor a good signal. 100 random placements average 66.0 and 65%. A spot counts as good from a rating of 55.

Conclusion

What we learned

Fuzzy logicRates signal the way people describe it, with no sudden jumps between good and bad.
PSOFound a placement covering about 96% of the floor after checking only 820 placements.
TogetherThe swarm searches and the fuzzy system judges, so each technique does one clear job.

Limits and future work

  • Signal strength comes from a formula, not from measuring real routers.
  • The project could be extended to more routers, several floors, or real signal measurements.

Thank you

Questions?

Soft Computing · BMS College of Engineering