Social inhibition maintains adaptivity and consensus of foraging honeybee swarms in dynamic environments

To effectively forage in natural environments, organisms must adapt to changes in the quality and yield of food sources across multiple timescales. Individuals foraging in groups act based on both their private observations and the opinions of their neighbors. How do these information sources interact in changing environments? We address this problem in the context of honeybee swarms, showing inhibitory social interactions help maintain adaptivity and consensus needed for effective foraging. Individual and social interactions of a mathematical swarm model shape the nutrition yield of a group foraging from feeders with temporally switching food quality. Social interactions improve foraging from a single feeder if temporal switching is fast or feeder quality is low. When the swarm chooses from multiple feeders, the most effective form of social interaction is direct switching, whereby bees flip the opinion of nestmates foraging at lower yielding feeders. Model linearization shows that effective social interactions increase the fraction of the swarm at the correct feeder (consensus) and the rate at which bees reach that feeder (adaptivity). Our mathematical framework allows us to compare a suite of social inhibition mechanisms, suggesting experimental protocols for revealing effective swarm foraging strategies in dynamic environments.


Introduction
Social insects forage in groups, scouting food sources and sharing information with their neighbors [1-3]. The emergent global perspective of animal collectives helps them adapt to dynamic and competitive environments in which food sources' quality and location can vary [4]. Importantly, decisions made by groups involve nonlinear interactions between individuals, temporally integrating information received from neighbors [5]. For example, honeybees waggle dance 1 to inform nestmates of profitable nectar sources [6,7], and use stop signaling 2 to dissuade them from perilous food sources [8] or less suitable nest sites [9]. While waggle dancing rouses bees from indecision, stop signaling prevents decision deadlock and builds consensus when two choices are of similar quality [10]. Thus, both positive and negative feedback interactions within the group regulate swarm decisions and foraging [11,12].
Honeybee colonies live in dynamic environments, in which the best adjacent nest or foraging sites can vary across time [13,14]. Bees adapt to change by abandoning less profitable nectar sources for those with higher yields [15], and by modifying the number of foragers [16,17]. Prior studies focused on how waggle dance recruitment or the heterogeneity of individual bee roles shape swarm adaptivity [18,19]. Inhibitory social interactions, whereby bees stop each other from foraging, have been mostly overlooked as a swarm communication mechanism for facilitating adaptation to change [20,21]. Bayesian principles and experiments suggest individuals discount prior evidence at a timescale matched to the change rate of their environment [22,23]. However, the mechanics of evidence discounting by collectives is not well understood. Here we propose that inhibitory social interactions play an important role in adapting collective beliefs of swarms foraging in a fluid world.
To study how social inhibition shapes foraging yields, we focus on a task in which the nectar quality of feeders is switched periodically. In prior studies [15,19], swarm foraging targets shifted in response to food quality switches, suggesting bee collectives can detect such changes. Granovskiy et al (2012) emphasized that uncommitted inspector bees can lead bees away from the previously dominant foraging site [19]. They also found recruitment via waggle dancing is unimportant for effective foraging in changing environments (See also [24]). Here we also find recruitment can be detrimental, but negative feedback interactions can rapidly pull bees from low to high yielding feeders. This paired with 'abandonment' whereby bees spontaneously stop foraging facilitates the swarm-wide temporal discounting of prior evidence. In contrast, strong positive feedback via recruitment causes bees to congregate at feeders even after food quality has dropped, biasing a swarm's behavior based on past states of the world.
We quantify the contribution of these positive and negative feedback interactions within a mathematical swarm model. Our study focuses on four potential inhibitory social interactions -discriminate and indiscriminate stop signaling [8,9], direct switching [25,26], and self inhibition -by which foraging bees alter the behavior of other foraging bees. Strategies are compared by measuring the rate of foraging yield over the timescale of feeder quality switches. When bees have a single feeder, social interactions are less important, but in the case of two feeders the performance of different forms of social interactions is clearly delineated. Direct switching, by which a bee converts another forager to their own preference, is the most effective means for a swarm to adapt to food site quality changes. Also, foraging yields are most sensitive to swarm interaction tuning in rapidly changing environments with lower food quality. Model linearizations allow us calculate a correspondence between social interaction parameters and the consensus (steady state fraction of bees at the high yielding site) and adaptivity (the rate of switching from low to high yielding sites). This provides a clear means of determining the impact of social interactions on a swarm's foraging efficacy.

