liveBook · Manning

Position vector

As explained in Grokking AI Algorithms, Second Edition

A position is the point or vector in a search space that represents a particle's candidate solution in particle swarm optimization.

In particle swarm optimization (PSO), a position vector gives a particle’s current coordinates in the search space. Think of it as a pin on a map: moving the pin proposes a different solution. In a two-coordinate problem, the position is (x, y); in a larger search space, it has a coordinate for each dimension. section 7.4

A position has several jobs during a PSO run:

  • Start somewhere: initialize each particle at a random position, spread across the search space so the swarm can explore different regions. section 7.6
  • Measure a candidate: calculate fitness at the particle’s current position to judge how good that solution is. section 7.5
  • Move and remember: update the position using velocity, then compare the new fitness with earlier results. Keep track of the particle’s best position and the swarm’s best position. section 7.4 section 7.5

A two-coordinate move

Suppose a particle is at (-1, 9). In the worked update, its next position is (0.52, 10.52): each coordinate has increased by 1.52. That new pair is another candidate solution, so its fitness must be evaluated again. The particle’s current position can change without erasing the best position it has found. section 7.8 section 7.4

In a simple Python particle, x and y store the current position, while best_x and best_y store its remembered best. Velocity controls the next move; inertia, the particle’s own best result, and the swarm’s best result influence that velocity. The practical takeaway: a position is the solution being tested now, not necessarily the best solution found so far. section 7.4 section 7.8

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Defines position as coordinates in all dimensions and traces initialization and updates through a two-coordinate example, without a general vector derivation.
Examples
Uses two-coordinate Python particles, randomly generated starting positions, and a numerical move from (-1, 9) to (0.52, 10.52).
What it assumes
Introduces particle state from coordinates and fitness while using Python class syntax without explaining that syntax.
What you can do after
Build it from scratch as current and best coordinates in a Python Particle class, then update and evaluate the current position.
How it connects
Connects position to particle swarm optimization, fitness functions, velocity, personal best position, swarm best position, and search-space exploration.

Also explained in

Compare how 3 books explain position vector →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.