The evolutionary dynamics of plastic foraging and its ecological 1 consequences: a resource-consumer model.

4 Phenotypic plasticity has important ecological and evolutionary consequences. In particular, be-5 havioural phenotypic plasticity such as plastic foraging (PF) by consumers, may enhance community 6 stability. Yet little is known about the ecological conditions that favor the evolution of PF, and how 7 the evolutionary dynamics of PF may modulate its eﬀects on community stability. In order to address 8 these questions, we constructed an eco-evolutionary model in which resource and consumer niche traits 9 underwent evolutionary diversiﬁcation. Consumers could either forage randomly, only as a function 10 of resources abundance, or plastically, as a function of resource abundance, suitability and consump-11


Introduction
Phenotypic plasticity has become central to evolutionary theory (West-Eberhard, 2003;Pfennig, 2021), but the interplay between its evolutionary dynamics and ecological consequences remains underexplored.Such an interplay occurs when a variety of resources are available to consumers investing more or less time on each resource according to its suitability, which depends on the (mis)match between the resources' defensive and consumers' counter-defensive traits (e.g.Clissold et al., 2009) and the nutritional quality of the resources and the requirements of the consumers (e.g.Behmer and Joern, 2008).The relative time spent on each resource (relative foraging efforts, sensu Abrams, 2010) sometimes corresponds to the best compromise between suitability and abundance, an outcome called optimal foraging (MacArthur and Pianka, 1966;Loeuille, 2010).However optimal foraging might be difficult to achieve when the identity and abundance of resources vary over time and space, because foraging optimization is not instantaneous (Abrams, 1992(Abrams, , 2010)).Under such circumstances, consumers may nevertheless redirect their relative foraging efforts towards more profitable resources in order to increase their energy intake.The ability to adjust relative foraging efforts is a type of behavioural plasticity which has been called adaptive foraging in the literature (Valdovinos et al., 2013;Loeuille, 2010).However, this term can be misleading because "adaptive" generally refers to traits shaped by natural selection.Here, the term plastic foraging (PF) will be used for clarity, moreover because its evolutionary dynamics will be explored.Indeed, phenotypic plasticity often results from evolution by natural selection (Nussey et al., 2005;Peluc et al., 2008;Van Kleunen and Fischer, 2001).In particular, phenotypic plasticity may help populations to cope with environmental changes (Chevin et al., 2013;Vedder et al., 2013;Charmantier et al., 2008), although empirical evidence is sometimes questionable (Merilä and Hendry, 2014).From a theoretical point of view, the extent to which phenotypic plasticity is adaptive has not been tested in the context of PF because previous works ignored the evolutionary dynamics of PF, focusing instead on food-web stability (Kondoh, 2003;Uchida and Drossel, 2007;Heckmann et al., 2012) or food web structure (Beckerman et al., 2006).Abrams (2003) modelled the evolution of the general foraging effort, corresponding to the overall amount of time and energy invested in foraging (e.g.Dill, 1983), in function of the trade-off with predation risk.General foraging effort differs from PF, that in contrast focuses on the adjustment of relative foraging efforts, i.e. how the general foraging effort is distributed across the different resources.Although the PF strategy tends to increase fitness, in some situations PF may reduce it increases energy intake, it may also be costly, e.g. by increasing predation risk (Abrams, 2003;Pangle et al., 2012;Wang et al., 2013;McArthur et al., 2014;Costa et al., 2019), preventing efficient thermoregulation (du Plessis et al., 2012;Van de Ven et al., 2019) or increasing searching time for resources (Randolph and Cameron, 2001;Bergman et al., 2001;Fortin et al., 2004).Since PF faces several trade-offs with life-history components, its evolution should depend on ecological parameters such as mortality rate, resource searching time or consumer niche width.
The first aim of the present study is therefore to understand, using a theoretical model, under which ecological conditions the ability of consumers to forage plastically is subject to evolution by natural selection.In short: is plastic foraging adaptive?We define PF as a change in relative foraging efforts that directly increases energy intake, but not necessarily fitness.This contrasts with Loeuille (2010) who defined adaptive foraging as "changes in resource or patch exploitation by consumers that give the consumer a higher fitness compared with conspecifics that exhibit alternative strategies".Our restricted definition is justified by the need to explore how the trade-off between energy intake and other life-history components modulates the evolution of PF.Moreover, consumers are affected by environmental changes, either directly (Bale et al., 2002;Staley and Johnson, 2008;Scherber et al., 2013) or indirectly through changes affecting their resources.For instance, environmental changes may induce a shift in resource phenology (Altermatt, 2010;Kerby et al., 2012;Portalier et al.) or alter resource chemistry (Bidart-Bouzat and Imeh-Nathaniel, 2008;Rasmann and Pellissier, 2015).
As a result, the diet preferences of consumers may be altered (Rasmann et al., 2014;Rosenblatt and Schmitz, 2016;Boersma et al., 2016), suggesting that environmental disturbances should lead to the evolution of PF.However as disturbances may also reduce the functional diversity of available resources (Thuiller et al., 2006;Buisson et al., 2013), the evolutionary response of the PF strategy to environmental changes is unclear.
Although phenotypic plasticity generally results from evolution by natural selection, as outlined above, it also generates evolutionary changes (Simpson, 1953;Baldwin, 1896;Laland et al., 2014), with genes acting as followers (West-Eberhard, 2003).In the context of PF, the consumption of novel or unusual resources through behavioral plasticity might trigger subsequent adaptations that favour the use of these resources.This would increase the diversity of the traits involved in resource use, such as counter-defences and nutritional requirements.The second motivation is therefore to investigate how PF can alter the evolution of these consumer traits, as well as those of their resources (defenses, nutritional quality).In particular, we expect PF to affect the functional diversity of consumers and resources, through its effects on diet breadth.
The evolutionary dynamics of phenotypic plasticity has important ecological consequences (Miner et al., 2005;Turcotte and Levine, 2016), which in turn can feed back into the evolutionary dynamics.
In the case of PF, behavioural plasticity in diet choice can favour the persistence of consumers in unusual environments and rescue them in the face of environmental changes (e.g.Varner and Dearing, 2014;Kowalczyk et al., 2019).Previous theoretical studies have indeed shown that PF promotes community stability (Křivan and Schmitz, 2003;Abrams and Matsuda, 2004;Kondoh, 2003;Uchida and Drossel, 2007).The third motivation is to test if this positive relationship holds when both PF and the functional traits of consumers and resources are subject to evolutionary dynamics.In this eco-evolutionary context, it is uncertain whether the evolution of PF stabilises communities directly, by altering food-web structure or indirectly, through its effects on functional diversity.
The main questions outlined earlier are sketched in Figure 1: • Question 1.Under which ecological conditions is PF evolutionary adaptive?
• Question 2. When PF evolves, what are its effects on the diversity of the traits involved in the resource-consumer interaction?
• Question 3. What is the effect of the evolution of PF on the stability of the resource-consumer system, in response to environmental changes?Are these effects direct (Q3a) or indirect, mediated by the influence of PF on functional diversity (Q3b)?
To address these issues, we build an eco-evolutionary model in which a consumer species feeds on a resource species.Both species are characterized by an ecological trait; the resource is the most suitable for the consumer when both traits match.In addition, the consumers carry a foraging trait measuring the extent to which they select the resources allowing the largest intake, or instead forage randomly and consume the resources as a function of their abundance.Ecological and foraging traits are subject to evolution; starting from monomorphic initial conditions, they rapidly diversify and reach a stationary regime characterized by a stable diversity of ecological and foraging traits.The stationary regime is then subjected to various environmental disturbances, to test how the evolution of PF responds to environmental changes, and how this cascades down on the ecological properties of the resource-consumer system.

