MetaIPM: Placing integral projection models into a metapopulation framework

Metapopulation models include spatial population dynamics such as dispersion and migration between subpopulations. Integral projection models (IPMs) can include demographic rates as a function of size. Traditionally, metapopulation models do not included detailed populaiton models such as IPMs. In some situations, both local population dynamics (e.g. size‐based survival) and spatial dynamics are important. We present a Python package, MetaIPM, which places IPMs into a metapopulation framework, and allow users to readily construct and apply these models that combine local population dynamics within a metapopulation framework. MetaIPM includes an IPM for each subpopulation that is connected to other subpopulations via a metapopulation movement model. These movements can include dispersion, migration or other patterns. The IPM can include for size‐specific demographic rates (e.g. survival, recruitment) as well as management actions, such as length‐based harvest (e.g. gear specific capture sizes, varying slot limits across political boundaries). The model also allows for changes in metapopulation connectivity between locations, such as a fish passage ladders to enhance movement or deterrents to reduce movement. Thus, resource managers can use MetaIPM to compare different management actions such as the harvest gear type (which can be length‐specific) and harvest locations. We demonstrate how MetaIPM may be applied to inform managers seeking to limit the spread of an invasive species in a system with important metapopulation dynamics. Specifically, we compared removal lengths (all length fish versus longer fish only) for an invasive fish population in a fragmented, inland river system. MetaIPM allowed users to compare the importance of harvesting source populations away from the invasion front, as well as species at the invasion front. The model would also allow for future comparisons of different deterrent placement locations in the system. Moving beyond our example system, we describe how MetaIPM can be applied to other species, systems and management approaches. The MetaIPM packages includes Jupyter Notebooks documenting the package as well as a second set of JupyterNotebooks showing the application of the package to our example system.


