Open source computational simulation for a moth-inspired navigation algorithm

Olfactory navigation in insects, for instance when males search for mates, is a navigational problem of a self-propelled agent with limited sensor capabilities in a scalar field (odor) convected and diffused by turbulent wind. There are numerous navigation strategies proposed to explain the navigation paths of insects to food (flowers) or mating partners (females). In a search for a mate, the males use airborne pheromone puffs in turbulent environments around trees and vegetation. It is difficult to compare the various strategies because of a lack of a single simulation framework that can change a single parameter in time and test all the strategies against a controlled environment. This work aims at closing this gap, suggesting an open source, freely accessible simulation framework, abbreviated MothPy. We implement the simulation framework using another open source package (“pompy”) that recreates a state-of-the-art puff-based odor plume model of Farrell et al. [1]. We add four different navigation strategies to the simulation framework based on and extending the previously published models [2, 3], and compare their performance with different wind and odor spread parameters. We test a sensitivity analysis of the navigation strategies to the plume meandering and to increased turbulence levels that are effectively expressed as the elevated puff spread rates. The simulations are compared statistically and provide an interesting view on the robustness and effectiveness of various strategies. This benchmarking-ready simulation framework could be useful for the biology-oriented, as well as engineering-oriented studies, assisting to deduce the evolutionary efficient strategies and improving self-propelled autonomous systems in complex environments.