Diversity Stability indirect effect
Adaptive Foraging evolution direct effect

Q3a
Perturbations Figure 1: Overview of the main questions: (Q1) Under which ecological conditions does PF evolve?(Q2) Does the evolution of PF increases the diversity of traits involved in the resource-consumer interaction?(Q3) Does the evolution of PF enhances the stability of the resource-consumer system, either directly (Q3a) or through its effects on functional diversity (Q3b)?
2 Model description

A resource-consumer niche model
An eco-evolutionary model is developed to describe the dynamics of a consumer population feeding, with various individual foraging strategies, on a resource population.Consumers compete for resources both directly and indirectly.Individuals are characterized by quantitative traits: the niche traits x and y of consumers and resources, respectively, and the plastic foraging trait z of consumers.The niche traits affect competition between individuals as well as interactions between consumer and resource individuals.The foraging trait z affects the foraging strategy of the consumers through their foraging efforts φ.The model describes the time dynamics of the trait densities of resources R(t, y) and consumers C(t, x, z); the components of the model are detailed in the following sections.
mortality and competition niche and PF traits mutations (2) Resource growth and niche trait.In the absence of consumers, resources grow logistically with an intrinsic rate g, independent from the niche trait y, and a carrying capacity that depends on the difference between the niche trait y and the optimal niche trait y 0 .Competition between resources depends on the niche trait y through the carrying capacity K(y − y 0 ) of individuals with trait y and r e (t, y), the effective population density perceived by an individual with trait y at time t.Resource consumption and absorption.In the presence of consumers, resources are exploited at rate F R , whereas the consumer density increases through resource absorption at a rate F C .On the one hand, these rates depend on the consumers foraging efforts φ(t, x, y, z), which characterize the time spent by a consumer of niche trait x and foraging trait z on a resource of trait y during a period t.On the other hand, they vary with the effective interaction strength ∆(x, y) between consumer and resource individuals.The function ∆ is normally distributed around 0 with a variance σ, which measures the extend to which consumers can deal with a variety of resource types (Table SI.1).The variance parameter σ is chosen similarly to previous models (see e.g.Dieckmann and Doebeli, 1999;Egas et al., 2005), but it is not subject to evolution as in Egas et al. (2005).The interactions are described by a Holling type II functional response, which provides the following consumption and absorption rates: where the integrals correspond to the total biomass of consumer.
Mutation of traits and diffusion approximation.Due to mutations, the niche traits and the foraging trait can evolve independently.Foraging behaviour can indeed be heritable in nature (Wallin, 1988;Lemon, 1993).Since ecological and evolutionary dynamics occur on the same time scale, mutants are constantly introduced through the diffusion of traits: where µ is the mutation frequency and σ 2 m is the variance of the mutational effects.This approach contrasts with the adaptive dynamic framework, in which a mutant phenotype is introduced sequentially and persists only if its invasive fitness is positive (Geritz et al., 1998).
2.2 Foraging strategies and plastic foraging trait.
Consumers can use two different foraging strategies during their foraging time: Random Foraging (RF) or Plastic Foraging (PF).The effective consumer foraging strategy depends on the consumer plastic foraging trait z ∈ [0, 1], which corresponds to the proportion of its general foraging effort spent using the PF strategy.The effective consumer efforts are thus: where φ P F and φ RF are the foraging efforts resulting respectively from the plastic foraging strategy and the random strategy.
Random foraging strategy.When using RF, the consumer randomly forages its environment without selecting resources.The resulting efforts φ RF is proportional to the density of the resources: Plastic foraging strategy.Conversely, when using PF, consumers actively search for resources, that maximize their energy intake.More precisely, they modify their foraging efforts according to the potential resource uptake u, that corresponds to the amount of resource taken by the consumer, if its foraging effort only focus on this resource.It depends on the resource availability and suitability (e.g.Sundell et al., 2003).A consumer will reduce its effort on a resource if the uptake from that resource is lower than the uptake from an other resource, that is if the difference between potential resource uptakes is negative.The resulting relative foraging efforts φ P F may change over time according to the average difference between resource uptake, weighted by the foraging effort per resource and the amount of resource as follows: where [u(y) − u(y )] + = max (u(y) − u(y )), 0 is the positive part of the difference between potential resource uptake.The quantity φ P F is analogous to the behavioral trait z in Abrams and Matsuda (2004).The potential resource uptake u(t, x, y, z) of a consumer with traits (x, z) on a resource with trait y depends on its foraging efforts as well as the resource suitability and availability: The PF dynamics allow consumers to compare the benefits u received from different resources.More precisely, for a given resource y and a given consumer with traits x and z, if the benefits u(t, x, y, z) from the resource y is larger than the benefit u(t, x, y , z) from the resource y , that is [u(t, x, y, z) − u(t, x, y , z)] + > 0, then the consumer will gain benefits by increasing its effort on resource y.Conversely, it will gain benefits by decreasing its effort on resource y .Eq. ( 11) reflects the balance between the positive effects [u(t, x, y, z) − u(t, x, y , z)] + > 0 to increase the effort on resource y and the negative effects −[u(t, x, y , z) − u(t, x, y, z)] + < 0, to do it.As a result, consumers increase their efforts on the most beneficial resources and reduce them on sub-optimal resources.The comparison of resources is assumed time consuming.The efforts are therefore not adjusted instantaneously but exponentially fast at a rate that is proportional to the density of consumer C, with similar trait x and z, accounting for the use of social cues during foraging (Jones et al., 2018), and an intrinsic adjustment rate l φ .When the intrinsic adjustment rate l φ becomes large, the plastic foraging strategy becomes closer to the optimal foraging strategy maximizing the potential resource uptake u (MacArthur and , 1966;Loeuille, 2010).Moreover, the searching time s(z) also increases with the foraging trait:

