Q-learning with temporal memory to navigate turbulence

  1. Marco Rando  Is a corresponding author
  2. Martin James
  3. Alessandro Verri
  4. Lorenzo Rosasco
  5. Agnese Seminara  Is a corresponding author
  1. MaLGa, Department of Computer Science, Bioengineering, Robotics and Systems Engineering, University of Genova, Italy
  2. MalGa, Department of Civil, Chemical and Environmental Engineering, University of Genoa, Italy
5 figures, 4 tables and 1 additional file

Figures

Learning a stimulus-response strategy for turbulent navigation.

(A) Representation of the search problem with turbulent odor cues obtained from Direct Numerical Simulations of fluid turbulence (gray scale, odor snapshot from the simulations). The discrete position s is hidden; the odor concentration zT=z(s(t),t)|tTtt is observed along the trajectory s(t), where T is the sensing memory. (B) Odor traces from direct numerical simulations at different (fixed) points within the plume. Odor is noisy and sparse, information about the source is hidden in the temporal dynamics. (C) Contour maps of olfactory states with nearly infinite memory (T=2598): on average, olfactory states map to different locations within the plume, and the void state is outside the plume. Intermittency is discretized in three bins defined by two thresholds: 66% (red line) and 33% (blue line). Intensity is discretized in 5 bins (dark red shade to white shade) defined by four thresholds (percentiles 99%, 80%, 50%, 25%). (D) Performance of stimulus-response strategies obtained during training, averaged over 500 episodes. We train using realistic turbulent data with memory T=20 and backtracking recovery.

Figure 2 with 1 supplement
The optimal memory T.

(A) Four measures of performance as a function of memory with backtracking recovery (solid line) show that the optimal memory T=20 maximizes average performance and minimizes standard deviation, except for the normalized time. Top: Averages computed over 10 realizations of test trajectories starting from 43,000 initial positions (dash: results with adaptive memory). Bottom: standard deviation of the mean performance metrics for each initial condition (see Materials and methods). (B) Average number of times agents encounter the void state along their path, N, as a function of memory (top); cumulative average reward G is inversely correlated to N (bottom), hence the optimal memory minimizes encounters with the void. (C) Colormaps: Probability that agents at different spatial locations are in the void state at any point in time, starting the search from anywhere in the plume and representative trajectory of a successful searcher (green solid line) with memory T=1, T=20, T=50 (left to right). At the optimal memory, agents in the void state are concentrated near the edge of the plume. Agents with shorter memories encounter voids throughout the plume; agents with longer memories encounter more voids outside of the plume as they delay recovery. In all panels, shades are ± standard deviation.

Figure 2—figure supplement 1
The role of temporal memory with Brownian recovery strategy (same as main Figure 2A).

(A) Total cumulative reward (top left) and standard deviation (top right) as a function of memory showing an optimal memory T=3 for the Brownian agent. Other measures of performance with their standard deviations show the same optimal memory (bottom). The trade-off between long and short memories discussed in the main text holds, but here exiting the plume is much more detrimental because regaining position within the plume by Brownian motion is much lengthier. (B) As for the Backtracking agent, the optimal memory corresponds to minimizing the number of times the agent encounters the void state.

Figure 3 with 1 supplement
The adaptive memory approximates the duration of the blank dictated by physics, and it is an efficient heuristic, especially when coupled with a learned recovery strategy.

(A) Top to bottom: Colormaps of the Eulerian average blank time τb; average sensing memory T; standard deviation of Eulerian blank time and of sensing memory. The sensing memory statistics are computed over all agents that are located at each discrete cell, at any point in time. (B) Probability distribution of τb across all spatial locations and times (black) and of T across all agents at all times (gray). (C) Performance with the adaptive memory nears performance of the optimal fixed memory, here shown for backtracking; similar results apply to the Brownian recovery (Figure 3—figure supplement 1). (D) Comparison of five recovery strategies with adaptive memory: The learned recovery with adaptive memory outperforms all fixed and adaptive memory agents. In (C) and (D), dark squares mark the mean, and light rectangles mark ± standard deviation. f+ is defined as the fraction of agents that reach the target at test, hence has no standard deviation.