Results
The mathematical swarm model assumes individual bees may be uncommitted or committed to one of the possible feeders [26]. Uncommitted bees spontaneously commit by observing a feeder or by being recruited by another currently foraging bee. Committed bees may spontaneously abandon their chosen feeder, or may be influenced to stop foraging or switch their foraging target based on inhibitory social interactions we describe [9,26]. A population level model emerges in limit of large swarms. Stochastic effects of the finite system do not qualitatively change our results in most cases (See Appendix C.5).
We mostly focus on two feeder (A and B) systems, in which the fraction of the swarm committed to either site is described by a pair of nonlinear differential equations in the limit of large swarms (See Fig. 1a for a schematic):u where α A,B (t) are time-dependent food qualities at sites A, B (See Fig. 1b for examples); β min −1 is the rate bees recruit nest mates to their feeder via waggle dancing; γ min −1 is the rate bees spontaneously Fig 1. (a) Schematic of swarm foraging model with two feeding sites (e.g., flowers or feeder boxes), Eq. (1). Bees move along arrows between different opinions (uncommitted or committed); arrow labels indicate interactions that provoke those opinion switches. (b) Example feeder quality time series α A,B (t), which switch with period T minutes. abandon a feeder 3 ; and S(x, y) is a nonlinear function describing inhibitory social interactions (e.g., stopsignaling, direct switching as described in Appendix B.1). Since the swarm commitment fractions are bounded within the simplex 0 ≤ u A,B ≤ 1 and 0 ≤ u A +u B ≤ 1, the commitment (α A,B ) and recruitment (β) provide positive feedback and the abandonment (γ) and inhibition (S) provide negative feedback. Foraging efficacy is quantified by the reward rate (RR) of the swarm, assuming net nutrition is proportional to both the fraction of the swarm at a feeder u X times the current quality of that feeder minus the foraging cost c (e.g., the energy required to forage and/or the predator risk), α X (t) − c.
Integrating this product and scaling by time yields the effective RR: Given a food quality switching schedule α A,B (t) and total foraging time T f , swarms with more efficient foraging strategies (β, γ, S) have higher RRs J. Before studying how social inhibition shapes swarm foraging in two feeder environments, we analyze the single feeder model, finding that commitment and negative feedback from either abandonment or inhibition are usually sufficient for the swarm to rapidly adapt to feeder quality switches. (3) within each food quality epoch are marked as dots. Dynamic increases/decreases of the foraging fraction are indicated by right/left arrows. Bees forage when food becomes available (α →ᾱ > 0 for t ∈ [0, T )) andū > 0 is stable and abandon the feeder once food is removed (α → 0 for t ∈ [T, 2T )) if recruitment is weaker than abandonment (β < γ). (d) Swarm fraction foraging u(t) tracks environmental changes. Higher/lower consensusū is obtained by changing the balance of recruitment β and abandonment γ. (e) Reward rate maximizing strategies vary with feeder quality (ᾱ) and switching interval (T ). Each colored region denotes a different optimal strategy given the environment (ᾱ, T ). The best strategies exclude recruitment (β = 0). Boldness of letters γ and ρ denote the strength of swarm behaviors that best adapt to the given environment. In rapid (short T ) or low quality (lowᾱ) environments (white region), strong inhibition ρ and weak abandonment γ is best, whereas in slow or high quality environments, inhibition ρ can be weak. We take τ = T /10 min throughout. See Appendix A.3 for optimization methods.

Shaping swarm adaptivity and consensus for single feeders
Inhibitory social interactions in a single feeder model can only take the form of self inhibition, by which a foraging bee stops another based on a detected change in food quality (Fig. 2a). Since transit from the hive to the feeder takes time, we incorporate a delay of τ minutes, so the fraction of foraging bees u evolves as:u where α(t) is the food quality schedule of the feeder that switches at time intervals T (minutes) between α(t) = 0 and α(t) =ᾱ [15, 19] (Fig. 2b), β min −1 and γ min −1 are the recruitment and abandonment rates, and ρ min −1 is the rate of self-inhibition. Swarm adaptivity and consensus is shaped by both individual behavior changes (commitment α(t) and abandonment γ) and interactions (recruitment β and inhibition ρ) [9]. Periodic solutions to Eq. (3) can be found explicitly, allowing us to to compute a swarm's reward rate (RR) (See Appendix A.2). Adaptive swarms rapidly return to the hive when no food is available and quickly populate the feeder when there is food (Fig. 2c,d). Eq.
(3) admits one stable equilibrium in each time interval: When no food is available (α(t) = 0) the nonforaging (ū = 0) equilibrium is stable as long as recruitment is not stronger than abandonment (β < γ). When food becomes available (α(t) =ᾱ > 0) the stable fraction of foragersū increases with food quality (See Fig. 2c and Appendix A.1). This fractionū corresponds to the consensus of the swarm [28], and the rate λ we deem the swarm's adaptivity.