Pianka
This relationship introduces a trade-off between the PF strategy and the searching time.

The evolution of plastic foraging
Previous models exploring the effect of PF on community dynamics assumed that PF was a fixed trait of equal intensity for all consumers (Kondoh, 2003;Uchida and Drossel, 2007;Beckerman et al., 2010;Heckmann et al., 2012;Valdovinos et al., 2013).In these models, the foraging efforts of consumers changed in function of the availability and suitability of their resources, but whether foraging efforts could change or not was itself not subject to evolution.Egas et al. (2005) modelled the evolutionary dynamics of the consumers' niche width, but not of their foraging selectivity.Therefore, the first motivation of this study was to explore under which conditions the capacity to forage plastically can evolve by natural selection (Question 1 in the introduction).

Diversification and emerging foraging strategy
The model is investigated numerically using MATLAB.The niche traits are discretized into 31 equally distanced values (11 values for the foraging trait).In the simulations, when the density of a resource or a consumer phenotype drops below the critical threshold ε = 10 −4 , the density is set to 0 to save computational time.The simulations start with monomorphic populations at the niche center (y = x = 0) and consumers have a purely random foraging strategy (z = 0).
Given the parameter ranges of Table 1, the eco-evolutionary dynamics of the model lead to the diversification of resources and consumers along the ecological gradient (Figure 2a).Although the distribution of the consumer foraging trait reaches a unimodal distribution (Figure 2a), the consumers positioned at the niche center forage randomly, while those at the niche edges forage plastically (Figure 2b).Indeed, scarce resources located at the niche edge are consumed significantly by plastic foragers only, because random foragers cannot choose infrequent resources.Instead, abundant resources located at the niche center can be consumed in large amounts by random foragers.This model prediction calls for empirical testing, as we are not aware of any existing work reporting this pattern.In addition, the distributions of the niche traits reach a stationary regime that vary over time due to the PF strategy (Appendix A.1). Table 1: Parameters of the model with their reference values used for the analysis of the response to disturbances, and the range used for the 6 parameters tested by the sensitivity analysis.The last column corresponds to the PRCC values, that is the correlation between the mean foraging trait z(t) and the tested parameter.