Figure 3—figure supplement 1
All four measures of performance across agents with fixed memory and Backtracking vs Brownian recovery (green and red respectively, unframed boxes) and with adaptive memory for Backtracking, Brownian, and Learned recovery (green, red, and blue respectively, framed boxes).
Figure 4 with 2 supplements
Optimal policies with adaptive memory for different recovery strategies: backtracking (green), Brownian (red), and learned (blue).

For each recovery, we show the spatial distribution of the olfactory states (top); the policy (center) and the state occupancy (bottom) for non-void states (left) vs the void state π(a|)(right). Spatial distribution: probability that an agent at a given position is in any non-void olfactory state (left) or in the void state (right), color-coded from yellow to blue. Policy: actions learned in the non-void states onoπ(a|o), weighted on their occupancy no (left, arrows proportional to the frequency of the corresponding action) and schematic view of recovery policy in the void state (right). State occupancy: fraction of agents that is in any of the 15 non-void states (left) or in the void state (right) at any point in space and time. Occupancy is proportional to the radius of the corresponding circle. The position of the circle identifies the olfactory state (rows and columns indicate the discrete intensity and intermittency respectively). All statistics are computed over 43,000 trajectories, starting from any location within the plume.

Figure 4—figure supplement 1
Optimal policies for different recovery strategies and adaptive memory.

From left to right: results for backtracking (green), Brownian (red), and learned (blue) recovery strategies. Top: probability that an agent in a given olfactory state is at a specific spatial location color-coded from yellow to blue. Rows and columns indicate the olfactory state; the void state is in the lower right corner. Arrows indicate the optimal action from that state. Bottom: Circles represent occupancy of each state, olfactory states are arranged as in the top panel. All statistics are computed over 43,000 trajectories, starting from any location within the plume.

Figure 4—figure supplement 2
The learned recovery resembles the cast and surge observed in animals, with an initial surge of 5±2 steps and a subsequent motion crosswind starting from either side of the centerline and overshooting to the other side.
Figure 5 with 1 supplement
Generalization to statistically different environments.

(A) Snapshots of odor concentration normalized with concentration at the source, color-coded from blue (0) to yellow (1) for environment 1–6 as labeled. Environment 1 is the native environment where all agents are trained. (B) Performance for the five recovery strategies backtracking (green), learned (blue), circling (orange), zigzag (purple) and brownian (red), with adaptive memory, trained on the native environment and tested across all environments 1–6. Four measures of performance defined in the main text are shown. Dark squares mark the mean, and empty rectangles ± standard deviation. For definition of the metrics used, see Materials and Methods, Agents Evaluation.

Figure 5—figure supplement 1
The learned recovery with adaptive memory and a single non-empty olfactory state (empty circles) displays degraded performance with respect to the full model (full circles).

Tables

Table 1
Parameters of the learned recovery, statistics over 20 independent trainings.
Initial surge upwind6 ± 2
Total steps upwind15 ± 2
Total steps downwind1.3 ± 1.4
Total steps to the right15 ± 3
Total steps to the left18 ± 6
Key resources table
Reagent type (species) or resourceDesignationSource or referenceIdentifiersAdditional information
Software, algorithmComputational fluid dynamics source codeViola et al., 2023; Viola et al., 2020; Viola et al., 2022; Verzicco et al., 2025. Courtesy of F. Viola.https://gitlab.com/vdv9265847/IBbookVdV/Reused Computational Fluid Dynamics software used to run simulations of odor transport. An earlier version of the code is publicly available at the website indicated in the ‘identifiers’ entry, described in Verzicco et al., 2025. Our simulations were conducted using a GPU-accelerated version of the code that was developed by F. Viola and colleagues in the Refs indicated in the ‘Source or reference’ entry. This version will be shared in the near future. All requests may be directed to Viola and colleagues
Software, algorithmDatasets of odor field obtained with computational fluid dynamics – Environments 5 and 6This paperhttps://doi.org/10.5281/zenodo.14655991Newly developed datasets of turbulent odor fields, obtained through computational fluid dynamics.
Software, algorithmTabular Q-learningThis paper, Rando, 2025https://github.com/Akatsuki96/qlearning_for_navigationNewly developed Model-free Algorithm for training olfactory search agents, with settings described in materials and methods. Shared on github address mentioned as ‘Identifier’
Software, algorithmDatasets of odor field obtained with computational fluid dynamics – Environments 1–4Rigolli et al., 2022bhttps://doi.org/10.5281/zenodo.6538177Reused datasets of turbulent odor fields, obtained through computational fluid dynamics in Rigolli et al., 2022b
Table 2
Gridworld geometry.