Robust foraging should adapt to the environmental conditions
The performance of swarm interaction strategies strongly depends on the feeder qualityᾱ and switching time T . Swarms with stronger rates of abandonment γ and self-inhibition ρ more quickly leave the feeder once there is no food (α(t) :ᾱ → 0), but have limited consensusū when food becomes available (α(t) : 0 →ᾱ). Increasing the recruitment rate β, on the other hand, boosts consensus but can slow the rate at which the swarm abandons an empty feeder (Fig. 2d).
To quantify the effect of abandonment γ, recruitment β, and self-inhibition ρ, we compute the long term RR of the swarm, measuring the foraging yield over a single period (2T minutes) once the swarm equilibrates to its periodic switching behavior (See Appendix A.2): where 0 < c <ᾱ is the cost of foraging and α(t) ∈ {0,ᾱ} is the quality of foraging site. For each foraging site quality level,ᾱ, there is an optimal foraging strategy (abandonment γ, recruitment β and stop signaling ρ) within our set of possible strategies (See Appendix A.3) that maximizes the RR J(γ, β, ρ) (Fig. 2e). Here, private information is sufficient for individual bees to commit to foraging (quality sensing α(t)), and recruitment does not benefit the swarm (β = 0). Reinforcing the majority opinion via recruitment is detrimental once the environment changes, as opposed to static environments [9,29,30]. In rapid (small T ) or low food quality (ᾱ low) environments, stronger inhibition (large ρ) is needed to swap swarm commitment when the environment changes (white region, Fig. 2e). This nonlinear mechanism increases the adaptivity of the swarm, but tempers the initial stage of consensus after the feeder is switched on (See Appendix A.1 for details). On the other hand, when food is plentiful (highᾱ) (brown regions, Fig. 2e), inhibition should be weak (small ρ). In intermediate environments, the best strategies interpolate these extremes.
Linearizing solutions to the model Eq.
(3) provides us with a closer look at how swarm dynamics impact foraging yields. In sufficiently slow environments (large T ) with small delays (τ → 0), we can linearly approximate the evolving foraging fraction (See Appendix A.4): whereū is the consensus foraging fraction and λ on/off are the rates the swarm arrives/departs the feeder once food is switched on/off. Plugging Eq. (5) into Eq. (4), we estimate the RR: It can be shown that ∂ λ J > 0 for λ = λ on/off , so the RR increases with the rates at which the swarm switches behaviors. These rates increase as abandonment γ and social inhibition ρ are strengthened (Appendix A.1). Clearly, J increases withū since more bees forage when food is available. Increasing abandonment γ tends to decrease consensus, so the most robust foraging strategies cannot use abandonment that is too rapid (Appendix A.1). We conclude that the volatility (1/T ) and profitability (ᾱ) of the environment dictate the swarm interactions that yield efficient foraging strategies. One important caveat is that we bounded the interaction parameters, so swarm communication cannot be arbitrarily fast. This biological bound may be lower in practice, explaining slow adaptation of swarms to feeder changes in experiments [15,19]. Our qualitative finding, that social inhibition is more effective in slow and high quality environments, should be robust to even tighter bounds. We have also shown that when social inhibition is not present, abandonment must be increased as the speed and quality of the environment is increased (Appendix C.1 and Fig. 7). In the next section, we extend these principles to two feeder environments, particularly showing how specific forms of social inhibition shape foraging yields.

Foraging decisions between two dynamic feeders
For the swarm to effectively decide between two feeders, it must collectively inhibit foraging at the lower quality feeder. Our mean field model, Eq. (1), generalizes house-hunting swarm models with stop-signaling [9, 10, 30] to a foraging swarm in a dynamic environment with different forms of social inhibition (Fig. 1). How do these inhibitory interactions contribute to foraging efficacy? Honeybees can deliver inhibitory signals to nestmates foraging at potentially perilous sites [8, 31, 32], but swarm-level effects of these mechanisms are not well studied in foraging tasks in dynamic environments [33]. As we will show, the specific form of social inhibition can strongly determine how a swarm will adapt to change.

Forms of social inhibition
Generalizing previous models [9, 25], we consider four forms of social inhibition (all parameterized by ρ as before): (a) direct switching: bees foraging at the superior feeder directly switch the preference of opposing foragers to the better feeder; (b) indiscriminate stop-signaling: when two foraging bees meet, one will stop foraging; (c) self-inhibition: when two bee foraging at the same feeder meet, one will stop foraging; and (d) discriminate stop-signaling: when bees foraging different feeders meet, one stops foraging. These interactions are visualized in Fig. 3a,b,c,d and their evolution equations are given in Appendix B.1 (See also [9] supplement).
We can divide these forms of social inhibition into two classes, based on the swarm dynamics they produce: monostable or bistable consensus behaviors. The first three forms of social inhibition yield swarms with monostable consensus behaviors (See Appendix B.2), tending to a single stable foraging fraction when the feeder qualities are fixed (Fig. 3e). The swarm will thus mostly forage at the higher yielding feeder. On the other hand, strong discriminant stop-signaling can produce swarms with bistable consensus behaviors (Fig. 3f). As a result, the swarm can remain stuck at an unfavorable feeder, after the feeder qualities are switched. This is similar to "winner-take-all" regimes in mutually inhibitory neural networks [26,34]. Inhibition from bees holding the swarm's dominant preference is too strong for bees with the opposing preference to overcome, even with new evidence from the changed environment.