Parameters influencing the evolution of plastic foraging strategy
To investigate the ecological conditions leading to the evolution of PF, a global sensitivity analysis is performed using Partial Rank Correlations Coefficients (PRCC, Saltelli et al., 2004), on the mean foraging trait value of the consumer population z(t) defined by: The analysis focuses on the parameters σ, σ K , s max , d, I, g (Table 1) with 5000 parameter sets sampled in their ranges.
The PRCC analysis revealed that the six tested parameters played a significant role in the evolution of PF (Table 1

last column).
Handling time As expected, elevated costs of PF (S max , Table 1) disfavor its evolution (correlation coefficient −0.64), which is in accordance with the existence of a trade-off between PF and other lifehistory traits like predation (Pangle et al., 2012;Wang et al., 2013;McArthur et al., 2014;Costa et al., 2019), thermoregulation (du Plessis et al., 2012;Van de Ven et al., 2019) and time budget (Randolph and Cameron, 2001;Fortin et al., 2004).Consumer niche width The evolution of PF is instead favored by the niche width of consumers (parameter σ, correlation coefficient 0.28).The evolution of plastic foraging may lead to contrasting foraging strategies among individuals, which increases inter-individual niche variation.This would then fit with the "Niche Variation Hypothesis" (NVH) according to which "populations with wider niches are more variable than populations with narrower niches" (Soule and Stewart, 1970).The NVH was initially formulated by Leigh van Valen 1965 for morphological traits, although it appears better suited to behavioral traits like resource use (Bolnick et al., 2007).Empirical support for the NVH was found for herbivores (Bison et al., 2015) and predators (Bolnick et al., 2007), with a positive correlation between total niche width and inter-individual niche variation.Inter-individual niche variation reflects the existence of contrasting foraging strategies, which may be the result of plastic foraging.
Baboons also combine niche breadth with selectivity in resource use (Whiten et al., 1991).Since the evolution of consumer niche width may itself depend on environmental heterogeneity (Kassen, 2002) (i.e. on resource diversity in the model), the coevolution of PF, niche width and niche position is a possible avenue for future research.Niche width foster PF because consumers deplete the whole range of resources when their niche width is large, therefore competition between consumers is more intense, which leads to the evolution of PF.Empirical studies have indeed found that generalist consumers competing for resources forage plastically.For instance generalist bumblebee species visited the larkspur Delphinium barbeyi when the most abundant bumblebee species was experimentally removed, but preferred other plant species otherwise, likely to avoid competition for nectar (Brosi and Briggs, 2013).A similar behavior has been reported for syrphid flies, which preferentially foraged on open rather than tubular flowers when competing with bumblebees (Fontaine et al., 2006).In the case of predators, intraspecific competition between sticklebacks (Gasterosteus aculeatus) enhanced the diversity of foraging behaviors and increased the correlation between diet and morphology (Svanbäck and Bolnick, 2007), as found here (Figure SI.9).
Other parameters The present model further predicts that PF evolution is favoured by direct competition between consumers I (correlation coefficient 0.13) as well as by increased consumer mortality δ (correlation coefficient 0.13).This is in line with the above results, in the sense that constrained environmental condition for consumers strengthen the need for PF.On the other hand PF becomes useful when resources are diversified enough, hence the positive effect of the resources niche width σ K (correlation coefficient 0.38).

The effects of PF evolution on community properties
Starting from a fixed pool of species or phenotypes, most previous theoretical works have shown that PF fosters food web complexity and community stability (Kondoh, 2003;Uchida and Drossel, 2007;Beckerman et al., 2010;Heckmann et al., 2012), although this depended on the way PF was incorporated to the model (Berec et al., 2010).However, had niche traits been also subject to evolution, PF might also have affected stability indirectly, through its effect on functional diversity (Figure 1).
The effects of PF on diversity and other community properties (Question 2 in the introduction) are discussed in the present section and the effects on consumer persistence (Question 3) in section 5.

Effects on biomass
To assess the effects of the evolution of PF on biomass, we compare the total biomass C of consumers in two situations: a freely evolving PF trait z and a fixed RF strategy (z = 0).In both cases, the ecological niche traits x and y are subject to evolution.The communities evolve during 1000 time steps, which is enough time for the system to reach a stationary regime with stable community-level characteristics (A.1).The same comparison is done for all the other community properties.
When the evolution of PF produce consumer populations with a high mean foraging trait z, the resource biomass is reduced (e.g.-50% when z = 1) while the consumer biomass increased by 25% on average (Figure 3a).Following the evolution of PF, the functional complementarity and diversity of consumers increase their biomass at the expense of resources (Figure 3a).This fits with empirical studies showing a relationship between resource consumption and consumer diversity (Deraison et al., 2015;Lefcheck et al., 2019;Milotić et al., 2019).However, the variability of the consumer biomass among simulations also increases with z.This pattern has also been observed when the foraging trait z of a monomorphic population without PF evolution is increased (Figure SI.3a).