The known ability of male moths to reach conspecific females from long distances 2 (hundreds to thousands of meters) in turbulent environments such as forests and 3 canopies, [4,5] has attracted considerable interest in both biological and engineering 4 studies devoted to navigation strategies, e.g. [2,3,6,7]. Moths are able to navigate 5 efficiently using only local cues mediated by turbulent air. This is accomplished by 6 framework is based on the diffusion process without accounting for wind or turbulence 22 that are at the core of the moth-inspired navigation strategies [2,3,6,29]. In this work, 23 we provide a framework using an open source computational platform with wind and 24 plume characteristics set as parameters that can be adjusted in order to more 25 realistically simulate the environmental conditions. 26 Herein we examine few available moth-inspired navigation strategies based on a 27 prescribed wind and plume model. The main goal is to provide an accessible and 28 reproducible scientific simulation platform, promoting the development of new 29 navigation strategies for biology and autonomous vehicles. 30 Methods and materials 31 We build a benchmarking and comparison framework based on numerical simulations 32 for odor-based navigation. We utilize a well-known wind and plume model of [1] 33 provided by an open source software package [33] to which we add navigation models, as 34 described below. We provide the framework as an open source package written in 35 Python and entitled MothPy, see [34]. 36 In the following section we briefly review the wind and plume models, described in 37 details in [1] and with greater details, a set of four navigation models chosen for this 38 work. The models are different by the concept and their construction. Therefore, we 39 have chosen a common set of sub-modules. For instance, if some models include both 40 casting or foraging parts, and other models do not have such parts, we compare only the 41 same parts (casting/zigzagging/surging) . The choice is rather arbitrary, yet has a 42 common base that enables a fair comparison. 43 Computational framework 44 The computational framework is an open source package written in Python [34]. It is another open source project, [33], and adopted here as a good representation of the 48 model of Farrell et al. [1]. The software package is developed as the object oriented 49 programming concept, containing several classes for the wind, plume and basic 50 navigator properties. The four examples of navigators were implemented as objects 51 from those classes for the present case study. The perspective user can easily install the 52 required packages using standard Python procedures and develop its own classes based 53 on these examples. For easier adoption and reproducibility, we developed an online 54 cloud-based Jupyter notebook (use the link from the software repository) in the spirit of 55 a new term in the scientific world preproducibility [35] 56 Wind and plume model 57 The simulation is performed in a numerical domain representing a two dimensional flow 58 field in the streamwise -spanwise plane. It resembles a horizontal plane parallel to the 59 ground at some height above the vegetation without obstacles. The two velocity 60 components are the streamwise or wind direction component, u, and the transverse or 61 cross-wind direction, v in the direction of y axis. Generally, the crosswind component is 62 about an order of magnitude weaker than the streamwise component, but not negligible. 63 In some cases, a user might want to create a more realistic representation of 64 turbulent plumes in complex environments. The wind model contains an option to 65 include random noise which can represent turbulent velocity fluctuations [1]. We added 66 also a periodic, large-amplitude and relatively slow ( where A, B, ω are constants, chosen as the simulation parameters of the wind speed, 78 meandering amplitude and period, respectively. Parameter β represents a random white 79 noise. For more detailed technical information on the implementation of the wind 80 model, see [1].

81
Plume model 82 The plume model simulates the release of odor from a point source located upstream in 83 respect to the navigator. We call it odor, although the released scalar represents equally 84 temperature or concentration, among others [1]. Conceptually, the source emits the 85 odor through so-called "puffs". Physically speaking, a puff is a finite amount of scalar 86 that is preserved in time during its dispersion (a mass conservation). Mathematically, it 87 can be defined as a two-dimensional Gaussian shape carried downstream by the wind, 88 defined by the coordinates of the center of the puff, x p (t), y p (t) and the concentration 89 distribution around the puff C, which is related to the standard deviation of the 90 Gaussian function. The puff center, x p (t), y p (t), will move in the flow field with a speed 91 determined by the two-dimensional wind vector (u, v). For simplicity, we use bold 92 mathematical symbols for the 2D vectors, i.e. u = {u, v}, x p = {x p , y p }: The concentration C(r, t) around a single puff is determined by the distance from 94 the puff's center, x p (t), as well as the time passed since the formation of the puff t.

95
Broadly speaking, as the puff "matures" it becomes more dispersed, in a 96 two-dimensional approximation mathematically described in Eq. (3): where m p is the mass of the puff, H is a Heaviside function and σ is the spreading rate 98 proportional to turbulent diffusivity, see e.g. Ref. [3] for the references therein. In the 99 following, we simplify the problem using the agents with a binary sensor, therefore the 100 concentration of odor is translated into the size of the region in which the concentration 101 is above a threshold of detection, i.e. C ≥ C 0 . The size in this approximate model is a 102 circular patch of radius r p (t) and its area is proportional to r p (t) 2 , growing at the rate 103 proportional to σ 2 : Parameters of the source are the puff release rate, f r (in units of frequency, puffs per 105 second) and puff spread rate, dr p (t)/dt. The spread rate defines the linear rate of 106 increase of r p (t), as shown in Eq. (4). These two source parameters, together with the 107 wind parameters and the concentration threshold of the agent's odor sensor, determine 108 the characteristic of the plume. For instance, setting the threshold to a negligible value 109 will convert the plume type from an array of discrete, concentrated puffs into a single, 110 featureless stream of odor. We are interested in the present case study in a downwind 111 spreading plume of odor, resembling in some sense a trail of puffs, similar to that made 112 by the conditions in a wind tunnel with a single female moth secreting pheromone [36]. 113 Table 1. Model variables and parameters. Let us first note the different notations and their meanings: A -constant average wind speed, ω -angular rate of change of the wind vector direction, R -transverse diffusion of puffs, f r -puffs release rate, a number of puffs released by the source per second, r 0 -initial radius of a puff at the source, σrate of growth of a puff, C 0 -odor detection threshold of a navigator, T -time it would take a navigator to reach the source along the straight path from the initial position.

Parameter
Values Navigation strategies 114 We chose four navigation strategies for the present case study, tested in the proposed 115 computational framework. These are based on Ref. [3] (named here as: "A","B"), and 116 on Ref. [2] (named here as: "C","D"). An overview of each navigational strategy is 117 provided in the following.

118
Definitions 119 The strategy of the navigator model is comprised from a set of rules and constrains that 120 underline the decision making process. For the cases studied here, there are several 121 assumptions that are similar for all the different strategies:

122
• The agent is a free-flying object travelling at a constant ground speed and a 123 binary sensor (yes/no) for the odor cues.

124
• The agent can only measure the local wind direction and it can use an internal 125 counter [16] for the time scale estimates.

126
• The agent does not have a long-term memory or spatial information in respect to 127 the fixed coordinate system (no GPS signal) 128 Mathematically, we describe the agent as an object marked by a point in a two 129 dimensional space, x p ∈ R 2 , a point-sensor of the local wind velocity, u(x), and 130 presence/absence of odor c(x p ) = 1/0. Although a flying navigator will only sense wind 131 velocity relative to itself, we assume that using optometry data, the navigator can find 132 the direction of the wind relative to the ground. Here we adopt the widely acceptable 133 notion of optomotor anemotaxis [2,29]. That assumption is in accordance with the 134 directly observed behaviour of moths in a wind tunnel and previous models [1,3].

135
Navigation in our study is performed in a simulated wind and concentration field, as 136 explained above. The binary sensor threshold of a navigator is the last parameter that 137 defines the field for a given navigator. Two such examples of the identical simulation Two examples of the plumes with discrete puffs, based on the model of [1], using [33]. The wind direction is from left to right and the source ("female moth") is at the origin located at the center of the left side of the figure. The plume release parameters and wind parameters are identical, and the difference in the visualized puffs is due to the threshold limit of the "male moth" binary sensor: a) 1500 and b) 30000 (arbitrary units). Concentration above a threshold is marked by white pixels.
We focus on the navigation part and not on the complete process of foraging or 145 mating search. Therefore, in our simulations, the flyer does not actively search for the 146 plume. The initial condition is that a navigator is placed at position x 0 , y 0 downstream 147 the source (x 0 > 0) and within an area with a certain probability to encounter a puff.