Direct switching leads to most robust foraging
To determine the most robust forms of social inhibition for foraging in dynamic environments, we studied how the rate of reward, Eq. (2), depended on the foraging strategy used. Environments are parameterized by the time between switches T (min), the better feeder qualityᾱ and the lower feeder qualityᾱ/2, which periodically switch between feeders A and B. As in the single feeder case, we tune interactions of each strategy ( Fig. 3a,b,c,d) to maximize reward rate (RR) over a discrete set of strategies (See Appendix B.3 for details). Comparing each social inhibition strategy type's RR in different environments (Fig. 4a), we find direct switching generally yields higher RRs than other strategies. Deviations between the c. d. e.
f.  Fig. 1) and their resultant dynamical behaviors: (a) direct switching: inhibiting bee switches opposing nestmate to their preference; (b) indiscriminate stop signaling: inhibiting bee may either cause opposing or agreeing nestmate to become uncommitted; (c) self-inhibition: inhibiting bee causes agreeing nestmate to become uncommitted; (d) discriminate stop signaling: inhibiting bee causes opposing nestmate to become uncommitted. Phase portraits: (e) Monostable behavior arises from direct switching, discriminate stop signaling, and selfinhibition so the swarm always tends to a single equilibrium foraging fraction given fixed feeder qualities.
(f) Bistable behavior that can emerge for strong discriminate stop-signaling.
effectiveness of different strategies are most pronounced at intermediate environmental timescales T . As expected, RRs increase with the maximal food site qualityᾱ (Fig. 4b,c). Direct switching is likely a superior strategy because it allows for continually foraging (Fig. 3a), rather than other strategies' interruption by an uncommitted stage (Fig. 3b,c,d), which must rely on recruitment β to restart foraging. To study how interactions should be balance to yield effective foraging, we examined how to optimally tune (β, γ, ρ) across environments in the direct switching model (Fig. 5). Analysis of other models are show in Figs 8 and 9 of Appendix C.2.
As in the single feeder environments, we see a delineation between strategies optimized to slow/high quality environments as opposed to rapid/low quality environments. Weak recruitment β (Fig. 5a) and abandonment γ (Fig. 5b), and strong direct switching (Fig. 5c) yield the highest RRs in slow (large T ) and high quality (largeᾱ) environments. Recruitment β may be inessential since the food quality signals α andᾱ/2 are significantly different. Also, direct switching ρ provides strong adaptation to change. In fact, for virtually all environments, we found it was best to take ρ as strong as possible. The strategy changes significantly when the environment is fast (small T ) and low quality (smallᾱ), in which case abandonment γ should be strong, and in extreme cases direct switching ρ can be made weak (Fig. 5b,c). Changes in the optimal recruitment strength are less systematic, however, and there are stratified regions in which the best β can change significantly for small shifts in environmental parameters. Overall, a mixture of abandonment and direct switching is more effective in more difficult environments (lower T andᾱ). Direct switching does underperform self-inhibition in rapid environments ( Fig. 4a), since the swarm is more efficient by keeping some bees uncommitted, and not risking the cost of foraging the lower yielding feeder. Strong self-inhibition ρ keeps more bees from foraging. Overall, both direct switching and selfinhibition can perform similarly, as recruitment interactions can be strengthened in self-inhibiting swarms, so more bees return to foraging after such inhibitory encounters (Fig. 4). This balances adaptivity, so the swarm's preferences change with the environment, and consensus, so the swarm mostly builds up to forage at the better feeder given sufficient time. We now study this balance in each model using linearization techniques. Overall, these measures can account for discrepancies between the RR yields of swarms using different social inhibition strategies.

Linearization reveals strategy adaptivity and consensus
Each swarm interaction mechanism differentially shapes both the fraction of bees that forage at the better site in the long time limit (consensusū) and the rate at which this bound is approached (adaptivity λ). Focusing specifically on these measures, we demonstrate both how they shape foraging efficiency and how they distinguish each social inhibition strategy.

