Supplementary Material

I - Parameter variation: Duration of immunity

The basic model assumes immunity is life long, but our results do not strictly depend on this assumption. Qualitatively similar ones are found for cases of temporary immunity, i.e., when hosts become susceptible after a period of time (see figure S-I below). The reason we find similar results for both life long immunity and temporary immunity is because in either case the period of time spent in the immunity class generates a delay in the replenishment of susceptibles. This delay leads to demographic fluctuations in the level of infected hosts: if no time is spent in an immunity class (as in the SIS class of models), there would be no delay, and hence no fluctuations. Alternatively, if at least some time is spent in an immunity class, fluctuations arise, and as the time spent in an immunity state increases, the troughs of infected hosts become deeper. The depth of these fluctuations determines the risk of stochastic extinction, particularly in small host populations.

Figure S-I: Optimal combinations of c1and c2 when varying the duration of immunity. Red and pink represent c1and c2, respectively (when they are allowed to be different), and blue represents the cases where c1must equal c2. In the first row, immunity is life long, in the second row it lasts 25 years on average, and in the third row it lasts 10 years on average. For different combinations of ci, the depth of the trough of infected where recorded via numerical simulation. The x-axis is–log of thisdepth. On the y-axis are the optimal values of c for that depth. For all cases, b=5, r=5, k=1, mean life is 70yr, and c is between [0.01,1].

II - Parameter variation: Host life span

We assume that population size is constant, such that natural mortality is balanced by birth. Hence, increasing effectively increases the replenishment of susceptible hosts. When the expected life span of hosts is short (i.e.,  is large), fluctuations in the infected class decrease, and therefore the risk of stochastic extinction decreases ensuring persistence in smaller host populations. In contrast, when the expected life span of hosts is long (is small), the delay in the replenishment of susceptibles is more significant, and so the troughs of infected are deeper. Therefore, as  becomes very small, larger populations are needed to support persistence, and at the limit, where =0, there is no population large enough to support persistence, meaning that extinction of the pathogen is guaranteed.

This is demonstrated in figure S-II.

Figure S-II: Optimal combinations of c1 and c2 when varying the expected life span of a host. Red and pink represent c1 and c2, respectively (when they are allowed to be different), and blue represents the cases where c1 must equal c2. As in the main text, the search for optimal ci’s was carried out using two methods: On the right: for different combinations of ci, approximations of the critical community size where calculated according to Ncrit from equ. 4 in the main text. The x-axis represents Ncrit, and y-axis are the optimal values of c for Ncrit. On the left: for different combinations of ci, the depth of the troughs of infected were recorded via numerical simulation. The x-axis represents –log of that depth, and y-axis are the optimal values of c for that depth. (these search were not as deep as for the cases presented in the paper, hence the noise in the results.) For the two panels in the first row, mean age is 30 years, for the two panels in the second row mean age is 70 years, for the two panels in the third row mean age is 150 years, and for the two panels in the fourth row mean age is 1000 years. For all of these, b=5, r=5, k=1, duration of immunity is life long, and c is bound between [0.01,1].

III – Parameter variation: Restrictions on duration of infection

Figure S-III: Optimal strategies for two stages of infection based on critical community size (Ncrit) and r0, and for different restrictions on the maximum duration of infection of each of stage, from row 1 until 4: 5.5 days, 31 days, 177 days and 5 years, respectively. The left column shows the optimal combinations of transmission and the right column shows the corresponding duration, plotted as a function of community size. Red and pink represent optimal combinations of c1 and c2, and blue represents optimal combinations when both stages are restricted to being equal. As duration of infection is lengthened, pathogens can persist in smaller host populations. In all panels, only results for R0>1 are plotted. It can be seen that when duration is long, mixed-strategy pathogens can persist in very small host populations while pathogens with equal stages go extinct. Model parameters: k=0.75, b=10, r=1 and 1/ = 70yrs.

IV – Results based on R0 and r0

Figure S-IV: Optimal strategies for a 2-stage model according to R0 and r0. Plotted as a function of community size, red and pink curves represent optimal combinations for the first and second stages of infection, respectively. On the left are the results based on maximizing the basic reproductive number R0, and in the right are results based on maximization of the Malthusian growth rate r0. Note the similarity of the results obtained for the two different measures. Parameters: k=1, b=5, r=5, 1/ = 70yrs, and duration of infection in each stage is restricted to at least 5 day and at most 500 days.