148
The navigation starts when a puff with concentration above a given threshold "touches" 149 the initial location of the navigator. This moment is marked as the initial time of the 150 navigation path t 0 . The navigation path consists of several possible time intervals:

151
• "detection" -the time of flight during which the navigator is inside a puff, i.e. the 152 measured concentration is above the threshold;

154
• "casting" or "zigzagging" -crosswind flight with alternating changes of direction, 155 typically when the signal has been recently lost or uncertain; 156 Table 2. Key parameters of the navigators simulated in this study. For navigators "C/D", λ, δ 1 , are predetermined constants. Navigator surging casting parameter sweeping • "sweeping" -large random motions that are designed to increase the probability 157 to encounter a next signal.

158
These elements of the navigation strategy are similar to those observed in moth flights, 159 see e.g. [2]. Schematic description of a typical simulation run with the "mean wind" direction from left to right and a typical flight from right to left, including: the two dimensional wind field with an arrow emphasizing an instantaneous direction of wind, a position of the source, a plume of previously released pheromone puffs, and a prototype of a navigation path (type A), following [3]. At the time of detection of the odor, the time of crossing is defined as t c and used for the following surging (upwind flight for time denoted as λ) and casting (crosswind flight, a typical time denoted as delta 1 ). Due to the turbulent nature of the odor spreading and diffusion, pheromone puffs are increasing in size with the distance from the source.
Strategy "A" is based on the navigational strategy developed in Ref. [3]. This  Table 2. Schematic description of navigator "B" path -in addition to the cross-wind casting option, this navigator type increases its following casting time (or width of search) at some constant rate, i.e. δ 1 = α(t)t c , where α(t) is a predefined, non-adaptive, rate.
Strategies "C" and "D"

184
Navigation strategies "C" and "D" are based on the ideas in Ref. [2]. The basic move is 185 that anemotaxis, i.e. after every detection, the navigator surges upwind for time λ.

216
Using the aforementioned methods and software, we created a simulator that can mimic 217 different plumes: laminar or turbulent, continuous or sparse, patchy plumes, and strong 218 winds that can have strong gusts or meandering. Comparing different strategies and 219 characterizing their sensitivity to the plume, wind field and navigator parameters, can 220 assist in addressing the key ingredients of an olfactory-like navigation. In the following, 221 we present results of the simulator in which we compare the strategies' sensitivity to two 222 parameters: meandering and a puff spread rate. 223 We present randomly chosen "flights" or navigation paths by navigators "A-D" in Sensitivity of strategies to wind and plume parameters 238 All the four strategies "A-D" are capable of successful flights in present simulations.

239
Our focus is not on the extreme cases, where only a specific navigation strategy may 240 have an advantage, but rather on a statistically significant set of flights that will help us 241 find the sensitivity of the navigation strategies to some key parameters. The first key 242 parameter is the meandering of the plume. As reported in the previous studies, moving 243 upwind (anemotaxis) is a well thought strategy, but theoretically cannot work in a 244 strongly meandering wind. For instance, if the navigator is using local wind direction at 245 the time it encounters the first puff, during this period of time of the puff propagation, 246 the wind completely changes its direction -then the navigator will receive an unreliable 247 signal on the source location.