Effects on functional diversity
Resource and consumer functional diversity are measured by the functional dispersion index F Dis (Laliberté and Legendre, 2010), which represents for each population the average absolute deviation from the mean niche trait: The evolution of PF increases functional dispersion of both resources and consumers (Figure 3b).
When the average foraging trait value is large the consequences on diversity indices becomes heterogeneous, but the effect of PF is almost always positive.The increase in functional diversity is due to an eco-evolutionary loop between resources and consumers situated at the niche edge.Following the evolution of PF some consumers forage at the niche edge, thereby reducing the density of the corresponding resources.This decreases competition among these resources and promotes the emergence of new resource phenotypes at the niche edge.The diversification of resources triggered the apparition of consumers standing even further away from the niche centre, and so on until the resources reached the limits of the exploitable niche.This emphasizes that adaptive phenotypic plasticity like PF can subsequently fuel evolutionary change (Baldwin, 1896;Crispo, 2007;Laland et al., 2014).Instead, when no PF evolution is introduced, the few resources standing far away from the niche centre are barely used by consumers, which can not forage preferentially on them.This prevents the emergence of new resources further away from the niche centre, due to competition between resources.Since the evolution of PF occurs when the diversity of resources is initially large enough (large σ K ), causation is reciprocal: PF both promotes and is promoted by resource diversity.

Effects on productivity
Productivity corresponds to the net production of biomass by consumers following resource absorption, measured once the system has reached a stationary regime (e.g.Loreau and Hector, 2001;Poisot et al., 2013): T is the time to reach the stationary regime, T = 1000 in the simulations below.
The relationship with productivity (i.e the flow of biomass from resources to consumers) is nonlinear (Figure 3c).When the system with PF evolution has a rather low mean foraging trait (0 < z < 0.4) productivity increases in comparison to the system without PF.This occurs thanks to functional complementarity between consumers (Poisot et al., 2013).However, when z is above 0.4, the productivity gain does not change on average, because consumers with high foraging trait impact resources too heavily.Strong PF also increases the variability of productivity; among the systems with strong PF some have large gains of productivity and others small gains or even small deficits.

Effects on niche overlap and functional match
The niche overlap between two consumers with niche traits x i and x j and foraging traits z i and z j is defined by the correlation coefficient ρ ij of their resource absorption: The overall niche overlap between consumers ρ is the average of this correlation coefficient of all consumers (Chesson and Kuang, 2008).The functional match F M corresponds to the mean difference between the niche trait of the consumer and the mean niche trait of its diet, that is the resources absorbed by the consumer: where diet(t, x, z) = y φ(t, x, y, z)u(t, x, y, z) φ u(t, x, y, z)dy dy (17) The evolution of PF also decreases the niche overlap between consumers by about 90% as soon as the mean foraging trait exceeds 0.230% when the mean foraging trait is close to 1 (Figure 3d), and increases the functional match between the niche trait of consumers and the mean niche trait of their  2006) and Brosi and Briggs (2013).At the intraspecific level, niche overlap between individuals of the same species decreased in function of their abundance (Svanbäck and Bolnick, 2007;Tur et al., 2014).Short-term experimental time scales suggest this pattern was caused by plastic behavior (Svanbäck and Bolnick, 2007), although in the long-term this pattern may also be due to genetic diversification.Since abundance favors intraspecific competition, this is consistent with our findings that competition between consumers promotes the evolution of PF.The decrease of niche overlap between consumers corresponds to niche partitioning, which may favor their coexistence (Behmer and Joern, 2008;Turcotte and Levine, 2016).For each panel, 1500 simulations of 1000 time steps with PF evolution were compared to simulations with fixed RF, the parameters being randomly sampled in the ranges specified in Table 1.Dashed lines: median; areas: 75% confidence intervals.

The effects of PF on consumer persistence
To understand whether the evolution of PF can rescue consumers from environmental changes, three specific disturbances are considered: a sudden environmental change where the mode y 0 center of the resource niche is instantaneously shifted at a distance ∆y from the initial niche center, y 0 + ∆y (e.g.Domínguez-García et al., 2019), an ecosystem disturbance where consumer mortality d increases gradually by ∆d, and a constantly changing environment, where the mode y 0 of the niche is displaced at constant speed c, y 0 + ct.The mutation process driving the diversification of resources and consumers in the system should help to recover trait diversity after a disturbance.To assess the effects of those disturbances on the resource-consumer system, the proportion of consumer biomass lost after the dis-turbance is calculated once a new equilibrium is reached.The difference in the mean foraging trait before and after each disturbance is also measured.
Before the perturbation, we start with a resource-consumer system at equilibrium for each system: with PF evolution and with fixed RF, that is the foraging trait of consumers is monomorphic (z = 0) and does not evolve (∂ 2 z C = 0).In the system with PF evolution, the mean PF trait is stabilized around a high value, z ≈ 0.9, with the parameters set in Table 1.The resource-consumer system is initialized with consumers carrying a high mean PF trait (z ≈ 0.9 with parameter values set as in Table 1).For each disturbance strength and type, we wait until a new equilibrium is reached.
The stability metrics of the system with PF evolution is compared to those of the system with fixed RF at this new equilibrium., in which the foraging trait of consumers is monomorphic (z = 0) and fixed (∂ 2 z C = 0).For all disturbance types, the disturbance strength is increased until the consumer population goes to extinction, in order to compute the maximal disturbance level that the system can tolerate.Monomorphic systems for different foraging trait values are also initialized to test their response to disturbances.