V – Alternative model formulation: An explicit consideration of the age of infection

We use the following partial-differential equation framework, similar to that (King et al. 2009) and (Day, Alizon, and Mideo 2011) to explicitly track the age of infection:

HereS is the fraction of susceptibles, and I is the number of infected hosts. As before, the population is assumed to remain constant and is normalized to 1, such that R=1-S-Ii, where R is the fraction of recovered individuals. We assume that birth balances natural mortality at a constant rate,  Variable a represents the age of the infection, ranging from 0 to ac.b(a) is the transmission rate of infected hosts at age a and λ denotes the total force of infection at time t. Immunity is life long, but this is not a critical assumption as we discuss at the end of the paper (see Supplement for further details).

To demonstrate the robustness of our results under this alternative framework, we assume that the infection is characterized by multiple stages, each allowed to evolve independently. We defineAi= aj (j=1:..:n), with A0 = 0, An = ac and n is the number of stages. Hence, for Ai-1 a Ai: b(a)=bci, where, as before, b represents a contact rate, which cannot evolve, while ci is the transmission probability, or transmissibility, which can. Based on the tradeoff between transmissibility and duration, for each stage i, we define ai to be a function of ci, such that: i, j: ci cj  ai aj. Hence, when transmissibility increases, the duration of the infection decreases. The basic reproductive number for the two-stage model is:

Our analysis is carriedout in a similar manner to our original model. For different parameter combinations of c1 and c2, we calculate values of R0 and we numerically simulate the model to obtain values of -log(Tr)and r0. In agreement with our earlier results, a composite strategy that is composed of an initially acute stage with a chronic one later, is superior to the uniform strategy (see figure S4).

Figure S-V: Optimal strategies for two stages of infection. Plotted as a function of –log(Tr), the red and pink curves represent optimal combinations for the first and second stages of infection, respectively, and the blue curve corresponds to the optimal strategy when both stages of the infection are restricted to being equal. In the top panel are the optimal combinations of ci’s, that were found, in the middle panel are the corresponding R0’s, and in the bottom panel are the corresponding durations of infection. Model parameters: k=0.75, b=5, r=5 and 1/= 70yr.

VI – Alternative model formulation: Individual Based simulation

The results of our IBM for low and intermediate levels of immigration and/or mutation, agreed with the findings of our basic framework [1]. Figure S-VI-1a demonstrates a characteristic time series, and correspondingly, figure S-VI-1b shows the mean transmissibility of each stage as it evolves over time.

Figure S-VI-1:A time series demonstrating characteristic evolutionary dynamics. The individual based simulation begins from the initial introduction of a random strain type into a naïve host population. Red dots represent points of general extinction where the host population is infection free. a)A stacked histogram of the number of transmission events for time intervals of 50 days (each color represents a different strain type).It can be seen that at around year 380 and then again at around year 600, the highest frequency of cases are dominated by ‘chronic-acute’ strains (in red and then in light purple). However, these types are not robust to invasion and are eventually outcompeted by highly transmissible strains, which quickly go extinct themselves (the thin tall peaks appearing throughout the simulations are characteristically ‘acute-acute’ types). At around year 1150 an ‘acute-chronic’ strain (in dark magenta) takes over, and from there onwards it dominates most of the transmission events. b)The corresponding mean transmissibility of each stage weighted by the number of transmission events of the different types. Note the switch from ‘chronic-acute’ to ‘acute-chronic’ at around year 1150. Parameters are similar to those used in figure 4 in the text, except for b = 0.2 and = 0.0001.

In contrast, for high levels of immigration and/or mutation, we identify cases of evolutionary cycling (Boerlijst and van Ballegooijen, 2010), where the pathogen population is still attracted towards areas in parameter space where transmission is high in one stage, and low in the other, but here we identify two notable patterns:

1)Firstly, frequent strains are still clustered in a relatively narrow region of C2, as seen earlier, but the region itself shifts in time, leading to evolutionally cycling where the most frequent strains change from being “acute first and chronic later” to being “chronic first and acute later”, and back again (see figure S-VI-2 and also the corresponding switch in mean transmissibility of each of the stages in figure S-VI-1b).

2)Secondly, the dominant strains persist for significantly shorter stretches of time relative to the earlier case (the red lines in figure S-VI-2b are much shorter than those in figure S-VI-2a).