From Top: 2D size of the simulation, agents that leave the simulation box continue to receive negative reward and no odor; number of time stamps in the simulation, beyond which simulations are looped; number of actions per time stamp; speed of the agent; noise level below which odor is not detected; location of the source on the grid. See Table 3 for the values of the grid size Δx and time stamps at which odor snapshots are saved.

Simulation 1Simulation 2Simulation 3
2D simulation grid1225 × 2801024 × 2562000 × 500
# time stamps259850005000
# decisions per time stamp111
Speed (grid points / time stamp)101010
nlvl3×1063×106104
Source location(20, 142)(128, 128)(150, 250)
Table 3
Parameters of the simulations.

From Left to Right: Simulation ID (1, 2, 3); Length L, width W, height H of the computational domain; mean horizontal speed Ub=u; Kolmogorov length scale η=(ν3/ϵ)1/4 where ν is the kinematic viscosity and ϵ is the energy dissipation rate; mean size of gridcell Δx; Kolmogorov timescale τη=η2/ν; energy dissipation rate ϵ=ν/2(ui/xj+uj/xi)2; wall unit y+=ν/uτ where uτ is the friction velocity; bulk Reynolds number Reb=Ub(H/2)/ν based on the bulk speed Ub and half height; magnitude of velocity fluctuations u relative to the bulk speed; large eddy turnover time T=H/2u frequency at which odor snapshots are saved ×τη. For each simulation, the first row reports results in non-dimensional units. Second and third rows provide an idea of how non-dimensional parameters match dimensional parameters in real flows in air and water, assuming the Kolmogorov length is 1.5 mm in air and 0.4 mm in water.

Sim IDLWHUbηΔxτηϵy+RebuUbTωsave×τη
14084230.0060.0250.01390.00351150015%64τη1
air9.50 m1.90 m0.96 m36cms0.15 cm0.6 cm0.15 s6.3e4m2s30.09 cm
water2.66 m0.53 m0.27 m8.6cms0.04 cm0.2 cm0.18 s3e5m2s30.02 cm
22052140.0040.020.0051630.0038783015%95τη5
air7.50 m1.875 m0.75 m17.5cms0.15 cm0.75 cm0.15 s6.3e4m2s30.142 cm
water2.00 m0.50 m0.20 m3.9cms0.04 cm0.2 cm0.18 s3e5m2s30.038 cm
32052220.00180.010.00252040.00121750013%141τη2.5
air16.7 m4.18 m1.67 m30.6cms0.15 cm0.83 cm0.15 s6.3e4m2s30.1 cm
water4.44 m1.11 m0.44 m6.8cms0.04 cm0.22 cm0.18 s3e5m2s30.03 cm

Additional files

Download links

A two-part list of links to download the article, or parts of the article, in various formats.

Downloads (link to download the article as PDF)

Open citations (links to open the citations from this article in various online reference manager services)

Cite this article (links to download the citations from this article in formats compatible with various reference manager tools)

  1. Marco Rando
  2. Martin James
  3. Alessandro Verri
  4. Lorenzo Rosasco
  5. Agnese Seminara
(2025)
Q-learning with temporal memory to navigate turbulence
eLife 13:RP102906.
https://doi.org/10.7554/eLife.102906.3