Food quality↵
Period of switch T (min) The best tunings of recruitment vary considerably for rapid (low T ) and low qualityᾱ environments, but recruitment appears to be less essential for slow (high T ) and high qualityᾱ environments. (b) The rate of abandonment that best suits the environment decreases as the environment becomes slower and higher quality. (c) Generally, the direct switching rate should be made as strong as possible, except for very fast, low quality environments.
We leverage our approach developed for the single feeder model, and consider linear approximations of Eq. (1) in the limit of long switching times T (See Appendix B.4 and Fig. 10 in Appendix C.3). In the specific case c :=ᾱ/2, we can approximate the RR solely in terms of the consensusū (long term fraction of the swarm at the better feeder) and adaptivity λ (rate this fraction is approached): The RR J increases with consensusū and adaptivity λ (Fig. 6a). Efficient swarms rapidly recruit a high fraction of the swarm to the better feeder. Consensus and adaptivity are approximated in each model using linear stability (Appendix B.2). The impact of varying abandonment γ and social inhibition ρ onū and λ is consistent with our optimality analysis of the full nonlinear model (Fig. 6b,c): Social inhibition generates more robust swarm switching between feeders than abandonment. While strengthening abandonment γ can increase λ, it decreases consensusū since it causes bees to become uncommitted (Fig. 6b). Such consensus-adaptivity trade-offs do not occur in most models, as social inhibition ρ is strengthened (See also Figs 11 and 12 in Appendix C.4). Only indiscriminate stop-signaling exhibits this behavior (Fig. 6c), but the other three models (direct switching, discriminate stop signaling and self inhibition) do not. Rather, consensusū increases with social inhibition, while adaptivity can vary nonmonotonically (direct switching) or even decrease (self-inhibition). Overall, direct switching swarms attain the highest levels of consensus and adaptivity, consistent with our finding that it is the most robust model (Fig. 4). Direct switching sustains both high levels of consensusū and adaptivity λ (

Discussion
Foraging animals constantly encounter temporal and spatial changes in their food supply [36]. The success of a foraging animal groups thus depends on how efficiently they communicate and act upon environmental changes [37]. Our swarm model analysis pinpoints specific social inhibition mechanisms that facilitate adaptation to changes in food availability and consolidate consensus at better feeding sites. If bees interact by direct switching, they can immediately update their foraging preference without requiring recruitment, keeping foragers active following environmental changes. Recruitment is less important to the foraging success of a swarm in dynamic conditions; bees can initiate commitment via their own scouting behavior. Individuals should balance their social and private information in an environment-dependent way to decide and forage most efficiently [38,39].
Efficient group decision making combines individual private evidence accumulation and information sharing across the cohort [40]. However, in groups where social influence is strong, opinions generated from weak and potentially misleading private evidence can cascade through the collective, resulting in rapid but lower value decisions [10, 41,42]. Our analysis makes these notions quantitatively concrete by associating the accuracy of the swarm decisions with the consensus fraction at the better feeder and the speed of decisions with the adaptivity or rate the swarm approaches steady state consensus (Fig. 6). The best foraging strategies balance these swarm level measures of decision efficiency. Social insects do appear to balance the speed and accuracy of decision to increase their rate of food intake [43,44], and collective tuning is likely influenced by individuals varying their response to social information.
We find that social recruitment can speed along initial foraging decisions, but it can limit adaptation to change. This is consistent with experimental studies that show a reduction in positive feedback can help collectives steer away from lower value decisions. For example, challenging environmental conditions (e.g., volatile and low food quality) are best managed by honeybee swarms whose individuals do not wait for recruitment but rely on their own individual scouting [24]. Ants encountering crowded environments tend to deposit less pheromone to keep their nestmates from less efficient foraging paths [45]. These experimental findings suggest social insects adapt to changing environmental conditions by limiting communication that promotes positive feedback [46]. Foragers must then be proactive in dynamic environments, since they cannot afford to wait for new social information [47]. Thus, the advantages of social learning depend strongly on environmental conditions [48].
In concert with a reduction in recruitment, we predict that honeybee swarms foraging in volatile environments will benefit from strengthening inhibitory mechanisms at the individual and group level.
Bees enacting social inhibition dissuade their nestmates from foraging at opposing feeders. We found the most efficient form of social inhibition is direct switching whereby bees flip the opinion of committed bees to their own opinion. So do honeybees utilize this mechanism in dynamic environments? Observations of swarms making nest site decisions show scouts directly switching their dance allegiance [25,49], but these events seem to be relatively rare in the static environments of typical nest site selection experiments [29]. Other forms of social inhibitory signals, especially stop-signaling, appear to be used to promote consensus in nest decisions [9,10] and escaping predators while foraging [8,31]. Thus, the role and prevalence of social inhibition as a means for foraging adaptively in dynamic environments warrants further investigation. Our simple parameterized model, developed from previously validated house-hunting models [9,26,30], is amenable to analysis and could be validated with time series measurements from dynamic foraging experiments. Past experimental work focused on shorter time windows in which only a few switches in feeder quality occurred [15,19], which may account for the relatively slow adaptation of the swarms to environmental changes. We predict swarms will slowly tune their social learning strategies to suit the volatility of the environment, but this could require several switch observations. Foraging tasks conducted within a laboratory could be controlled to track bee interactions over long time periods using newly developed automated monitoring techniques [50]. Our study also identifies key regions in parameter space in which different foraging strategies diverge in their performance, suggesting that placing swarms in rapid environments with relatively low food supplies will help distinguish which social communication mechanisms are being used.
Collective decision strategies and outcomes can depend on group size [51,52], though decision accuracy does not necessarily increase with group size [53]. We approximated swarm dynamics using a population level model, which is the deterministic mean field limit of a stochastic individual interaction based model [9]. Finite group size considerations would result in a models which behaves stochastically, in which the same conditions can generate different swarm dynamics [10]. The qualitative predictions of our mean field generally did not change dramatically when considering the stochastic finite size model (See Appendix C.5 and Fig. 13). However discriminate stop-signaling swarms exhibit bistable decision dynamics (Fig. 3d,f), so we expect in the stochasticity in the finite sized model would allow swarms to break free from less profitable feeders, similar to noise-driven escapes of a particle in double potential well models [54]. Fluctuation-induced switching may provide an additional mechanism for flexible foraging [55,56], and would be an interesting extension of our present modeling work.
Data Accessibility: Code for producing figures is available at https://github.com/sbidari/dynamicbees Authors' contributions: Formulated scientific question, modeling approaches, developed models: SB, OP, ZPK; implemented mathematical analysis and computer simulations: SB; wrote the article: SB, OP, ZPK. All authors were involved in discussions on different aspects of the study.
Competing interests: We declare we have no competing interests.
Funding: SB and ZPK were supported by an NSF grant (DMS-1615737). SB was also supported by a Dissertation Fellowship from the American Association of University Women. ZPK was also supported by NSF/NIH CRCNS grant(R01MH115557).

A Swarm foraging dynamics for a single switching feeder
Consider model Eq.
(3) for which the food quality α(t) switches between two values α(t) =ᾱ and 0 at length T minutes, similar to previous experiments [15,19]. Before analyzing the temporal dynamics u(t) of the swarm in response to food quality switches, we study equilibria and their stability to determine different swarm interactions impact foraging consensus and the rate at which it is approached.
We deemū :=ū 2 + the consensus level, as it is the upper limit on the fraction of the swarm foraging the feeder, when it supplies food. The eigenvalues λ on := λ 2 + and λ off := λ 4 0 define the adaptivity of the swarm, or the rates of arrival to/departure from the feeder when it does/does not supply food.

A.2 Periodically forced swarm foraging
Long term periodic solutions to Eq. (3) result from switching the food quality α(t) betweenᾱ and 0 every T minutes. These are obtained by solving Eq. (3) iteratively using separation of variables. For example, when α(t) ≡ᾱ and α(t − τ ) ≡ 0 we can separate variables and factor the resulting fraction: where D is defined in Eq. (8). Integrating, isolating u, and applying u(0) = u 0 , we find consistent with our equilibrium analysis showing lim t→∞ u(t) =ū =ū 2 + . Now, taking α(t) ≡ᾱ on t ∈ [2nT, (2n + 1)T ) for n = 0, 1, 2, 3, ... andᾱ ≡ 0 otherwise, we will havė where R(t) ≡ ρᾱ for t ∈ [2nT + τ, (2n + 1)T + τ ) and R(t) ≡ 0 otherwise. The periodic solution to Eq. (10) can be derived self-consistently by starting with an unknown initial condition u(0) = u 0 , and then requiring u(2T ) = u 0 . Thus, within t ∈ [0, τ ), we have the solution given by Eq. (9), and At t = τ , self-inhibition vanishes and the solution is a special case of Eq. (9) for which ρ = 0. Thus, we can solve Eq. (3) with u(τ ) = u 1 as an initial condition and write for t ∈ [τ, T ): so that at t = T , we have Beyond t = T , the dynamics is governed by a special case of Eq. (12) for which (ū + , for β = γ, and the limit as γ → β is u(t) = u2 1+u2βt , which can both be evaluated at t = T + τ to yield, At t = T + τ , self inhibition returns since α(t − τ ) ≡ 0, increases the negative feedback acting on foragers. The long term steady state is determined by the balance of abandonment and recruitment: for β = γ, and in the limit β → γ, u(t) = u3 1+u3(β+ρᾱ)t . Both expressions can be evaluated at t = 2T , and self-consistency of the periodic solution requires u 4 ≡ u 0 , Eqs. (11), (13), (14), and (15) can be solved explicitly for (u 0 , u 1 , u 2 , u 3 ), although the expressions are quite cumbersome, so we omit them here. These analytic solution techniques were used to generate the foraging fraction trajectories plotted in Fig. 2d and to identify model parameter that optimize the RR J in different environments (plotted in Fig. 2e) as we now describe.

A.3 Optimizing reward rate over strategy sets
We optimized the reward rate (RR) of the swarm foraging a single switching feeder by restricting the strategies to a discrete set of interaction parameter values. The RR in large regions of parameter space was relatively flat since it involves the sum of several exponentially small terms. To avoid spurious convergence, we focused on each parameter's relevant order of magnitude which led to the highest long term RR. For a given environment (α, T ), we identified the combination of interaction parameter values from the set (β, γ, ρ) ∈ {0.01, 0.1, 1, 10} 3 (in 1/min) yielding the highest RR J computed from Eq. (4). Bounds on interaction parameters were imposed so that a swarm could not completely dispense with any interaction or feedback mechanism or strengthen any to be arbitrarily rapid. This was performed over a mesh of environmental parametersᾱ ∈ [0.5, 20] (at ∆ᾱ = 0.1 steps) and T ∈ [1, 200] (at ∆T = 1 minute). We found that β = 0.01 min −1 was optimal across all environment types, but that γ and ρ varied in strength dependent on the environmental conditions (See Fig. 2e).

A.4 Linear approximation of the periodic solution and reward rate
The RR Eq. (4) for the single feeder can be estimated by linearly approximating the swarm dynamics using results from our equilibrium analysis. Assuming the interval T and between feeder quality switches (α :ᾱ → 0; α : 0 →ᾱ) and the delay τ are large, the swarm will nearly equilibrate before each switch, suggesting the following linear approximation of the foraging fraction:

B.1 Forms of social inhibitions
Here, we provide detailed descriptions of the dynamical models associated with each type of social inhibition used in the model of a swarm foraging two feeders, as generalized in Eq. (1). In the main text, we simply indicate the general form of social inhibition with the function S(u A , u B ), but we provide the functional form for these interactions in the descriptions below.
Direct Switching Model: A bee committed to a feeder inhibits bees with opposing opinions by causing them to switch the feeder to which they are committed: where τ (in minutes) indicates the time delay required for the strength of the direct switching signal (based on detected food quality) to update following a switch in the food quality. Notice that the social inhibition terms in either evolution equation (u A or u B ) will necessarily be of opposite sign since each is the negative of the other and α A (t) = α B (t) for all t > 0.

Indiscriminate Stop Signal Model:
A bee committed to a feeder indiscriminately inhibits bees committed to either feeder, affecting both bees committed to the same feeder and those committed to a different feeder, and causes them become uncommitted: where τ (in minutes) is the time delay required for food quality switch detection as in the direct switching model. This form of social inhibition will always lead to negative feedback to both populations as long as ρ > 0.

Self-Inhibition Model:
A bee committed to one feeder inhibits bees committed to the same feeder, causing them to become uncommitted: where τ is the time delay. Self-inhibition is only active in the population of foragers for which the swarm detects there is less than the maximum supply of food available (α A,B (t − τ ) <ᾱ).

Discriminate Stop Signal:
A bee committed to a feeder inhibits bees committed to different feeders, causing them to become uncommitted: where τ is the time delay. The strength of the stop signal varies with the detected quality of each feeder.

B.2 Equilibria and linear stability
We determined linear approximations of periodic solutions to the full nonlinear model Eq.
(1) by studying the equilibria and linear stability properties of the full system. For any t, the dynamics of Eq. (1) is governed by the piecewise constant values of the food quality functions denotedᾱ t A,B = α A,B (t) and ᾱ τ A,B = α A,B (t − τ ) as the actual current and delay-observed values so that: where S(x, y; α x , α y ) is the nonlinear function describing inhibitory social interactions, parameterized by the strength ρ and delayed quality observationsᾱ τ A,B (See Section B.1 for exact forms). Since Eq. (16) is autonomous for piecewise time intervals, equilibria can be defined on each interval [57]. Eq. (16) can be explicitly solved using the quartic equation for all models and time intervals, but the expressions for u A,B are unwieldy, so we do not write them here.
Linear stability was classified using the eigenvalues λ ± = 1 2 Tr(D) ± Tr(D) 2 − 4det(D) of the Jacobian about fixed points (u A , u B ) = (ū A ,ū B ): Specific cases are stable nodes (with two negative real eigenvalues, λ ± < 0) and saddles (with one negative/one positive real eigenvalue, λ ± ≷ 0) as illustrated Fig. 3. Direct switching, self inhibition and indiscriminate stop signaling yield monostable behavior -a phase space only containing a single stable node (Fig. 3e) -and the majority of bees forage at the high yielding feeder (ū A >ū B ). Discriminate stop signaling model can generate bistability for weak abandonment γ and strong recruitment β and stop-signaling ρ. In this case, the phase space is occupied by two stable nodes separated by a saddle point (Fig. 3f). In this case, consensus is lower in some phases of the foraging cycle, since discriminate stop-signaling prevents switching between feeders. For the self inhibition model, the optimal strategy is low abandonment (γ = 0.01 min −1 ) with high recruitment and social inhibition (β = ρ = 10 min −1 ). The maximum RR is plotted for each of the four models in a given environmental condition (food qualityᾱ and switching period T ) in Fig 4.

B.4 Linear approximation of the periodic solution
To compute consensus and adaptivity, we derived a linear approximation to the period solution in the two feeder case. Feeder qualities started with α A (t) =ᾱ and α B (t) =ᾱ 2 and switched every T minutes. Assuming T large, the swarm will equilibrate between condition switching, yielding the following estimate of the u A (t) part of the periodic solution: population, u B (t) = u A (t + T ). This implies λ 1 = λ 3 and λ 2 = λ 4 . In the long time limit, the RR Eq. (2) can be computed: Considering the limit of long time intervals lim T →∞ and short delays lim τ →0 and the case in which u 2 +ū 4 ≈ 1 (no uncommitted bees in the long time limit) we further simplify the expression: For the specific case in which c =ᾱ 2 , we remove the superscripts soū =ū 2 and λ = λ 2 : The gradient of the RR alongū and λ can then be computed as: showing J is increasing inū as long as λT > 1.594 and increasing in λ as long asū > 0.5.

C Supplemental figures and table
C.1 Matching abandonment rate to switching rate in a single dynamic feeder Considering the single feeder foraging swarm model without nonlinear negative feedback (ρ = 0 so delays τ are irrelevant), we can explicitly compute the RR J as a function of other parameters. We found that the best strategies do not utilize recruitment (β = 0), so the abandonment rate γ is the only parameter that needs to be tuned with the environmental switching time T and food qualityᾱ. Thus, Eq. (3) is linear and so the linear approximation of the periodic solution is exact, described by determining the maximum with respect to the abandonment rate γ by solving ∂ γ J = 0 (Fig. 7). The optimal abandonment rate γ increases with the food site quality and decreases with the switching time T of the environment. Thus, the negative feedback process should adapt to the dynamics of the environment, and discounting can be more rapid when the evidence for feeder quality is stronger.
C.2 Foraging strategies with discriminate and indiscriminate stop signaling In discriminate stop signaling model, weak recruitment β (Fig. 8a), weak abandonment γ (Fig. 8b), and strong stop signaling (Fig. 8c) yield the highest RRs for most environments (ᾱ, T ). In slow (large T ) and high qualityᾱ environments, abandonment γ should be strong, and discriminate stop signaling ρ can be made weak (Fig. 8b,c). Recruitment should be weak in most environments (Fig. 8a).   c.

Food quality↵
Period of switch T (min) There is no clear preferred interaction profile for maximizing RR across environments (ᾱ, T ) in the case of indiscriminate stop signaling (Fig. 9). Interestingly, the strength of indiscriminate stop signaling parameter ρ should be made low for virtually all environments (Fig. 9c), and thus it does not seem to improve foraging efficiency. Consensus is lower due to the non-selectivity of social inhibition to all foraging bees.
For the self inhibition model, to maximize foraging efficiency, abandonment should be made weak (γ = 0.01 min −1 ) while recruitment and social inhibition should be made strong (β = ρ = 10 min −1 ).

a.
b. c. c.
Consensusū and adaptivity λ computed as described in Sections B.2 and B.4, as social inhibition strength ρ is increased between [0, 20] min −1 (along the direction of the arrows) for all models. Other parameters are fixed at their optimal level. example Fig. 10a,b). If the system not poised close to a bifurcation, the dynamics between switches roughly linearly decays to the stable equilibrium. However, in the discriminate stop-signaling model, the system can lie close to the saddle-node bifurcation beyond which the model exhibits bistability (Fig. 10c).
In this case, the ghost of the saddle-node slows the solution trajectory, a nonlinear effect which is not well characterized by a linear approximation [58].

C.4 Computing adaptivity and consensus across models
Here we calculate consensusū and adaptivity λ across a wider range of environments as the abandonment rate γ (Fig. 11) and social inhibition rate ρ (Fig. 12) are varied. The general trends observed in Fig. 6b,c are preserved. For strong enough abandonment γ, adaptivity λ increases asū decreasing, and direct switching tends to balances this trade off best (Fig. 11). Indiscriminate stop-signaling presents a similar trade off as social inhibition strength ρ is increased (Fig. 12), while the other social inhibition mechanisms eventually show increases in both consensusū and adaptivity λ, but again direct switching tends to provide higher levels of both overall.

C.5 Stochastic effects in the finite system size
Honeybee swarms tend to be of modest size (in the 1,000s) [6], and so it is reasonable to expect some impact of finite size effect on the dynamics of foraging. In general, we found finite size effects induced fluctuations about the typical mean periodic switching solutions, but that it did not qualitatively alter the general behavior of the swarm (Fig. 13). The finite size model is governed by a master equation, determining the probability of all possible changes in committed and uncommitted populations. In the case of the single feeder model, the master equation for the probability p(n, t) of finding n bees committed to foraging at time t iṡ p(n, t) = r + (n − 1)p(n − 1, t) + r − (n + 1)p(n + 1, t) − [r + (n) + r − (n)] p(n, t), for integer n = 0, 1, 2, ..., N with boundary conditions p(−1, t) = p(N + 1, t) = 0 and forward and backward transition rates r + (n) = (N − n)(α(t) +βn), r − (n) =γn +ρ(ᾱ −α(t − τ ))n 2 for system size (total bee number) N . To obtain the mean field Eq. (3) as N → ∞ [9, 27], one must defineα(t) = α(t)/N ,β = β/N 2 ,γ = γ/N , andρ = ρ/N 2 . Note, the scalings correspond to the power of the population count appearing in the interaction term, ensuring the transition terms remain bounded in the thermodynamic limit. We utilized the stochastic simulation algorithm by Gillespie [59] to evolve the stochastic system for the statistic plotted in Fig. 13a,b. We make two remarks about our findings. First, the swarm generally increases the fraction of committed foragers when food is present at the feeder and decreases when food is removed. Second, the amplitude of fluctuations in individual simulations decreases with system size, as typically expected [27], as evidenced by the narrower standard deviations in the solution trajectories in the N = 1000 versus the N = 100 simulations.
In the case of the two feeder model, the master equation is more complicated as it must track the probability of transitions between uncommitted bees, bees committed to feeder A, and those committed to feeder B. Indeed, we can write the model down for any of the four forms of social inhibition, but we just provide the discriminate stop signaling model here. Others can be written similarly. The probability p(n A , n B , t) of finding n A bees committed to A and n B committed to B at time t given system size N is (dropping the argument in t for brevity): p(n A , n B ) =r 0A (n A − 1, n B )p(n A − 1, n B ) + r 0B (n A , n B − 1) + r A0 (n A + 1, n B ) (18) + r B0 (n A , n B + 1)p(n A , n B + 1) − [r 0A (n A , n B ) + r 0B (n A , n B )+ +r A0 (n A , n B ) + r B0 (n A , n B )] p(n A , n B ), for n A , n B = 0, 1, ..., N with the condition that n A + n B ≤ N , boundary conditions p(−1, n B ) = p(n A , −1) = p(N + 1, n B ) = p(n A , N + 1) = 0, and transition rates As in the single feeder model, periodic switching with environmental switches is apparent, and the amplitude of fluctuations decreases with system size (Fig. 13c,d).
A detailed study of the finite size population model would require a much more thorough treatment and statistical analysis. We expect the effects of stochasticity will not considerably impact our general findings. The only qualitative differences we would expect would be in the case of unrealistically small systems (e.g., N = 10), and in bistable systems (like cases of the discriminate stop signaling model), where fluctuations could drive switching between multiple stable equilibria [56].