Ecosystem disturbance and constant environmental change
In reaction to increasing levels of consumer mortality, the system with PF evolution behaves as the system with fixed RF.Indeed, after each increment of mortality the new biomass of consumers is similar; and the consumers disappear for the same mortality rate (Figure 4a).Moreover, at each mortality increase, consumers in the system with PF evolution gradually reduce their foraging trait, until PF ultimately disappears (color scale in Figure 4a).Indeed, increased mortality leads to reduced competition between consumers via their reduced density, and to the non-viability of the niche edge for consumers, both leading to a reduction in PF trait.Controlled monomorphic systems having low PF values better tolerate higher mortality rates (Figure 4b), which indicates that when PF is fixed it has a negative effect on the persistence of consumers facing increases in mortality.
Turning to the constant environmental change, the system with PF evolution tolerates niche displacement better than the system with fixed RF, up to a certain point when it disappears suddenly, earlier than its counterpart (Figure 4c).Moreover, as in the case of ecosystem disturbance, the mean PF value decreases for faster environmental changes (color scale in Figure 4c).Controlled monomorphic systems having low PF values tolerate faster environmental changes (Figure 4d), which indicates that when PF is fixed it has a negative effect on the persistence of consumers facing constant environmental change.
For both disturbances the cost of PF becomes larger than the benefits, and choosy consumers go extinct earlier than random consumers.In particular, constant environmental changes weathers resource diversity to such a point that RF and PF consumers have a similar diet, which annihilates the benefits of PF.It has been stressed that phenotypic plasticity can retard adaptation to environmental change, shielding suboptimal phenotypes from natural selection (Fox et al., 2019), but in the present model phenotypic plasticity is limited to the foraging strategy of consumers.Instead, niche traits are not plastic and are therefore entirely sensitive to selection; the negative effect of PF on consumer persistence is therefore only due to its cost.In nature however, niche trait can also be plastic (e.g.Rossiter, 1987), but this was ignored by the model.
In figures 4b and d PF is fixed, but when PF can evolve, it gradually decreases in function of the intensity of the disturbances (see color scales in Figures 4 a and c), although for different reasons.In the case of ecosystem disturbance, plastic foragers located at the edge of the niche trait distribution (Figure 2b) disappear progressively due to increases in mortality.The average PF trait therefore decreases (Figure 4a) due to demographic changes of a pre-existing trait diversity.In the case of a constant environmental change, however, the typical trait distribution depicted in Figure 2b no longer exists because niche traits constantly run after those of resources, which corresponds to an evolutionary lag load.In that case, consumers do not have enough time to reduce their PF searching behaviour and become extinct slightly earlier (Figure 4c); PF therefore imposes a second lag load, corresponding to the time needed for the evolutionary regression of PF.
A purely ecological model ignoring the evolutionary dynamics of PF would have missed the possibility of its evolutionary regression, and would have therefore overestimated the negative effect of PF on consumer persistence.In the simulations, the various disturbance types have been applied independently, but in nature they can be combined.In such cases, ecosystem disturbance and/or constant environmental change might first lead to the evolutionary regression of the PF behaviour, and a sudden shift might then facilitate the extinction of consumers, since they would not be protected by PF any more.

Sudden environmental change
After a sudden environmental change, either consumers disappear or they persist in a new state close to the original one.In that case their niche traits shift towards the new optimum and their foraging traits remain unchanged, which is an indication of resilience.The variation of biomass before and after disturbance is therefore uninformative; instead the maximal sudden environmental change that the consumer can tolerate is used to quantify its stability (Figure 4e).The system with PF evolution resists to a larger sudden change (δ y = 10) compared with the system with fixed RF (δ y = 8).In order to disentangle the direct effect of PF on stability from its indirect effect through diversity, the PF values of the consumers with PF are set to 0, while retaining the original diversity of the niche traits x and y of both guilds.The resulting hybrid system tolerates a large environmental change (δ y = 10), which indicates that the positive effect of PF on the persistence of consumers is mainly due to its effects on diversity.In line with the above results, controlled monomorphic systems having high PF values tolerates larger sudden environmental changes (Figure 4d).
Previous theoretical studies have shown that PF can stabilize food-webs by favoring topologies able to buffer environmental disturbances (Kondoh, 2003;Heckmann et al., 2012), but in the present model such inherently robust topologies have not been observed.Instead, the mechanisms responsible for the stabilising effect of PF rely on the dynamical nature of the interaction webs produced by PF, which is caused both by a direct effect of PF (Question 3a), and by an indirect effect through diversity (Question 3b), as detailed above.The direct effect of PF on consumer persistence relies on the mitigation of the lag load faced by consumers.Indeed, resources become adapted to the new niche center more quickly than consumers, which suffer from a trait mismatch (e.g.Post and Forchhammer, 2008;Miller-Struttmann et al., 2015;Damien and Tougeron, 2019).This indicates that phenotypic plasticity acts as a rapid response mechanism to environmental change (Fox et al., 2019), in that case.Since random foragers consume the most abundant resources (but not the most suitable), after a sudden niche shift they feed on sub-optimal resources, which hamper their resilience to environmental change.In contrast plastic foragers select less abundant but more suitable resources, which favor their survival.In the meantime their traits evolve towards the new niche optimum and ultimately catch up the resources, which illustrates that adaptive plasticity can promote persistence in new environmental conditions (Ghalambor et al., 2007).
Turning to the indirect effect of PF on consumer persistence (Question 3b), when PF increases the diversity of both resources and consumers this favors the emergence of extreme phenotypes far away from the niche center.The extreme phenotypes are pre-adapted to the niche shift and therefore persist, unlike the central species.The positive effect of biodiversity on ecosystem functioning can be caused by complementarity and selection effects (e.g.Loreau and Hector, 2001).In the present case, a few well-adapted phenotypes determine the resilience to the niche shift : this corresponds to a selection effect.Although PF also increases complementarity between species as discussed earlier, this do not create any synergy between phenotypes, at least with respect to the resilience to the niche shift.
In summary, consumer persistence is fostered either by the evolution of PF in the case of a sudden environmental change or by its regression in the cases of ecosystem disturbance and constant environmental change.This corresponds to a combination of evolutionary rescue (Gonzalez et al., 2013;Kopp and Matuszewski, 2014), because PF is subject to evolution, and of plastic rescue (Kovach-Orr and Fussmann, 2013), since PF is a type of phenotypic plasticity.