248
The ability of the navigators to find the plume source is classified using the two In this subsection we present the ability of different navigators to reach the odor source 265 in different meandering conditions. Meandering determines the extent in which the wind 266 changes direction between the puff release, first puff arrival to the flyer's initial position 267 and the navigation process. Meandering is characterized here by two parameters: 268 amplitude and time period, as defined in Eq. (1). A stronger amplitude and shorter 269 period will also affect the separation of puffs within the plume, in addition to creating 270 a"curved" or "wavy" plume shape. We keep the time period constant and vary only the 271 meandering amplitude, the parameter shown on the horizontal axis in Fig. 6.   Table 2. An increase in puff spread rate effectively simulates an increase in turbulent intensity. a) puff spread rate is 0.0005 m 2 /s, creating a stream of distinct, separate puffs; and b) puff spread rate is 0.001 m 2 /s, leading to overlap between different puffs that results in a continuous plume.
In percentage are not monotonic. For a given set of conditions, it appears that there is an 295 "optimal" turbulence intensity level, and the rest of the values change for 296 increasing/decreasing values for different reasons. In this particular case, there is a 297 positive effect of increasing search interval δ 1 is evident in results of navigator "B" in 298 terms of the success rate and time, as compared to type "A".

299
One plausible explanation is the strict dependence of type "A" on the last 300 measurement of the crossing time which becomes a less reliable signal for high spread 301 rates and especially at small distances from the source. Navigator types "C" and "D" 302 seem to respond negatively to the increasing spread rate, though similarly navigator "C" 303 (Large δ2) outperforms navigator "D" (small δ2).

305
The main goal of this work is to create a computational framework for comparison of 306 various navigation and decision making strategies. It is not necessarily limited to flying 307 objects, with small modifications it could also fit to simulate walking or swimming 308 agents. It is designed to allow comparison of strategies also for diffusive spread of 309 scalars, with zero wind speed, as well as problems with multiple sources.

310
In this case study we implemented four navigation strategies designed to track a 311 chemical plume trail, created by a pulsating source in a turbulent flow. The navigators 312 are self-propelled flyers with a single sensor that provides a binary odor detection 313 (above/below a threshold), and a timer, but without memory of previous states.

314
Elaborating on an existing computational simulation of turbulent flow [33], we propose 315 a system to simulate and evaluate the performance of such navigation algorithms. We 316 present a case study for 12,000 navigators of four different types and multiple parameter 317 changes of wind and plume parameters. Each navigator can only access the data about 318 the pixel on which it is positioned -the local wind velocity (magnitude and direction), 319 and local odor concentration below/above its sensor threshold. Comparison of different 320 strategies is performed statistically initiating a large set of randomly varying parameters 321 within a given set of constraints and conditions. For each instance, we locate a group of 322 navigators and collect statistics of this population in a sort of Monte Carlo simulation. 323 The important constraint is to use the same predefined simulated wind and plume fields, 324 as well as the same starting positions for a group.

325
In this paper we focused on strategies using fixed parameters [2] ("C/D"), with the 326 strategies that use locally available information about the puffs, as suggested in [3] 327 ("A"), and augmented with the extended casting search type "B". For the sake of 328 comparison, a large set of runs was performed and the results are compared in terms of 329 efficiency parameters: shorter/longer average navigation time, and a success rate (the 330 number of successful searches out of all moving navigators). We provide the comparison 331 in terms of histograms and compare our navigators for sensitivity to various wind or 332 plume characteristics. It is not the purpose of this work to claim that one of the types 333 has a better or worse performance, as this statement would be valid only in a context of 334 the simulated parameters. We observe that some navigation strategies could imply an 335 adaption to strongly meandering winds, which could potentially be an important insight 336 comparing flights of insects from different regions, or habitats.

337
The future research that will be based on the developed framework could assist 338 development of better navigating strategies for autonomous drones or underwater 339 vehicles, e.g. [31] or analysing sophisticated navigation strategies such as 340 infotaxis [28], [27].

341
The presented simulation framework is not developed with the real physical models 342 in hand. For instance, the puff spreading rate which is proportional to the turbulent 343 intensity in atmospheric boundary layers is taken here as a constant, despite the fact 344 that it is a very complex function of a varying turbulence level, a proximity to the trees 345 and canopies, or strongly depending on the atmospheric boundary layer stability [37]. 346 In the future, it would be possible to extend this study with more realistic fluid 347 dynamics and scalar dispersion models. It would be also valuable to extend this work to 348 a realistic 3D simulation field that could take into account also height varying 349 parameters and a possible effect on foraging and mating insects.