| INTRODUC TI ON
Metapopulations describe populations of subpopulations (Hanski, 1999). Historically, metapopulation theory focused on patch dynamics, but it has now emerged as a field of spatial ecology with increasing emphasis on linking time and space (Ellner, 2001).
In addition to metapopulation processes, size distribution of individuals may be important to consider when describing population dynamics. For example, individual sizes can be crucial for management, as size affects survival (Miehls et al., 2014), movement among locations (Noonan et al., 2011;Prchalov'a et al., 2011), reproduction potential (Lambert, 2008), and harvesting strategies (Gwinn et al., 2013). An integral projection model (IPM) allows for size distributions (e.g. length) to be directly modelled as a continuous, state variable (Ellner et al., 2016). These differ from matrix models, another more commonly used type of model, that can account for length or age classes by using discrete length bins. In practice, the numerical representations of IPMs and length-based matrix models can be identical and yield the same results if the integration method for the IPM uses the same discrete bins as the matrix model. The benefit of using an IPM over a matrix model is that an IPM can accommodate continuous (e.g. length) and discrete state variables (e.g. life-stages), whereas a matrix model must accommodate the continuous state variables in an ad hoc manner (Smallegange et al., 2016).
We have recognized a need for metapopulation assessments that include length-based population models for species management, in general, and for freshwater fisheries, in particular. For example, management actions in river systems such as the Mississippi River Basin are often fragmented by locks-and-dams into pools (Chick et al., 2006) as well as jurisdictional boundaries (Hupfeld et al., 2016).
Yet, freshwater fisheries management has lagged behind marine fisheries (and other areas of applied ecology) in incorporating metapopulation dynamics into plans and decision-making. Specifically, inland fisheries programs in the United States do not regularly use metapopulation models for management in river systems such as the Mississippi River Basin (D.C. Glover, personal observation). To fulfil this need, we developed MetaIPM.
MetaIPM consists of two major sub-models: a spatial metapopulation model and a length-based IPM. The metapopulation model expands upon notation from Taylor and Norris (2009). The entire model is a network, which is comprised of spatially discrete nodes connected by paths. Our example application describes silver carp Hypophthalmichthys molitrix in the Illinois River, USA, where both the location (pool) and the length of harvested silver carp may influence species management. The network corresponds to the Illinois River, with river pools being nodes. These pools are discrete because a series of locks-and-dams fragment the river, creating a metapopulation pattern . The groups correspond to the male and female subpopulations in each pool. Groups could also be used for other sub-populations (e.g. YY-males, genetic sub-populations, juvenile/adult age-classes). In MetaIPM, groups serve as the basic accounting level and most population dynamics occur within nodes.
The groups also capture length distributions, another important consideration for the management of silver carp.
MetaIPM builds upon previous efforts. Erickson et al. (2017) used R scripts to implement an IPM examining grass carp Ctenopharyngodon idella control with YY-males.  continued to use grass carp as an example species and added metapopulation dynamics and switched to Python scripts because it more readily allowed the use of object-oriented programming (OOP) and abstraction. OOP is a type of programming that focuses on organizing code and code functionality around computer 'objects' rather than logic or functions. Erickson et al. (2017, as well as tutorials found within Erickson, Peirce, et al. (2021), contain the equations and formal documentation for MetaIPM.

| Overview
Our current work expands upon  by placing the code into a Python package, MetaIPM, for easier use compared to lose Python module files (Erickson, Peirce, et al., 2021).

MetaIPM includes both deterministic and stochastic options for
parameter values (i.e. either single values or tables of possible value to be randomly selected) and recruitment (i.e. either a fixed recruitment rate, or annual stochastic recruitment based upon a includes Jupyter Notebooks documenting the package as well as a second set of JupyterNotebooks showing the application of the package to our example system.

K E Y W O R D S
connected habitats, integral projection model, length-based models, network models, population ecology distribution). When placing MetaIPM into a Python package, we followed clean coding principles including test-driven development, OOP, linting and version control (Martin, 2009;Thomas & Hunt, 2000). Vedder et al. (2021) notes how ecologists increasingly use and value these practices for modelling and software development. Lastly, MetaPIM uses the term group for biological sub-populations (e.g. males, females) rather than class because class has a specific definition for OOP (e.g. MetaIPM uses 'female groups' rather than 'female class').
Major classes within the model include a network that holds paths and nodes, which hold groups. Major model functions act upon the network, which iterates over nodes and paths. In turn, nodes and paths iterate over groups. For example, the class network_projection() projects the population distribution through time for groups inside of nodes. We include five tutorials as Jupyter Notebooks to demonstrate MetaIPM (Erickson, Peirce, et al., 2021): • Deterministic_example.ipynb shows a deterministic example.
• Stochastic_example.ipynb shows stochastic examples with stochastic recruitment probability, selection from the stochastic demographic or movement parameters distributions, or both forms of stochasticity.
• yy-male_example.ipynb shows an example with YY-males as a control tool.
Following Ellner and Rees (2006), we numerically approximated solutions to our IPM using the midpoint rule. For readers requiring more advanced methods, Pollesch et al. (2022) details methods that allow for smaller growth of individuals in each time step without causing numerical instability.

| Data inputs
MetaIPM requires three broad types of data. First, MetaIPM requires descriptive information about the groups (e.g. female/male sub-populations), nodes (discrete spatial habitat patches) and the network (the collection of nodes and their connecting paths). This includes details (e.g. recruitment location, recruitment probabilities), management parameters (e.g. harvest details) and numerical settings (e.g. the number of simulation years, mesh size for integration).
These inputs also control the stochastic recruitment option (e.g. to what extent does spawning occur within a given year?). Rather than a binary yes/no to recruitment, a probability multiplier is used to allow for high (closer to 1.0) and low (closer to 0.0) recruitment years compared to the model's maximum recruitment. Alternatively, a constant deterministic spawning option may be specified as well.
In the deterministic case, the recruitment probability is multiplied by recruitment every year.
Second, MetaIPM requires demographic rate data for groups.
These include length-weight relations, female maturity curves, and growth curve parameters. These parameters may be estimated using tools such as the fishStan v2.0 package (Erickson et al., 2020). An example application of this package on a large dataset can be found in Erickson, Kallis, et al. (2021a). When running the stochastic model, different draws from the posterior distribution are used for each simulation run. When running the deterministic model, the mean for each parameter is used. These parameters may be specified for each node. If parameters do not exist for a node, the hyper parameter is used instead.
Third, MetaIPM requires movement data. Coulter et al. (2018) provides an example of how to generate movement data and Coulter et al. (2022) provides an example dataset. Movement data includes movement probabilities between specific nodes. The probability of staying within a node is calculated by subtracting out the probability of leaving a node. If a posterior distribution is provided, different movement probabilities may be used for each simulation run.
Otherwise, the mean movement probabilities may be used in the model.
Notably, MetaIPM requires movement data between nodes when self-constructing the model. Otherwise, nodes will not be included within the model itself. Conversely, missing demographic data will be replaced with hyper-parameters for any missing values.

| C A S E S TUDY
Silver carp infest the Mississippi River Basin. Concern exists the species will spread to the Great Lakes via an artificial connection between the Illinois River and Lake Michigan. Coulter et al. (2018) described the study system, its invasive carp problem and challenges managers face in the system. Notably, the Illinois River has six pools with carp and recruitment occurs in the three most downriver pools. The uppermost infested pool is closest to the connection with Lake Michigan. The upper three lock-and-dam structures also differ compared to the lower three pools. These structures limit movement and would also allow movement deterrents to be installed.
Hence, resource managers had questions such as: Where to harvest fish? What size fish need to be harvested? For this case study, we compared harvesting 80% of all fish in all pools to harvesting only 80% of large fish. This demonstrates how IPMs, and more specifically MetaIPM allows the direct modelling of populations where length-based distributions are important. We used a posterior distribution of demographic data (previously estimated using fishStan v2.0 package [Erickson et al., 2020] on a large dataset [Erickson, Kallis, et al., 2021a]). Likewise, we used hydroacoustic data to scale the relative starting carp populations (Coulter et al., 2019). Lastly, Coulter et al. (2018) estimated movement probabilities of silver carp F I G U R E 1 Example distribution of the monthly length of the silver carp population of Alton pool for three different model years (colours in the plot). Simulated fish length is in m. These simulation results were from a deterministic result without recruitment stochasticity. Months start with 0 rather than 1 following Python's indexing. among different pools using telemetry movement data in combination with multi-state models. Erickson et al., 2022 includes the code and details for this example.
With this application, MetaIPM models fish length through time as a state variable (e.g. Figure 1). Furthermore, and, of more interest, the model provided insight into harvest size. Figure 2 shows the results of only harvesting large fish compared to all length fish. Downriver, this change in harvest had a much greater effect on population size. More specifically, harvest location and size of fish removed interact such that size of harvested fish has little impact upstream but in downstream pools all sizes of fish should be removed. Thus, harvest length is important of one wants crash the entire population, but, less important if one only wants to limit the population at the invasion front due to the metapopulation dynamics of the system. Erickson, Peirce, et al. (2021) and Erickson et al. (2022) provides the case study files as rendered Jupyter Notebooks that may be viewed directly online. Specifically, the Jupyter Notebooks located in Tutorial folder of https://doi.org/10.5066/P9PW673G and the IL_example.ipynb filer located in the main level of https://doi. org/10.5066/P92VZXP7 may be viewed directly in browsers.

| DISCUSS ION
We demonstrate how MetaIPM may be used to combine individual characteristics (or population dynamics) such as length with metapopulation models to more accurately direct management actions. Erickson, Kallis, et al. (2021b), Erickson, Peirce, et al. (2021) and Erickson et al. (2022) presents code that would readily allow the model to be applied to evaluate other removal strategies for silver carp in the Illinois River or movement deterrent placement scenarios.
Movement deterrents, although not considered within our model, can be included within the MetaIMP package. Outside information about catch efforts and costs would also allow the model to be directly used for cost-befit analysis for different control strategies.
More broadly MetaIPM will help others to model populations that exist in metapopulation, yet, have important dynamics within F I G U R E 2 Boxplots of silver carp population sizes (in each pool) during the last year of harvest (year 19) and 5 years post harvest (year 25). Each pool contains scenarios of harvesting of all length fish, harvesting of large fish, and no carp harvest, as denoted by colour (and boxplot order left to right). Alton is the most downriver pool, then La Grange, Peoria, Starved Rock, Marseilles and Dresden Island is the most upriver pool. For the large fish harvest scenario, we used a logistic function with a harvest_inflection of 0.5 m and harvest_slope of 10 with a maximum harvest level as 80%. Boxplots depict the middle 50% of data with the box, the median with the bar, and the top and bottom 25% of data with the tails. Dots are outliers with values that are greater than 1.5 × the interquartile range. each subpopulation. For example, dam removal projects and fish passage projects seek to reconnect native populations and address habitat fragmentation (e.g. Chick et al., 2006). MetaIPM would lend itself to these systems, especially if source-sink dynamics are important. A closely related application would be fisheries systems where political boundaries create subpopulations with different management actions (e.g. Rypel et al., 2021). For example, a river passing through multiple jurisdictions could have different slot limits (or length-based limits). Applying MetaIPM to these systems would provide an understanding of the population-level effects of these management approaches. Metapopulation dynamics can also be important for marine fisheries management (e.g. Sale et al., 2006). MetaIPM would assist in understanding these systems and also allow for different size-based management scenarios to be considered and evaluated. In addition to traditional fisheries management, MetaIPM also includes options to readily allow synthetic biology applications. Synthetic biology includes tools such as gene drives, genetically modified organisms (GMO) and similar technologies (Harvey-Samuel et al., 2017). MetaIPM also includes an example application of stocking non-GMO yy-males as an approach to skew the sex-ratio of a population and cause the population to crash (e.g. efforts similar to Erickson et al., 2017.

CO N FLI C T O F I NTER E S T S TATEM ENT
The authors report no conflicts of interest.

DATA AVA I L A B I L I T Y S TAT E M E N T
Both MetaIPM and our example have been released as USGS software releases (Erickson et al., 2022;Erickson, Peirce, et al., 2021). Data required for the example application have been released for the movement data (Coulter et al., 2022) and demographic data (Erickson, Kallis, et al., 2021a).