Neuron 101

Nature-inspired optimization / Optimization landscape

Türkçe

Plate55

Unit 6 · Topic 1 of 11

Optimization landscape

Easy, 6 min, 7 steps

highest fitness
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 7 Landscape

Every solution is a position, its quality a height

The horizontal axis holds the possible solutions: x can be any number between 0 and 10. The height of a point is the fitness of that solution, how good it is. In this unit we always look for the highest point.

Open in Colab
  1. import math
  2. TEPELER = [(1.5, 0.7, 0.45),
  3. (4.5, 0.8, 0.7),
  4. (8.0, 0.9, 1.0)]
  5. def f(x):
  6. return sum(h * math.exp(
  7. -(x - m) ** 2 / (2 * s * s))
  8. for m, s, h in TEPELER)
  9. print(f(3.0))
  10. n = 5
  11. xs = [10 * i / (n - 1)
  12. for i in range(n)]
  13. en_iyi = max(xs, key=f)
  14. print(en_iyi, f(en_iyi))
x
3
fx
0.17
n
5
enIyiX
7.50
enIyiF
0.86
genelX
8
genelF
1.00
fark
0.14
yerel1X
1.50
yerel1F
0.45
yerel2X
4.50
yerel2F
0.70