Plastic male mating behavior evolves in response to the competitive environment

Male reproductive phenotypes can evolve in response to the social and sexual environment. The expression of many such phenotypes may also be plastic within an individual’s lifetime. For example, male Drosophila melanogaster show significantly extended mating duration following a period of exposure to conspecific male rivals. The costs and benefits of reproductive investment, and plasticity itself, can be shaped by the prevailing sociosexual environment and by resource availability. We investigated these ideas using experimental evolution lines of D. melanogaster evolving under three fixed sex ratios (high, medium, and low male-male competition) on either rich or poor adult diets. We found that males evolving in high-competition environments evolved longer mating durations overall. In addition, these males expressed a novel type of plastic behavioral response following exposure to rival males: they both significantly reduced and showed altered courtship delivery, and exhibited significantly longer mating latencies. Plasticity in male mating duration in response to rivals was maintained in all of the lines, suggesting that the costs of plasticity were minimal. None of the evolutionary responses tested were consistently affected by dietary resource regimes. Collectively, the results show that fixed behavioral changes and new augmentations to the repertoire of reproductive behaviors can evolve rapidly.

Male reproductive investment is shaped by the level of pre-and postmating sexual competition in many species. Across taxa, males from species with higher levels of polyandry have been found to have larger testes and to produce more sperm (Birkhead 1998;Wedell et al. 2002;Smith 2012). Furthermore, individual males can express plasticity in their reproductive investment and mating behavior, allowing them to adapt to variation in the social environment within their lifetime. Plasticity in reproductive traits enables individuals to adjust their investment in each mating or reproductive bout in response to the environment, including social context, thus optimizing lifetime fitness (Dewsbury 1982;Gage and Baker 1991;Wedell et al. 2002;Bretman et al. 2011a). There are many examples of individuals adapting their reproductive effort according to factors such as the risk of sperm competition, the mating status or quality of a potential mate, or to the developmental environment (Wedell et al. 2002;Kasumovic and Brooks 2011;Kelly and Jennions 2011). In this study, we investigate how male reproductive behaviors evolve in response to the competitive environment. Investment in reproduction, particularly sperm and seminal fluid protein production, is known to be costly to males (Dewsbury 1982;Nakatsuru and Kramer 1982;Wedell et al. 2002;Perry et al. 2013). Drosophila melanogaster males that were repeatedly exposed to competitors, and responded by extending mating duration throughout their lifetimes, suffered significant costs later in life indicating that reproductive resources can be limiting (Bretman et al. 2013b). Furthermore, plasticity per se may also carry costs. For example, maintaining the capability to accurately monitor the environment, process cues and alter phenotype expression accordingly is expected to be energetically costly (DeWitt et al. 1998;Relyea 2002;Auld et al. 2010). Producing a phenotype that is rapidly and accurately matched to a changing environment may require stringent and sophisticated receiving, processing, learning, and/or memorizing of multiple sensory cue components (Bretman et al. 2011b;Mohorianu et al. 2017;Rouse et al. 2018). Relative costs and benefits of expressing plasticity are also likely to be context-dependent. The adaptive value of maintaining plasticity in a trait versus expressing a fixed response may vary temporally and spatially (Givnish 2002). Plasticity is predicted to be particularly beneficial in rapidly changing environments (Botero et al. 2015) and may become neutral or even costly if the environment is stable or constant. Therefore, the overall level of investment in a reproductive trait, and the degree to which it is plastic, may be subject to trade-offs, and both may be targets of selection imposed by the social environment.
If reproductive investment and plasticity are costly, they may be mediated by resource availability, as well as selection from the social environment. Diet is known to mediate trade-offs between reproduction and longevity, such that dietary restriction limits fecundity (Flatt 2009;Edward and Chapman 2011). Remating frequency, egg production, and life span are affected by reducing the levels of protein and carbohydrate in the diet of female D. melanogaster (Chapman and Partridge 1996) and protein availability may also influ male reproductive success (e.g., Fricke et al. 2008). The balance of costs and benefits of plasticity per se may interact with nutrition availability, as investment in maintaining costly plasticity may itself be resource-limited (Steinger et al. 2003;Cipollini 2004). Therefore, the expression of costly, plastic reproductive traits may be affected by an interaction between the social environment and resource availability.
Experimental evolution approaches offer excellent potential for testing explicit predictions of how male reproductive behaviors evolve in response to the social environment, whether the expression of plasticity is reduced when environments are more stable, and how these responses may be mediated over evolutionary time by resource availability (Murren et al. 2015). Previous studies have used lines of D. melanogaster experimentally evolved under male-biased (MB) or female-biased (FB) sex ratio to study male and female responses to the level of male-male competition and sexual conflict. A strongly FB sex ratio can select for larger male testis size, suggesting an adaptation to mating rate and sperm depletion (Reuter et al. 2008). MB adult sex ratios have been found to select for increased female resistance to male-induced harm (Wigby and Chapman 2004) and faster ejaculate depletion over serial matings (Linklater et al. 2007). Edward et al. (2010) tested plastic male responses to rivals in MB and FB lines of D. melanogaster and found that males from both lines maintained responses to rivals, whereas males from MB lines expressed a nonsignificant tendency to mate for longer overall. Here, we build on these previous studies by conducting a comprehensive investigation into male plastic reproductive behavior in MB, equal-sex (EQ), and FB experimental evolution lines maintained under two dietary regimes. The inclusion of the equal-sex lines allowed us to distinguish the effects of biased sex ratio per se from other possible influences of the evolutionary environment. New to this study were tests of the reproductive behavior of males from these lines in response to both wild-type and own-regime rivals and females, allowing us to disentangle po-tential effects arising from co-evolution as well as from contextdependence. We also studied plastic male mating duration and latency among males evolved under both fixed sex ratio and either rich or poor adult diet regimes, to test the effects of, and interactions between, the social environment and resource limitation on male reproductive investment and plasticity. Moreover, we investigated the previously unanswered question of how male courtship behavior has evolved in response to fixed sex ratio.
We used experimental evolution lines in which each generation is subjected to a fixed adult sex ratio and either a rich or poor adult diet. This allowed us to test how male reproductive behaviors evolve in response to different degrees of male-male competition and resource availability. Furthermore, the relatively stable level of male-male competition induced by controlling sex ratio allowed us to investigate whether plasticity in male reproductive behaviors diminishes when environmental stability increases. We measured mating duration, which shows a highly repeatable and well-characterized response to male-male competition (Bretman et al. 2009(Bretman et al. , 2010(Bretman et al. , 2011bRouse et al. 2018), latency to mate and courtship behavior in males from these regimes. We first measured male behavior in response to wild-type rivals and with wild-type females. In subsequent experiments, we tested for context specificity by comparing the behavior of focal males exposed to either wild-type or co-evolved rivals and females.
Our first prediction was that males evolved under the fixed sex ratios, and thus divergent levels of male-male competition, would show evidence of directional selection on mating behavior. We expected that males from the high-competition (MB lines) would be selected to mate for longer overall, indicating an increase in reproductive investment. Our second prediction was that males from all the sex ratio regimes would show reduced plasticity overall in their reproductive behaviors. This prediction was based on the assumption that plasticity is less beneficial in the more stable social environments in which the sex ratio lines have been maintained, thus increasing the relative costs of expressing plasticity in comparison to the originating stock populations. Our final prediction was that the adult dietary regime on which males were evolved would interact with sex ratio to influence plastic male mating behavior, assuming that male investment in reproduction and/or the expression of plasticity is limited by protein restriction.

GENERAL METHODS
Experiments were conducted in a 25°C humidified room with a 12 h light:12 h dark cycle. Flies were maintained on a sugaryeast-agar (SYA) medium (100 g brewer's yeast, 50 g sucrose, 15 g agar, 30 ml Nipagin (10% solution), 3 ml propionic acid, 0.97 l water). Wild-type rivals and females were from a Dahomey stock population (Bass et al. 2007;Bretman et al. 2009) maintained in large cages with overlapping generations and in which sex ratio was allowed to vary naturally. Experimental flies were cultured by allowing females to oviposit on agar-grape juice plates (50 g agar, 600 ml red grape juice, 42 ml Nipagin (10% solution), 1.1 l water). Larvae were collected from the plates and reared under a controlled density of 100 per vial. At eclosion, adults were separated by sex to ensure virginity, and stored 10 per vial. Post collection, rival males and females were maintained on standard SYA medium supplemented with live yeast paste. Focal treatment males were maintained on their evolutionary diet. Experiments took place when the focal males were 7-10 days old.

SEX RATIOS AND STANDARD AND LOW YEAST DIETS
Experimental evolution lines of D. melanogaster originated from a laboratory population of wild-type Dahomey flies and were maintained under three fixed adult sex ratios and two dietary regimes. Lines were maintained on either standard SYA medium, or a protein-restricted SYA medium containing only 20% of the standard amount of yeast (Fricke et al. 2008). Within these two dietary treatments, lines were maintained under fixed sex ratios, either MB (70 males:30 females), equal sex (EQ, 50:50), or FB (25:75). The MB lines were propagated at a sex ratio of 70:30 (rather than 75:25) to ensure sufficient eggs were produced to set up each next generation. There were three replicate populations for each diet/sex ratio combination (3 sex ratio regimes × 2 diets × 3 replicates each = 18 experimental evolution lines). These lines were maintained in nonoverlapping generations and set up each generation using 100 individuals of the same age. This created a stable social environment relative to the originating wildtype (which was maintained in large populations in which sex ratio and age structure were allowed to fluctuate). These experimental populations had been evolving under fixed sex ratio and diet for over 66 generations at the time the experiments were conducted. Although there may be some inbreeding depression in the lines, Snook et al. (2009) calculated that the effective population sizes of equivalent populations did not differ substantially between sex ratio treatments, and we expect any differential effects across lines to be minimal.
The sex ratio lines were maintained in ventilated plastic boxes with two vials of water plugged with cotton bungs to maintain adequate humidity, and two vials of SYA (either standard SYA or 20% yeast). Food was replaced with fresh vials on a regular schedule, every 2-3 days. On the eighth day after each generation was set up, the SYA vials were replaced with agar-grape juice plates, containing a smear of live yeast paste, for egg collection. Three hundred larvae were collected from these plates and cultured at 100 per vial on standard SYA. After eclosion, 100 individuals in the correct sex ratio were randomly selected from these offspring. Thus, the lines were maintained in nonoverlapping generations, within same age cohorts. Treatment males were offspring of individuals from the experimental evolution lines, obtained by standard density culturing of eggs laid on agar-grape juice plates.

Experiment 1. Evolution of plastic male behavior
Males cultured from experimental evolution lines were randomly assigned to either rivals (+) or no-rival (−) treatments. Males in the +rivals treatments were housed in a vial with three wildtype males for three days immediately prior to the mating assay. Rival males had their wings clipped under CO 2 anesthesia, to differentiate the focal and rival males without affecting mating success (Ehrman 1966). Males in the no-rival treatments were housed alone. During the ±rivals exposure treatment period, all males were maintained on the evolutionary diet of the focal male. All focal males, rival males, and females used in experiments were virgins, to control for confounding effects of prior social experience, and for consistency with previous studies of male D. melanogaster reproductive behaviors (Bretman et al. 2009(Bretman et al. , 2011bRouse and Bretman 2016). Females were transferred to individual vials of SYA with live yeast supplementation a day prior to mating. Each focal male was introduced to a female by aspiration. Latency to mate (the time from when the male was introduced to the vial with the female to when mating began) and mating duration were recorded to the nearest minute. Labels on vials were coded so that observers were blind to the treatment of each sample. Pairs that did not mate within 2.5 hours were discarded. Males were removed after mating to avoid remating and females were left to oviposit for 24 hours. Vials were retained until all offspring eclosed, when adult offspring were frozen and counted. Replicate populations 1 of each experimental evolution regime were tested in block one (at generation 66 of experimental evolution), replicate populations 2 of each regime tested in block two (at generation 67), and replicate populations 3 in block three (at generation 68). Data were pooled for analysis and analyzed as described below.
A separate control experiment was also conducted to determine the effects on reproductive responses to rivals of maintaining wild-type males on a proximate diet of either 100% or 20% yeast diets. This was done to give further insight into the determination of evolutionary versus proximate diet effects in the main experiments with the sex ratio lines. Wild-type individuals from stocks maintained on standard SYA were cultured as described above, and males were randomly assigned to a rival or no-rival treatments, and to a 100% or 20% yeast diet. Males were collected as adults and housed with or without three conspecific, wild-type male rivals for three days on their experimental test diet. Rival males and females were collected and stored in standard SYA vials with live yeast supplementation. Females were transferred to individual vials of SYA with live yeast a day prior to mating. Mating duration and latency to mate were recorded as described above.
The results from experiment 1 revealed that males from MB lines had evolved to become significantly slower to mate following exposure to rival males. To investigate potential male-and female-mediated drivers of this novel plasticity in mating latency, additional experiments were then conducted to test the influence of the evolutionary history of rival males and females on focal male mating behavior. Furthermore, a detailed analysis of male courtship behavior was performed to examine which elements had changed (details below). These experiments 2-4 focused on MB lines, due to the plasticity in mating latency expressed specifically by these populations. The EQ lines were included as a control group against which to infer evolved patterns of male mating behavior in the MB lines, and the FB lines were excluded from these further experiments. As no consistent effect of diet on male mating behavior was found, these subsequent experiments were also conducted only on lines derived from the standard diet regimes.

Experiment 2. Interaction of male reproductive plasticity with rival male evolutionary history
Focal regime males were tested with wild-type rivals versus coevolved rivals from within their own experimental evolution regime, when mating with wild-type females. Focal males were randomly assigned to treatments in which they were housed for three days with either three wild-type rivals (+WT), with three co-evolved rivals from within their own experimental evolution regime (+own regime), or alone (−). To investigate male aggressive encounters as a potential driver of evolved changes to male courtship repertoires, behavioral spot checks of the focal male were conducted during the period of exposure to rival males. On each of the three days, spot checks were made every half an hour from 8:30 a.m. (ZT0) to 10:30 a.m. (ZT2.5), a period of peak activity for D. melanogaster (De et al. 2013). The number of times the focal male was observed in physical contact with a rival male (encompassing fencing, lunging, boxing, tussling, etc.; Chen et al. 2002) was recorded, as a proxy for the frequency of aggressive interactions. Following rival/no-rival exposure treatment, focal males were introduced to a virgin female and mating latency and duration were recorded as described in experiment 1.
All three replicate populations were tested simultaneously. This experiment was conducted twice, independently, at generations 85 and 89 of experimental evolution, and the data were pooled across generations for analysis.

Experiment 3. Interaction of male reproductive plasticity with female evolutionary history
To investigate potential female-mediated drivers of MB male plasticity in mating latency, the responses of focal line males to wild-type rivals, when mating to wild-type versus coevolved, own-regime females were tested. Focal males were randomly assigned to treatments in which they were housed for three days either with three wild-type rivals (+) or alone (−), then mated to either a wild-type virgin female (xWT) or a virgin co-evolved female from within the male's own experimental evolution regime (xMB or xEQ). Assays to measure mating latency, duration, and offspring production were conducted as described for experiment 1. All three replicate populations were tested simultaneously. This experiment was conducted on individuals drawn from generation 92 of the experimental evolution.

Experiment 4: Evolutionary changes in courtship behavior
To investigate the behavioral drivers underpinning MB male plasticity in mating latency, the courtship repertoire of males from MB and EQ experimental evolution lines was analyzed, with and without prior exposure to wild-type rivals. Focal males were cultured as above and either exposed to one wild-type rival for three days (+) or housed alone (−). Following this, each focal male was aspirated into a circular Perspex mating arena (diameter 22 mm, depth 5 mm) with a wild-type female and filmed for up to 30 minutes, or until copulation began. Video recordings were made using Sony Handycam HDR cameras from 9:30 a.m. (ZT0) to 11:00 a.m. (ZT1.5) over six adjacent days. The first minute of footage of each pair was disregarded to allow for acclimation. The courtship videos were blinded with respect to identity and analyzed using JWatcher (Blumstein and Bouskila 1996;Blumstein and Daniel 2007). A time log of each video was created, which recorded the occurrence, duration, and sequence of the following courtship behaviors (Lasbleiz et al. 2006 The following behaviors were removed prior to statistical analysis because they occurred in <10% of samples: decamping (M), movement (F), wing flicking (F), kicking (F). Courtship latency and copulation latency were also recorded, as before.

STATISTICAL ANALYSIS
Statistical analyses were performed using R version 3.6.1 (R Core Team 2016). Mixed models were used to account for units of replication. In experiment 1, replicate population 1 of each experimental evolution treatment was tested in one block, replicate populations 2 in a second block, and replicate populations 3 in a third block. Thus, replicate population and experimental block were confounded, so were included in mixed models as one random effect ('block'; Table S1b). In experiment 2, all populations were tested simultaneously, in the two replicate assays. Thus, in this case population and experiment were included in mixed models as two random factors (Table S1c). In experiment 3, all replicate populations were tested once, simultaneously, thus population alone was included in mixed models as a random factor (Table S1d). In experiment 4, samples were tested across several days in a randomized order. Both population and the date of testing were included as random factors in models analyzing these data.
Where mating duration and latency data were normally distributed or could be transformed to fit a normal distribution, Gaussian linear models were used. Where data were not normally distributed, generalized linear mixed models with gamma distributions and log links, as was determined to be the best fit for the data, were implemented in the package "lme4" (Bates et al. 2015). Maximal models included the main effects of evolutionary sex ratio, evolutionary diet, rival exposure, rival evolutionary identity, and female evolutionary identity, where relevant as well as interaction effects. Stepwise model simplification was conducted, with analysis of deviance to determine significant terms.
Multivariate data showing the time budget of male courtship (the proportions of courtship duration spent on each recorded behavior) were analyzed using a principal components analysis with the function prcomp(). The eigenvalues of each principal component were extracted, and those with a value of >1 (PCs 1 and 2) included in linear mixed models to determine the influence of sex ratio and rival exposure. To complement this analysis and determine the consistency of patterns of courtship intensity across individual behaviors, the courtship data were also analyzed using univariate testing. The numbers of times behaviors were performed were analyzed with generalized linear models with Poisson distributions and log links. Some behaviors (singing, stationary, circling, and general movement) were performed for highly variable durations and could not be analyzed as simple counts of occurrence. In these cases, Kruskal-Wallis tests were run on individual measures to analyze the proportion of time the individual spent performing the behavior. Courtship duration and latency were also analyzed using Kruskal-Wallis tests. The probability of successful copulation within the 30minute window was analyzed using a generalized linear model with a binomial distribution and a logit link. Finally, the probability of transitions between courtship behaviors was analyzed to investigate differences in the sequence of the courtship routine. Occurrences of single-order transitions between behaviors were pooled for all males within each treatment, to give a transition matrix for each. Transitions that never occurred across all treatments were considered structural zeroes and not included. A generalization of Fisher's exact test was used to test for nonrandomness at each transition, using the function aylmer.function() in the package "aylmer" (West and Hankin 2008).
Throughout, planned pairwise comparisons were carried out on estimated marginal means using the emmeans() function in the package emmeans (Lenth et al. 2018). Within each set of experiments, P-values were adjusted for multiple comparisons using the Benjamini-Hochberg procedure.

COMPETITION
Our first prediction, that male mating behavior would evolve in response to the level of male-male competition imposed by the fixed sex ratio regimes, was supported. Males evolved under MB sex ratio evolved longer matings overall and novel, behaviorally plastic, responses to rivals in mating latency and courtship behavior. The evolution of this plasticity in mating latency and courtship was specific to the males from the MB sex ratio regimes and was not observed among FB, EQ, or wild-type males.
Across all experiments, there was evidence that baseline mating duration had evolved in the sex ratio regimes (Table 1). Increased male-male competition generally led to longer overall mating duration, with males from FB lines tending to mate for the shortest duration (Fig. 1). There was a general pattern of MB males mating for longer than EQ males in equivalent diet/rival treatments (Fig. S1). This effect was statistically significant in some, but not all comparisons. However, the pattern was repeatable across experiments 1-3 (Figs. 1 and S1; Table S1b-d). This supported the prediction that sex ratio imposed directional selection on overall mating duration, leading to extended mating duration among MB males in response to the consistently high level of competition exerted in the MB regimes.
Males from MB sex ratio regimes showed longer mating latencies following exposure to rivals (Table 1): in experiments 1 and 2 MB males significantly extended mating latency in response to both wild-type and own-regime rivals (Table S1b-c). The tendency to extend mating latency in response to rivals was not generally apparent among wild-type males or those evolved under EQ or FB sex ratios (Table S1b and c). In experiment 1, in which the mating behavior of males from all experimental evolution regimes was tested in response to wild-type rivals and wild-type females, mating latency was influenced by a significant interaction between evolutionary sex ratio and rival exposure (χ 2 = 12.16, df = 2, P = 0.0088). MB males evolved on both the 100% yeast (P = 0.029) and 20% yeast diets (P = 0.032) expressed significantly longer mating latencies following exposure to rivals ( Fig. 2; Table S1b). In experiment 2, in which the evolutionary history of male rivals was varied, rival exposure (χ 2 = 28.01, df = 1, P < 0.0001), but not sex ratio, significantly influenced mating latency. Pairwise comparisons showed that males exposed to both wild-type (P = 0.00045) and co-evolved rivals (P = 0.0014) significantly extended mating latency in comparison to males kept alone ( Fig. S2a; Table S1c). In experiment 3, in which the influence of female evolutionary history on focal male responses to competition was tested, there were no significant effects of sex ratio or rival exposure on male mating latency (Table S1d). Nevertheless, there was a nonsignificant pattern of MB males extending mating latency following exposure to rivals (Fig. S2b). Previous studies have not found a consistent effect of rival exposure on mating latency, suggesting that this behavior in MB males is an evolved response (Bretman et al. 2009(Bretman et al. , 2013a(Bretman et al. , 2013b. To investigate the mechanistic basis of the long latency expressed by MB males following exposure to rivals, the detailed courtship sequences of males from MB and EQ lines, with and without prior rival exposure, were analyzed (experiment 4). MB males responded to rival exposure by exhibiting a marked reduction in the expression of all courtship behaviors, evident as significantly extended courtship latency (P = 0.019; Table S1f) and a significantly altered courtship routine. The principal components with eigenvalues >1 were PC1 (explaining 41.59% of variation in courtship behavior) and PC2 (explaining 13.14% of the variation). The first principal component was significantly affected by rival exposure (Table 1; χ 2 = 6.85, df = 1, P = 0.026) with a borderline nonsignificant interaction between evolutionary sex ratio and rival exposure (P = 0.052; Table S1e). The second principal component was not significantly predicted by sex ratio or rival exposure. The time the male spent tapping the female had the highest loading on PC1 (0.46), followed by time spent chasing the female (0.40) and time spent licking the female (0.39). Time spent circling the female had the highest loading on PC2 (0.58), followed by time spent chasing (0.43) and time spent orientating (0.40; Fig. S3). Additional univariate tests showed that across six of the seven male courtship behaviors tested MB males responded to rivals by performing the behavior significantly less frequently, or for a significantly shorter proportion of time (Table S1f).
This effect of rivals on courtship behavior was seen only in MB, and not EQ, males (Figs. 3 and S4; Table S1f). MB males

Mating duration of experimentally evolved focal males in response to wild-type rivals and wild-type females. The mating duration of male D. melanogaster evolved under male-biased (MB; white boxes), equal (EQ; gray boxes) or female-biased (FB; blue boxes) sex ratio, and standard (100% yeast) or protein-restricted (20% yeast) diet regimes. Rival exposure treatments within each sex ratio/diet treatments are pooled to show differences in overall mating duration. Boxplots showing interquartile range and median.
Asterisks indicate significant pairwise differences in planned comparisons of estimated marginal means: * * * * P > 0.0001; * * * P > 0.001; * * P > 0.01; * P > 0.05. For boxplots split by replicate populations, see Figure S8. also responded to rivals by spending a significantly higher proportion of their courtship time stationary and thus less time performing courtship behaviors (P = 0.013; Fig. S4; Table S1e). However, the MB males did not spend less time engaged in general movement (i.e., moving around the courtship arena without interacting with the females; P = 0.80; Fig. S4h; Table S1e). This suggested that the decrease in courtship behavior was not driven by lower activity levels overall among MB males exposed to a rival. Furthermore, the number of times the female decamped (i.e., abruptly jumped or flew away from the male, which can be interpreted as a signal that the female is not receptive to mating) was not elevated in the MB rival treatment, suggesting that the reduced courtship intensity observed in the MB rival treatment group was not a response to reduced female receptivity (Table S1e). Extended courtship latency and reduced courtship intensity is likely to be the driver of longer latency to mate among MB males following rival exposure. MB males retained the ability to express normal courtship behavior, as demonstrated in the no-rival treatments (Figs. 3 and S4) and these males had comparable copulation success to that of EQ males in an equivalent rival treatment (Fig. S4c).
Courtship was less stereotypical in MB males that had been exposed to rivals. This was indicated by an overall lower incidence of statistically significant transitions between behaviors, and followed from their lower overall courtship activity. There were few cases where the likelihood of transitions between behaviors showed a significant response to sex ratio or rival exposure. However, the MB rivals treatment was the only group in which males were significantly likely to be stationary following female decamping, and not to follow decamping with chasing (Table S1g). This shows that MB males exposed to rivals appeared more likely to respond to female rejection behavior by ceasing courtship delivery. Among males exposed to rivals, the identity of the rival males did not significantly predict the frequency of aggressive interactions between focal and rival males, although MB males generally showed less contact with rivals overall (Fig. S5; Table S1c).

RATIO AND DIET REGIMES
Counter to our second prediction, males evolving under the different fixed sex ratio regimes maintained plasticity in mating sex ratio, and standard (100% yeast) or protein-restricted (20% yeast) diet regimes. Focal males were either exposed to three conspecific male rivals ("rivals"; solid line) or housed alone ("no rival"; dashed line) prior to mating. Right-hand column: the same data visualized as boxplots (defined as described in Fig. 1). For boxplots split by replicate populations, see Figure S9. duration in response to rivals (Table 1). The presence of rivals remained a significant predictor of mating duration of focal males in response to both wild-type rivals and to wild-type females (experiment 1; χ 2 = 93.87, df = 1, P < 0.0001), to co-evolved rivals (experiment 2; χ 2 = 44.24, df = 1, P < 0.001) and to coevolved females (experiment 3; χ 2 = 23.08, df = 1, P < 0.0001; Table S1b-d; Fig. S1). Thus, plasticity in mating duration was not reduced by evolution in a relatively stable social environment. Males from the experimental evolution lines did not express significantly different responses to wild-type rivals compared to coevolved rivals. Among focal males exposed to rivals, the evolutionary identity of the rival did not predict latency to mate, mating duration or the frequency of contact with rival males (Figs. S1, S2, and S5; Table S1c). Although behavioral plasticity was maintained among experimentally evolved males, mating duration did not show a consistent relationship with the number of offspring fathered (Fig. S6; Table S1b and d). In some instances, males that were exposed to rivals had lower reproductive success than those that experienced no competition. This was inconsistent with earlier studies showing that the extended mating phenotype expressed in response to rivals is associated with increased ejaculate investment and greater offspring production (e.g., Bretman et al. 2009). However, recent research with wild-type male D. melanogaster has also failed to find fitness benefits of extended mating and suggested that there may not be a direct relationship between rival exposure, behavioral response, ejaculate transfer, and reproductive fitness (Dore et al. 2020).
Although the pattern of extended mating duration in response to rivals was consistent across treatments and across experiments, it was less pronounced among MB males mating with co-evolved females (experiment 3). Unlike experiments 1 and 2, in experiment 3 there were no significant pairwise differences in mating duration between treatments exposed to competitors and those that were not. Nevertheless, the size of the effect of rival exposure on mating duration was markedly lower in the case of MB × MB matings (t-ratio = 1.13, df = 297, P = 0.42; Table S1d) than in other comparisons. This suggests that the expression of plasticity can be context-dependent, and that plasticity was diminished among MB males in their selective context with MB females.

PLASTICITY
In the tests using wild-type rivals and wild-type females (experiment 1), there was a significant interaction between evolutionary sex ratio and adult diet (P = 0.035, Table S1b). However, this did not appear to be driven by reduced mating duration among males evolved on the poor diet (20% yeast) medium ( Fig. 1; Table S1b). This was counter to our prediction that a protein-restricted evolutionary diet would impose resource limitations leading to reduced investment in reproduction. Similarly, the limited protein dietary regime did not result in a reduction in mating duration or limit the expression of reproductive plasticity in wild-type males, again giving no evidence that resource limitation affected the ability of males to invest in reproduction ( Fig. S7; Table S1h).

IMPOSED BY FIXED SEX RATIO
The results supported the prediction that the evolutionary manipulation of adult sex ratio would impose directional selection on overall mating duration. There was a general trend for overall mating duration to be longer in males from the MB lines that experienced higher male-male competition, with mating duration in FB males tending to be the shortest. In addition, in comparisons between MB and EQ males held under equivalent conditions, MB males generally mated for longer. Males are predicted to increase their reproductive investment when there is a high risk of sperm competition and when future mating opportunities are low (Linklater et al. 2007). Support for this prediction is observed across populations and species (Birkhead 1998;Hosken et al. 2001;Wedell et al. 2002;Smith 2012). In D. melanogaster, for example, males evolved in a polygamous mating system are more successful in sperm competition and elicit stronger postmating responses from females compared to monogamous males, likely driven by higher investment in seminal fluid proteins (Hollis et al. 2019). Drosophila spp. males from populations with higher sperm competition have also been found variously to have larger testes, higher investment in spermatogenesis, larger accessory glands, and higher offspring production (Pitnick et al. 2001;Crudgington et al. 2009). In the environment of the MB experimental evolution lines, each female may mate up to three times as often as each male (Wigby and Chapman 2004;Rostant et al. 2020). Thus, to contribute to the next generation of the MB lines, males must achieve reproductive success under consistently high sperm competition. The results of this study are consistent with previous findings that male D. melanogaster evolving in MB regimes invest more heavily in early mating opportunities, as evidenced by more rapid declines in productivity and accessory gland sizes than males from FB lines (Linklater et al. 2007). Despite expressing longer overall mating, males from MB lines did not father a higher number of offspring than males from other lines in the experimental assays used here. Hence, it is possible that the extension of mating duration is not adaptive. Alternatively, the extended mating observed may result in other reproductive benefits not measured, such as delaying female remating or promoting sperm defense (Bretman et al. 2009;Dore et al. 2020) and these would be interesting to explore further. Moreover, the evolution of longer mating duration could be a correlated response to another trait targeted by selection. We cannot rule out a contribution of maternal effects toward the differences in male mating duration and plastic courtship behavior observed between the sex ratio lines, as the focal males were the offspring of parents maintained in the regimes. Nevertheless, the results suggest a directional, potentially adaptive, response of male reproductive plasticity to the social environment.

IN RESPONSE TO RIVALS AMONG MB MALES
Males evolved under the MB sex ratio evolved novel plastic responses to rivals in mating latency and courtship behavior, which were not observed in control (wild-type or EQ) males. Males from MB lines frequently responded to exposure to rivals by shutting down their courtship delivery and becoming significantly slower to initiate mating. This was driven by longer courtship latency and reduced courtship intensity. These responses of reducing courtship intensity, and thus extending latency, after encountering rivals was not evidenced among EQ, FB, or wild-type males, and to our knowledge has not been previously reported. Previous research has suggested that elements of courtship behavior can evolve rapidly in response to the mating system (Holland and Rice 1999) and reduced latency to the initiation of courtship song is reported in promiscuous populations of Drosophila pseudoobscura (Snook et al. 2005). Our results show that plasticity in courtship behavior can evolve rapidly in response to the social environment.
In the evolutionary environment of the MB lines, it is likely that courtship is frequently interrupted or interfered with by the immediate presence of other males. The presence of rival males in the mating arena can reduce mating duration, suggesting that interference from rivals can interrupt and terminate copulation (Bretman et al. 2009). A similar effect is likely to occur during courtship-the structure of courtship song may often be masked by overlapping songs of other males, and it may be rare for males to complete a courtship sequence without interruption. These factors are proposed to drive a lower rate of courtship song delivery and shorter song duration by male D. melanogaster in the presence of competition (Tauber and Eberl 2002) as well as shorter courtship bouts in more MB groups (Ewing and Ewing 1984). Similarly, interruption by rival males has been found to reduce the amount of time male guppies (Poecilia reticulata) and Pacific blue-eye fish (Pseudomugil signifer) spend courting in competitive environments (Jirotkul 1999;Wong 2004). Ubiquitous interruption of courtship by competitor males in the MB lines may have selected for plasticity whereby shorter and less intensive bouts of courtship behavior are expressed by males when cues of rival presence are received prior to mating. This could explain the lower courtship intensity following exposure to rivals that was observed in males from MB, but not EQ lines, despite the fact that there were no competitors present in the mating arena to directly interrupt courtship in this experiment. Overall, the results show that novel elements of plasticity in courtship behavior can rapidly evolve in response to evolution under high male-male competition.
In contrast to the generally longer mating duration expressed by MB males, implying increased reproductive investment, the lower courtship intensity elicited by rival exposure among MB males implies reduced mating effort. Together, these results may represent a refocusing of reproductive effort that has evolved in response to the high level of male-male competition. Previously, polyandry has been shown to weaken precopulatory sex-ual selection and increase the relative strength of postcopulatory selection, demonstrating that the social environment can influence the balance of these two selective forces (Morimoto et al. 2019). The mating rate of females in the MB lines is high (Rostant et al. 2020), which may increase the relative importance of postcopulatory selection. In combination with the high likelihood of courtship being interrupted in this environment, this may select for a shift in reproductive effort from long, highenergy courtship sequences toward investment in postmating competition.
Although possible, it seems unlikely that the evolved changes to mating behavior expressed by MB males were strongly influenced by genetic drift and/or inbreeding. The effective population size of these regimes differ only slightly ) minimizing the potential for effects due to differential genetic drift. The extension of mating latency and reduction of courtship intensity in response to rivals also showed high consistency across the replicate MB populations (Figs. S8 and S9). Furthermore, MB males did not show evidence of inbreeding depression in that they retained the ability to express all the standard elements of the male courtship repertoire (Fig. 3). We posit that this context-dependent courtship behavior is more consistent with selection under high male-male competition than with the influence of inbreeding or drift.

MAINTENANCE OF REPRODUCTIVE PLASTICITY IN A FIXED SOCIAL AND SEXUAL ENVIRONMENT
When environments become more stable the benefits of maintaining plasticity are expected to decrease. If there are net costs to maintaining plasticity it may then be selected against, leading to the evolution of more fixed phenotypes (Hedrick et al. 1976;Givnish 2002;Hall and Colegrave 2008;Murren et al. 2015). Overall, our results did not support the prediction that plasticity in mating duration would be reduced within a relatively stable selective environment. Males evolving under fixed adult sex ratio regimes that were FB, EQ, or MB all retained the ability to fully express extended mating duration as a response to rival males. This suggested that benefits of plasticity remained, or that costs were insufficient for any substantial negative selection (assuming that additive genetic variation in plasticity is nonzero). Although some studies have supported the existence of costs of plasticity (Agrawal et al. 2002;Merila et al. 2004;Aubret and Shine 2010), which may select for fixed genotypes in stable environments, others have failed to find evidence for it (Scheiner and Berrigan 1998;Maughan et al. 2007;van Buskirk and Steiner 2009). It has been suggested that costs of maintaining plasticity per se, independent of any cost of the phenotype, may be negligible (Murren et al. 2015). Hence the accumulation of mutational effects, rather than costs of plasticity, may be the primary driver of erosion of plasticity under stability Maughan et al. 2007;Murren et al. 2015).
Alternatively, the maintenance of plasticity in mating duration could be driven by remaining variation in the competitive environment of the sex ratio lines, to which males may continue to adaptively respond. The result that MB males significantly extended mating duration in response to rivals when mating with wild-type, but not coevolved, females suggests that although the capacity for plastic responses was maintained in these lines, it may not actually be expressed in the environment in which they have been evolving. The reason why this was not observed in males from other lines could be due to differences in selection pressures across regimes. The data do not support the existence of plasticity costs, as MB males were still capable of expressing plasticity in mating duration when mating with wild-type females. Instead the findings suggest that fixed reproductive behaviors may become more beneficial than plasticity when the social environment increases in stability.

BEHAVIOR
Overall, the results showed that the dietary resource level regimes did not affect the ability of males to invest in reproduction or express plasticity. When the responses of focal males to wild-type rivals and wild-type females were tested, there was a significant interaction between sex ratio and diet for predicting mating duration. However, this appeared to be driven by particularly short mating duration among the 20% yeast no-rival EQ treatment. There was no general pattern of males evolved on the proteinrestricted diet mating for shorter durations, or fathering fewer offspring. This does not support the prediction that nutritional limitation within the evolutionary regimes affected the allocation of reproductive resources. The dietary protein restriction imposed by the evolutionary 20% yeast diet does not appear to have selected for more prudent reproductive strategy in the lines maintained on this diet. Furthermore, maintaining wild-type flies on poor or rich yeast diets in the three days prior to mating also had no effect on mating duration. Taken together, these results suggest that this dietary restriction did not limit the level or flexibility of male D. melanogaster mating duration. Previous findings suggested that protein restriction resulted in males fathering few offspring and securing fewer rematings (Fricke et al. 2008) and affected courtship intensity and testis mass (Droney 1998). However, the effects of protein restriction were not consistent across male reproductive traits in the current study, and it may be that other dietary components have a stronger impact on male reproductive investment. For example, carbohydrate may be the primary requirement for energetically demanding male mating behavior, whereas protein may be more important for female egg production (Maklakov et al. 2008). Previous research has similarly found that a low yeast dietary regime did not limit the expression of plastic mating duration by male D. melanogaster, but suggested that imbalance in dietary components can cause loss of the extended mating response (Mason et al. 2016). Overall, there does not seem to be a simple relationship between dietary restriction and reproductive investment in male D. melanogaster. However, the finding that males retained the ability to express plasticity in mating duration under protein restriction offers further support for the idea that the costs of this plasticity may be small, or even negligible.

Conclusions
We found that fixed and plastic reproductive behaviors of male D. melanogaster can rapidly evolve in response to the competitive environment. The level of sexual competition exerted directional selection on overall mating duration, resulting in MB males generally mating for longer than EQ or FB males. This is consistent with the idea that MB males are strongly selected for "per-mating" rather than "repeated-mating" investment. MB males also expressed novel responses to rival exposure, whereby they were slower to begin mating and showed reduced courtship intensity across a range of behaviors. Interruption of courtship by rival males is likely to be ubiquitous in the MB regimes, and may have selected for the expression of alternative or truncated courtship sequences when cues of competition are detected. Plasticity in male mating duration was not found to be reduced following evolution in a relatively stable competitive environment. Taken with the finding that protein restriction had no consistent effect on the expression of reproductive plasticity, this suggests that the maintenance of plasticity itself may carry low costs.

AUTHOR CONTRIBUTIONS
The study was conceived by TC, AAD, and AB; experiments were conducted by AAD; data were analyzed by AAD and WGR; and the article was written by AAD, WGR, AB, and TC.

Supporting Information
Additional supporting information may be found online in the Supporting Information section at the end of the article. Figure S1. The mating duration of male D. melanogaster experimentally evolved under male-biased (MB) or equal (EQ) sex ratio regimes. Figure S2. The latency to mate of male D. melanogaster experimentally evolved under male-biased (MB) or equal (EQ) sex ratio regimes. Figure S3. Proportion of courtship duration spent performing each courtship behavior by male D. melanogaster, represented by a Principal Components Analysis (PCA). Figure S4. The courtship intensity of male D. melanogaster experimentally evolved under male-biased (MB) or equal (EQ) sex ratio regimes. Figure S5. The proportion of behavioral spot checks in which male D. melanogaster from experimentally evolved male-biased (MB) or equal (EQ) sex ratio regimes were observed in contact with any one of three rival males (taken as a proxy for male-male aggression). Figure S6. The number of offspring fathered by male D. melanogaster experimentally evolved under male-biased (MB), equal (EQ) or female-biased (FB) sex ratio regimes. Figure S7. The mating duration of wild-type male D. melanogaster housed alone (−) or exposed to three conspecific wild-type rivals (+) prior to mating. Figure S8. Mating duration of male D. melanogaster experimentally evolved under male-biased (MB), equal (EQ) or female-biased (FB) sex ratio regimes, on either standard (100% yeast) or protein-restricted (20% yeast) adult diets. Figure S9. The latency to mate of male D. melanogaster experimentally evolved under male-biased (MB), equal (EQ) or female-biased (FB) sex ratio, on either standard (100% yeast) or protein-restricted (20% yeast) adult diets. Figure S10. The courtship intensity of male D. melanogaster experimentally evolved under male-biased (MB) or equal (EQ) sex ratio regimes, exposed to a conspecific rival male (+) or housed alone (−) prior to introduction to a female. Table S1a. Sample sizes. Table S1b. Experiment 1. Focal male responses to wildtype rivals and wildtype females. Table S1c. Experiment 2. Focal male responses to wildtype vs. co-evolved rivals, and wildtype females. Table S1d. Experiment 3. Focal male responses to wildtype rivals and wildtype vs. coevolved females. Table S1e. Experiment 4. Analysis of courtship behaviours (multivariate stats). Table S1f. Experiment 4. Analysis of courtship behaviours (univariate stats). Table S1g. Experiment 4. Analysis of courtship behaviours (transition probabilities). Table S1h. The effect of proximate diet on wildtype males. Table S1a-Sample sizes. Sample sizes used to test mating duration, latency to mate, offspring production and courtship behavior of male Drosophila melanogaster experimentally evolved under fixed sex ratio regimes that were either male-biased (MB), equal (EQ) or female-biased (FB). Table S1b-Experiment 1. Focal male responses to wild-type rivals and wild-type females. Statistical analyses of mating duration, latency to mate and number of offspring produced by male D. melanogaster evolved under male-biased (MB), equal (EQ) or female-biaed (FB) sex ratio regimes and standard (100% yeast) or protein-restricted (20% yeast) adult diets, compared to a control group of wild-type males (CT).