Assumptions and limitations of the model
As outlined earlier, compared with other existing models exploring the influence of PF on community stability, the main novelty of the model is to study the evolution of the propensity to forage plastically, together with the evolution of niche traits of resources and consumers.Several other specificities also require some consideration.
First, in previous works the absence of PF corresponded to a constant interaction matrix between resources and consumers (e.g.Kondoh, 2003;Valdovinos et al., 2013).Instead, in the present model the alternative to plastic foraging consists in random foraging, where resources are consumed according to their density.The interaction matrix is therefore highly dynamic for both foraging strategies, although for different reasons.In the case of RF the resources exploited by a given consumer change according to their abundance only, whereas in the case of PF they also change according to their traits, the consumer's trait, and their degree of exploitation by other consumers.In previous models allowing the evolutionary diversification of niche traits, the interaction matrices were dynamic but consumers did not forage plastically (Loeuille and Loreau, 2005;Allhoff et al., 2015).In those cases as well as here, new phenotypes constantly appear and need to be incorporated into the food web, which is therefore inherently dynamic (Appendix A.1).In comparison to RF, a consumer having fixed interaction coefficients would ignore these new phenotypes even if its favorite resources had gone extinct, which would make little sense.Besides, PF alone can produce non-equilibrium dynamics even with a fixed community composition, by triggering consumer-resource cycles (Abrams, 1992;Abrams and Matsuda, 2004).
Second, it is assumed that consumers feeding on a single optimal resource have the highest growth rate.Although this assumption often fits with prey-predator interactions (but see Jensen et al., 2012, for a counter-example), in the case of plant-herbivore interactions consumers often benefit from resource complementarity (Abrams, 2010;Unsicker et al., 2008), primarily because of nutrient balancing and toxin dilution (Ibanez et al., 2012;Behmer and Joern, 2008;Singer et al., 2002).We predict that the inclusion of this feature in the model would have favored the evolution of PF, since RF strategists mostly consume the most abundant resources, irrespective of their complementarity.
Third, foraging costs (quantified by the searching time s(z)) were assumed independent of resource abundance, although the searching time may be larger for rare than for abundant resources.Moreover, the spatial distribution of resources is ignored, although travel time is costly (WallisDeVries, 1996;Hassell and Southwood, 1978).For instance, the random distribution of low preferred plant species can disfavor herbivore foraging selectivity (Wang et al., 2010).These two factors may hamper the evolution of PF.
Finally, the competition kernel modelling the strength of competition between resources and the carrying capacity functions were both assumed Gaussian.Under this hypothesis and in the absence of consumers, the evolutionary dynamics produce a continuum of resources (MacArthur, 1970;Slatkin and Lande, 1976).There are however many deviations from this special case, by choosing for instance non Gaussian competition kernels or carrying capacity functions, which leads to a discrete distribution of resources (Sasaki and Ellner, 1995;Szabó and Meszéna, 2006;Pigolotti et al., 2010;Hernández-García et al., 2009;Sasaki and Dieckmann, 2011).The presence of consumers using PF also results in a discrete distribution of resources, either with Gaussian functions (Fig. 2) or with a quartic function, which was instead used in Appendix C. Platykurtic functions like the quartic function tend to broaden the resource distribution (Sasaki and Dieckmann, 2011).Under the quartic scenario, the resource distribution is indeed enlarged and the mean foraging trait is larger (compare Fig. 2

Conclusion
The present model illustrates how phenotypic plasticity can be simultaneously a result and a factor of evolution.On the one hand, plastic foraging (PF) evolves by natural selection acting on consumers.
On the other hand, it stimulates the diversification of ecological characters not only of consumers but also of resources, stressing that phenotypic plasticity can have far-reaching evolutionary consequences at the community-level (Fordyce, 2006).Moreover, functional diversity itself promotes the evolution of PF, creating an eco-evolutionary feedback loop between phenotypic plasticity, natural selection and community composition.This has intricate consequences on the response of the resource-consumer community to disturbances.In the case of sudden environmental change, the evolution of PF has a positive effect on community stability, partly via its effects on functional diversity.However for other disturbance types like constant change and increases in mortality, the PF behavior is less fit than random foraging and therefore declines.In contrast to previous studies, these results stress that the relationship between PF and community stability depends on the type of the disturbance as well as on the evolutionary dynamics of PF itself.

Appendix
A Model details  Table SI.1:List of the quantitative traits subject to evolutionary change, the state variables, the functions and the aggregate system-level properties involved the model.

A.1 Stationary regime
The stationary regime is visible in this simulation of the emergence of a community in which plastic foraging evolves: https://drive.google.com/file/d/1c1nNXJl9aR76FrwFcrJppJbk-Rg7o9tn/view.
The system follows a perpetual turnover of resources and consumers densities in function of their niche and foraging traits, but the macroscopic criteria of the community (exemplified here by the functional diversity F Dis) reach a quasi equilibrium.proportionally to the difference of the PF cost (s max − s min ).
As mentioned in the main text, the model may have assumed different trade-off such as a positive dependence between mortality rate and foraging trait.In this case the mortality rate may take the following form where d min is the basal mortality rate while d max is the maximal increase of mortality due to PF.
In this case, an increase of the foraging trait will increase the mortality rate proportionally to the maximal increment of mortality (d max − d min ).The growth rate will reduce proportionally to this quantity.We thus see that the effect of the trade-off will have similar consequences on the evolution of the foraging trait.1. Dashed lines: median; areas: 75% confidence intervals.
The effective density depends on the phenotype distribution of the population and the competition strength K e (y − y ) exerted by an individual with trait y on an individual with trait y: r e (t, y) = K e (y − y )R(t, y )dy (4) The functions K and K e are normally distributed around y = 0 with variances σ K and σ C respectively (Table SI.1 and Fig. SI.1).
In the present model the trade-off is only incorporated into the handling time of the type II functional response, where high handling times reduce resource absorption rates.If the PF strategy had increased mortality d instead of handling time, this would have also reduced resource absorption (see Appendix B for a formal derivation of the model).A trade-off between PF and mortality therefore provided similar results (Fig. SI.4 and SI.5).

Figure 2
Figure 2: a) Diversification of niche and foraging traits starting from a single resource and consumer at the niche centre, and a RF consumer strategy.Top panel: resource densities R(t, y).Middle panel: consumer densities C(t, x, z)dz.Bottom panel: foraging trait C(t, x, z)dx.b) The trait distribution of consumers at steady state (1000 time steps).
resources (Figure SI.9).PF also decreased niche overlap between pollinators in the model of Valdovinos et al. (2013) and in the empirical studies of Fontaine et al. (

Figure 3 :
Figure 3: Difference (in %) between systems with PF evolution and fixed RF, for (a) biomass, (b) functional dispersion, (c) productivity, and (d) niche overlap.For each panel, 1500 simulations of 1000 time steps with PF evolution were compared to simulations with fixed RF, the parameters being randomly sampled in the ranges specified in Table1.Dashed lines: median; areas: 75% confidence intervals.

Figure 4 :
Figure 4: Effect of disturbances: (a, b) increased mortality ∆d, (c, d) constant environment change c and (e, f) instantaneous niche shift ∆y.Left column (a, c, e): variations of consumer biomass of systems with and without PF, in function of the intensity of the disturbance.A negative variation indicates a decrease in biomass, for instance −0.2 indicates than 20% of the biomass is lost.The value −1 corresponds to the extinction of all consumers.The coloured gradient indicates the average PF trait of consumers.Right column (b, d, f): maximal sustainable mortality for monomorphic consumers, in function of their controlled foraging trait z.
to Fig. SI.6).Moreover, the gain in consumer biomass and productivity due to PF is larger in the quartic case (compare Fig. 3a-c to Fig. SI.8a-c).However, the quartic carrying capacity function tends to reduce the effect of PF on the functional diversity (Fig.SI.8b).Although functional diversity is higher with a platykurtic than with a Gaussian carrying capacity function, the gain due to PF is small (Fig. SI.7).
Figure SI.1: a) Carrying capacity K(y) of resources for various niche width values σ K = {0.5, 1, 2}.The niche centre fixed at y 0 = 0 corresponds to the maximal carrying capacity.b) Competition kernel K e for various neighbourhood size σ C = {0.5, 1, 2} between a focal resource y = 1 and all resources in function of their niche trait y. c) Interactions kernel ∆ for various generalization levels (σ = {0.5, 1, 2}) between a focal consumer (x = 1) and all the resources in function of their niche trait y. d) Searching time s in function of the foraging trait z.Parameter values as in Table1.