Our interpretation for these patterns is that the rapid introduction of new strainsenhances the conflict between co-existing strains in their competition for susceptible hosts, and in particular, between similar types. This prevents the system from reaching a stable state. For a strain introduced into an environment that is rich with “acute-chronic” strains, having the potential to quickly replicate as it enters the system is less beneficial than having the potential of enduring temporary depletion of susceptibles. Therefore, a system temporarily favoring “acute-chronic” strains will lead to high dominance of these at the time, but eventually it will evolve to a point where having a first stage that is long lasting becomessuperior. Gradually, the high density of the “acute-chronic” strains decreases, being replaced by high densities of strains that are “chronic” first. These, however, will be dominated by strains that are more transmissible at their second stage. As the density of these starts increasing, the system is once again driven to a point where having a first stage that is fast replicating is advantageous. The process so continues, cycling between periods wheerethe system is dominated by “acute-chronic” strain types, to periods wherethe system is dominated by “chronic-acute” strain types.

A more detailed analysis of these patterns will be presented elsewhere.

Figure S-VI-2: The distribution of strain types in parametric space C2 over time. z-axis is time, and the x- and y- axes are the corresponding transmission probabilities (c1 and c2) of each strain found in the system at that time. a) When mutation and immigration rates are low (= 0.0001,  = 10yrs), dominant strains are found in the region where transmissibility is first high, and later low (“acute-chronic”). The dominating strains can persist for relatively long stretches of time and are robust to invasion. b) When mutation and immigration are higher (=0.001,=0.5yrs), the persistence of dominant strains is shorter in time. Here, the region of parameter space where the dominant strains are found, cycles in time, from “acute-chronic” to “chronic-acute” and back again. Parameters: Nh = 2,000, contactb = 0.2, and minimal transmissibility is 0.001. Remaining parameters are identical to those in figure 4.

VII –A convex trade-off

In contrast to the concave and linear (k1) cases, we find that for convex trade-off between transmission and duration (k>1), the optimal strategy is generally independent of host population size, remaining fixed for almost all community sizes. In particular, here R0 reaches a maximum at intermediate levels of ci (see figure S-VII-1).

Based on our earlier analysis, evolution towards maximal levels of transmissibility may be expected when host population sizes are very large,because the risk of stochastic extinction is minimal. However, when the trade-of is convex,the optimal combinations of ci’s do not reach maximal values at any of the infection stages despite a low risk of extinction (see figure S-VII-2). The considerable variation in the duration of infection at different stages of infection is illustrated in figure S-VII-3 as a function of k. We find a switch from acute to chronic regimes as a function of the shape of the trade-off curve, implying that biological processes related with within-host dynamics have a direct influence on the evolution of acute vs. chronic disease.

Figure S-VII-1:Comparison of the shape of characteristic surface of R0for a two-class model under a transmissibility-recovery trade-off. a) The basic reproductive number (R0) withk1 in the trade-off function is maximal when transmissibility is maximized in both stages. b) The basic reproductive number (R0) with k1 in the trade-off function is maximal at intermediate levels of transmissibility.

Figure S-VII-2: Optimal strategies for two stages of infection based on critical community size (Ncrit) and R0. Plotted as a function of community size, the red and pink curves represent optimal combinations for the first (I) and second (II) stages of infection, respectively, and the blue curves correspond to the optimal strategy when both stages of the infection are restricted to being equal. In the top panel are the optimal combinations of ci’s,in the middle panel are the corresponding R0’sfor the solutions, and in the bottom panel arethe corresponding durations of infection in log scale. Note that for all community sizes, the optimal strategies for both stages always remain in the chronic phase, never developing into acute infections. However, a combined strategy is always superior to a uniform one. In all panels, only results for R0>1 are plotted. The parameters used are k=1.1 (convex), b=5, r=5 and 1/yr.

Figure S-VII-3:A switch from acute to chronic infection as a function of k. The x-axis corresponds to the value of k and the yaxis in the top panel, to the duration of infection in each stage, while that in the bottom panel is the corresponding transmissibility of each stage (in log scale). Note that the values plotted are under the assumption that community size is not limiting. Hence, when k1, the optimal strategy of all stages is maximal acuteness, while the optimal strategy for all stages when k1 is chronic infection. Interestingly, when host populations grow, based on the characteristics of the within-host dynamics, pathogens can evolve to being either acute under on regime, or chronic under another. In addition, we see that whenk1, although transmissibility of the different stages is very similar, the duration of infection varies substantially. Model parameters: b=3, r=3 and 1/yr, and duration of each stage is limited to 500 days.

1