Figure SI. 3 :≈
Figure SI.3:Effect of a fixed foraging trait value z on systems where only the niche traits x and y of resources and consumers can evolve.The measured characteristics are biomass, functional diversity, productivity, and niche overlap.

B. 1
Effect of mortality trade-off on community emergence a.b.

Figure SI. 4 :FigureFigure
Figure SI.4:Distribution of resources and consumers over time with a trade-off on mortality.a) Diversification of niche and foraging traits starting from a single resource and consumer at the niche centre, and a RF consumer strategy.Top panel: resource densities R(t, y).Middle panel: consumer densities C(t, x, z)dz.Bottom panel: foraging trait C(t, x, z)dx.b) The trait distribution of consumers at steady state (1000 time steps).

Figure
Figure SI.9:Difference in functional matching between systems with PF evolution and systems with fixed RF. 500 pairs of systems were compared, each pair having the same parameter set randomly sampled in the ranges specified in Table1.Dashed lines: median; areas: 75% confidence intervals.

Table 1 .
Top panels: distribution of resources and consumers in function of their niche trait.Middle panels: distribution of consumers in function of their foraging trait (left) and community-level mean foraging trait in function of time (right).Bottom panels: functional diversity F Dis of resources and consumers.The other community-level characteristics are also stabilized once the stationary regime is reached.