Login processing...

Trial ends in Request Full Access Tell Your Colleague About Jove


Spatial Multiobjective Optimization of Agricultural Conservation Practices using a SWAT Model and an Evolutionary Algorithm

Published: December 9, 2012 doi: 10.3791/4009


This work demonstrates an integration of a water quality model with an optimization component utilizing evolutionary algorithms to solve for optimal (lowest-cost) placement of agricultural conservation practices for a specified set of water quality improvement objectives. The solutions are generated using a multi-objective approach, allowing for explicit quantification of tradeoffs.


Finding the cost-efficient (i.e., lowest-cost) ways of targeting conservation practice investments for the achievement of specific water quality goals across the landscape is of primary importance in watershed management. Traditional economics methods of finding the lowest-cost solution in the watershed context (e.g.,5,12,20) assume that off-site impacts can be accurately described as a proportion of on-site pollution generated. Such approaches are unlikely to be representative of the actual pollution process in a watershed, where the impacts of polluting sources are often determined by complex biophysical processes. The use of modern physically-based, spatially distributed hydrologic simulation models allows for a greater degree of realism in terms of process representation but requires a development of a simulation-optimization framework where the model becomes an integral part of optimization.

Evolutionary algorithms appear to be a particularly useful optimization tool, able to deal with the combinatorial nature of a watershed simulation-optimization problem and allowing the use of the full water quality model. Evolutionary algorithms treat a particular spatial allocation of conservation practices in a watershed as a candidate solution and utilize sets (populations) of candidate solutions iteratively applying stochastic operators of selection, recombination, and mutation to find improvements with respect to the optimization objectives. The optimization objectives in this case are to minimize nonpoint-source pollution in the watershed, simultaneously minimizing the cost of conservation practices. A recent and expanding set of research is attempting to use similar methods and integrates water quality models with broadly defined evolutionary optimization methods3,4,9,10,13-15,17-19,22,23,25. In this application, we demonstrate a program which follows Rabotyagov et al.'s approach and integrates a modern and commonly used SWAT water quality model7 with a multiobjective evolutionary algorithm SPEA226, and user-specified set of conservation practices and their costs to search for the complete tradeoff frontiers between costs of conservation practices and user-specified water quality objectives. The frontiers quantify the tradeoffs faced by the watershed managers by presenting the full range of costs associated with various water quality improvement goals. The program allows for a selection of watershed configurations achieving specified water quality improvement goals and a production of maps of optimized placement of conservation practices.


1. Prepare Watershed Model and Provide Input Data for Optimization

  1. Create an i_SWAT database.
    1. Using a program called "rotator", build the database from multiple input databases including soils, weather, management and fertilizer.
    2. Alternatively, an existing SWAT run (possibly created with ArcSWAT or AVSWAT) can be imported with i_SWAT.exe. In this case, the program "swat_rewrite" can be used to replace management or other HRU information based on field-level data.
    3. Calibration and validation of the SWAT model should be performed at this point. The SWAT (version 2005) model incorporated within this Raccoon River Watershed EA modeling framework was originally calibrated and validated for a Total Maximum Daily Load (TMDL) study as described by Jha et al. (2010). Further calibration and validation of the SWAT model was conducted in support of the development of a Raccoon River Watershed Master Plan, as described in Agren, Inc. (2011), which is the SWAT model that was used for this study.
    4. Use a modified version of SWAT2005.exe, called SWAT2005GA.exe.
  2. Prepare file "watershed presets.csv" - This is a text file storing many of the settings specific to the Raccoon watershed. It is read by GeneticiSWAT and MapSWAT below to set multiple controls and data fields for the watershed with one click.
  3. Prepare the costs of conservation practice elements. For this example, these are stored in table [Practice Costs - Raccoon by County] in a database "Practice costs by subbasin Josh.mdb".

The total cost of a candidate solution is the sum of costs of conservation practices applied to watershed units ("hydrologic response units", or HRUs). The optimization program considers an optimal assignment of a single conservation practice from a particular set of conservation practices in every cropland HRU in the watershed. The sets of possible conservation practices assigned to an HRU are called allele sets.

  1. Create SWAT folders. For this run, 16 CPUs were used, meaning 16 copies of SWAT2005GA.exe were run in 16 separate folders (the same applies for systems with fewer CPUs, e.g. 4 folders should be created for a "quad-core" processor).

2. Select Optimization Parameters

  1. Optimization is controlled by the program called "GeneticISWAT". To perform optimization, open GeneticISWAT.exe.
    1. Go to "File", then "Open" and select the i_SWAT database "Raccoon GA.mdb".
    2. Go to "File", then "Configuration" to assign the paths to SWAT model executables (SWAT2005GA.exe).
    3. Go to "Execute", then "Select Allele Set". This step determines the combinations of conservation practices used in optimization. For this run, allele set #14 was used, which has 23 combinations of conservation practices. Available allele sets are stored in the configuration file "Alleles.csv".
    4. Go to "Execute", then select "SPEA2 Archive Baseline Aware Subset" to perform multiobjective optimization using the SPEA2 evolutionary algorithm.

Figure 1
Figure 1. Setting optimization objectives and parameters.

Optimization parameters to be selected:

Preset: Select the watershed to be optimized. Clicking "Apply" selects entries from the presets file "watershed presets.csv" to fill control values on this screen.

Output Variable: Select the environmental objectives for optimization. As selected (N Outlet, P Outlet), this defines a 3-dimensional objective function: Nitrogen (Organic N + NO3 + NH4 + NO2) averaged for 5 years at the outlet, Phosphorus (Organic P + Mineral P) averaged for 5 years at the outlet, and the total cost of conservation practices. Note that this will create a 3-dimensional tradeoff frontier. Alternative output variables can be selected, where the multiobjective program is to minimize ({Output Variable}, Total Cost).

Population size: Set initial population size. This determines the initial number of candidate solutions. When "Seed with each allele" option is selected, candidate solutions representing a uniform application of each conservation practice specified in the allele set to all cropland HRUs in the watershed are created first. The remaining candidate solutions are created by a random assignment of conservation practices from the allele set to cropland HRUs. When selecting the "Seed with each allele" option, one needs to make sure that the initial population size is at least as large as the number of alleles in an allele set (23 in this demonstration).

Number of generations: Set the desired number of generations (iterations) for the optimization run (note that the run can be restarted).

Crossover probability: When two candidate solutions are selected for creating new candidate solutions, crossover probability specifies the probability that distinct new solutions are created (set to 1 for this demonstration).

Size of temporary population: This determines the number of new candidate solutions created. Processor resources are used most efficiently when this value is an integer multiple of the number of processor threads (16 in this demonstration).

Mutation probability: Specify the probability of random change in HRU assignment to another conservation practice from the allele set. (It is set to 0.03 for this demonstration).

Number of threads: Select the number of processors or threads used. 16 is used in this demonstration.

Curve No. calibration factor: This is provided from the SWAT model calibration.

Save Population in text file: This is important to select if one wishes to restart the optimization run after the specified number of iterations is completed. Checking this option produces a text file with the allele values of every HRU in every surviving candidate solution (individual). This can be read back in to restart and continue a run.

Secondary optimization parameters

First Year: Must be set to a year after start of historical weather information, and no later than 7 years before end of this data.

Price of Corn: Used with the yield loss equation to estimate the cost of fertilizer reductions.

Scoring Method: SPEA2 Archive. Scoring determines how likely a surviving individual is to be selected for crossover.

Purge Method: Dominated. Individuals which are worse in all 3 dimensions are dominated and purged.

HUC Source: Set to "Specified Location", meaning the value "7100006" from the following field "Watershed HUC" is used to find a row in the HUC Zone table. The value "07100006" is the eight-digit HUC code for the Raccoon watershed.

Cost Source: Set to "County (HRU Location Code)" to indicate that costs other than CRP will be determined by county FIPS codes in the practice costs table above.

Cost Source CRP: Set to "1 Location" to indicate that CRP cost will be determined by county FIPS codes in the practice costs table above.

SWAT version: SWAT2005

3. Representative Results

GeneticiSWAT.exe produces a log file showing the settings and results for all candidate solutions (individuals), as well as a "save" file which encodes the results from the final algorithm iteration and which can be used to restart the optimization run.

At this point, one can visualize the entire set of Pareto-efficient solutions (the tradeoff frontier) by following the steps below:

  1. Run GeneticiSWAT;
    1. Go to "File", then "Open" to open the i_SWAT database "Raccoon GA.mdb".
    2. Go to "Execute", then "Export HRU List". Save file as "Raccoon Allele HRU.txt".
  2. Produce an animation by running Mapswat.exe, selecting "Execute" and then "3d Animation".

Figure 2
Figure 2. Screenshot for creating "snapshots" for 3-dimensional frontier visualization.

Output is a series of files which can be rendered all at once into image files by using POV-RAY program and selecting "Render", then "File Queue". The images can be used on their own or combined into a movie showing the algorithm progression.

Figure 3
Figure 3. Static visualization of the tradeoff frontier.

If desired, a movie showing the algorithm progression can be created by running "Framescanner.exe" and following these steps:

  1. Go to "File", then "New", then "File", then "Import", then "PNG Files". Select the static images.
  2. To create a movie, go to "File", then "Export", then "AVI".
  3. Select codec "DIB" to create AVI files from batches of image files.

Each point in the frontier represents a watershed configuration (a specific assignment of conservation practices on a landscape). Maps of these configurations can be seen for the entire frontier by following these steps:

  1. Run Mapswat.exe, select "Execute", then "Map Animation".
  2. Select "Raccoon" from preset list and click "Apply".
  3. Select "Layout 7 (Raccoon)" from Map Layout list, then click "OK".

Figure 4
Figure 4. Screenshot of creating a map of each individual in the final frontier.

Exporting specific watershed configurations (individuals) of interest.

Often a question of interest is to select specific watershed configurations (individuals) achieving particular water quality objectives. For example, one may wish to find an individual in the frontier which reduces Nitrogen by 30% and Phosphorus by 20% relative to baseline loadings. MapSWAT allows one to search the frontier for the individual with the smallest Euclidean distance to the specified objective. This can be done by doing the following:

  1. Open MapSWAT.exe. Select "Execute" | "Search".

Figure 5
Figure 5. Screenshot of searching for a specific individual in the frontier based on water quality objectives.

  1. Enter minimum and maximum reduction targets Tmin and Tmax as well as an interval Tint. Also enter a specific percent reduction in Nitrogen (Nspec) from baseline in the "% reduction" space next to N Baseline, and percent reduction in Phosphorus (Pspec) in the "% reduction" next to Phosphorus baseline. The program produces output in a popup screen:

Figure 6
Figure 6. Screenshot of search output

  1. Click "Copy Text" and paste into a spreadsheet. Three tables are produced. In the first are individuals nearest to N and P targets of the same percent reduction, which ranges from Tmin to Tmax by Tint. Just below this the closest single individual to the target (Nspec, Pspec) appears. Second, a table giving nearest individuals where the P target ranges from Tmin to Tmax while N is held constant near Nspec. Third, a table giving individuals nearest N targets ranging from Tmin to Tmax while P is held constant near Pspec. In this case, the closest individual to a 30% N reduction was ID 8423 with an N value of 14,637,279.60. Here is the map showing the spatial distribution of conservation practices and the location of this watershed configuration in the tradeoff frontier:

Figure 7
Figure 7. Screenshot of a sample map describing the selected individual in the frontier. Click here to view larger figure.

Exporting map data for further analysis is possible by following these steps:

  1. Run Mapswat.exe, select "Execute", then "Export Map Data".
  2. Select "Raccoon" from preset list and click "Apply".
  3. Enter the ID of a watershed configuration (individual) (8423 shown), check "Show Allele Properties" and "Show Costs", and then click "OK". This data can be used to create custom maps of the selected watershed configuration using a GIS program.
Name of Program Source Description
Rotator CARD Creates and fills an i_SWAT database with soil, weather, and management data for a watershed.
Swat2005GA.exe USDA Grassland, Soil & Water Research Laboratory Watershed simulation model
i_SWAT.exe CARD SWAT database interface
GeneticISWAT.exe CARD Evolutionary algorithm SWAT controller. Incorporates GALib from http://lancet.mit.edu/ga/.
MapSWAT.exe CARD Reads i_SWAT databases and shapefiles, produces images of generations and individuals.
POV-Ray Povray.org Persistence of Vision raytracer.
Framescanner.exe Todd Campbell PNG image to AVI converter
Windows Live Movie Maker Microsoft Used to compress AVI to WMV

Table 1. Table of programs required.

Name of File Type Description
Raccoon GA.mdb Access database Structure and management descriptions of Raccoon watershed. Read by GeneticiSWAT and MapSWAT.
watershed presets.csv Text Setting presets for GeneticiSWAT.exe and MapSWAT
Alleles.csv Text List of allele sets for evolutionary algorithm.
Raccoon Allele HRU.txt Text File created by GeneticISWAT listing those alleles determined to be cropland. Read by MapSWAT.
Practice costs by subbasin Josh.mdb Access Database Costs by management practice and county.
Terrace Zones.mdb Access Database Table [HUC Data] holds the terrace and yield zone numbers for the watershed.
NRI Budgets.mdb Access Database Read by GeneticISWAT.exe for crop & machine tables which are not used in this run.
phucrp 2008-12-15.dat Text Plant Heat Unit lookup table, not used in this run.
Management.mdb Access Database Rotation lookup table, not used in this run.
Raccoon GA 2011-09-28 1313.log, Raccoon GA 2011-09-29 0732.log, Raccoon GA 2011-10-07 0644.log Text Log files of GeneticISWAT run.
Raccoon GA.wmv Animation 3d display of individuals by generation
Subbasin.shp ESRI Shapefile Outlines of subbasins in the watershed.
Raccoon Map.wmv Animation Display of dominant alleles for each subbasin for each individual on the frontier.

Table 2. Table of sample files required.

Subscription Required. Please recommend JoVE to your librarian.


We build an integrated simulation-optimization framework to search for Pareto-efficient sets of watershed configurations involving lowest-cost mix and location of agricultural conservation practices to achieve a range of watershed-level nutrient reduction objectives. A conceptual diagram of the simulation-optimization system is presented in Figure 8. Watershed simulation, including simulating the water quality impacts of agricultural conservation practices are handled by the hydrologic model, SWAT2005, coupled with a Windows-based database control system, i_SWAT6,8. The optimization component operates on the hydrologic response units (HRUs) of SWAT and employs the logic of an evolutionary algorithm26 to find the allocation of conservation practices which simultaneously minimizes nutrient loadings (N, P, or both) and the cost of conservation practices. After the algorithm iterations are terminated, a set of surviving individuals represents the approximate tradeoff frontier. Since two nutrients are being considered simultaneously (nitrate-N and total phosphorus), we obtain a three-dimensional tradeoff frontier. Each individual point on the tradeoff frontier prescribes a particular configuration of conservation practices for each decision-making unit (cropland HRU) in the watershed. To see which conservation practices are selected, we have to specify nutrient targets and then search the tradeoff frontier for individual configurations which meet the nutrient reduction criteria. The location and the mix of conservation practices selected can be mapped back to the field-level spatial decision-making units in the watershed (if such data is available at the time of creating HRUs). Our approach, which specifies a particular mix and distribution of conservation practices, can provide policymakers with tools for better targeting of conservation policy aimed at water quality improvements. In terms of implementation, armed with the algorithm's prescriptions, policymakers can offer targeted payments (method suggested by11), or elicit bids and accept or reject them using modeling results as guidance. Of course, the specific set of practices targeted depends on particular water quality goals and the specific watershed studied. However, future improvements in the hydrologic model and the economic cost estimates can readily be incorporated into the simulation-optimization system. The framework developed is readily generalizable and is capable of providing useful and policy-relevant insight into a complex problem of nonpoint source pollution reductions.

Figure 8
Figure 8. Overall flow of the experiment.

Subscription Required. Please recommend JoVE to your librarian.


No conflicts of interest declared.


This research was funded in part from support received from the U.S. Environmental Protection Agency's Targeted Watersheds Grants Program (Project # WS97704801), the National Science Foundation's Dynamics of Coupled Natural and Human Systems (Project #DEB1010259-CARD-KLIN), and the U.S. Department of Agriculture-National Institute of Foodand Agriculture's Coordinated Agricultural Project (Project # 20116800230190-CARD-).


  1. American Society of Agricultural and Biological Engineers. Design, layout, construction, and maintenance of terrace systems. ASAE Standard. , S268 (2003).
  2. Raccoon River Watershed water quality master plan. , Agren, Inc. Carroll, IA. (2011).
  3. Arabi, M., Govindaraju, R. S., Hantush, M. M. Cost-effective allocation of watershed management practices using a genetic algorithm. Water Resour. Res. 42, W10429 (2006).
  4. Bekele, E. G., Nicklow, J. W. Multiobjective management of ecosystem services by integrative watershed modeling and evolutionary algorithms. Water Resour. Res. 41, W10406 (2005).
  5. Carpentier, C. L., Bosch, D. J., Batie, S. S. Using spatial information to reduce costs of controlling agricultural nonpoint source pollution. Am. J. Agr. Econ. 61, 404-413 (1998).
  6. CARD: Resource and Environmental Policy Interactive Software Programs [Internet]. , Center for Agricultural and Rural Development, Iowa State University. Ames, IA. Available from: http://www.card.iastate.edu/environment/interactive_programs.aspx (2007).
  7. Gassman, P. W., Reyes, M., Green, C. H., Arnold, J. G. The Soil and Water Assessment Tool: Historical development, applications, and future directions. Trans. ASABE. 50 (4), 1211-1250 (2007).
  8. The i_SWAT software package: a tool for supporting SWAT watershed applications. Gassman, P. W., Campbell, T., Secchi, S., Jha, M., Arnold, J. G. SWAT2003: The 2nd International SWAT Conference, 1-4 July, Bari, Italy, , Instituto di Ricerca sulle Acque, IRSACNR. Bari, Italy. 66-69 Forthcoming.
  9. Gitau, M. W., Veith, T. L., Gburek, W. J., Jarrett, A. R. Watershed level best management practice selection and placement in the Town Brook watershed, New York. J. Am. Water Resour. Assoc. 42, 1565-1581 (2006).
  10. Jha, M., Rabotyagov, S., Gassman, P. W. Optimal placement of conservation practices using genetic algorithms with SWAT. Int. Agr. Eng. J. 18 (1-2), 41-50 (2009).
  11. Jha, M. K., Wolter, C. F., Schilling, K. E., Gassman, P. W. Assessment of total maximum daily load implementation strategies for nitrate impairment of the Raccoon River, Iowa. J. Envir. Qual. 39, 1317-1327 (2010).
  12. Kanna, M., Yang, W., Farnsworth, R., Onal, H. Cost effective targeting of CREP to improve water quality with endogenous sediment deposition coefficients. Am. J. Agr. Econ. 85, 538-553 (2003).
  13. Kramer, R. A., McSweeny, W. T., Kerns, W. R., Stravros, R. W. An evaluation of alternative policies for controlling agricultural nonpoint source pollution. Water Resour. Bull. 20, 841-8446 (1984).
  14. Lant, C. L., Kraft, S. E., Beaulieu, J., Bennett, D., Loftus, T., Nicklow, J. Using GIS-based ecological-economic modeling to evaluate policies affecting agricultural watersheds. Ecol. Econ. 55, 467-484 (2005).
  15. Muleta, M. K., Nicklow, J. W. Evolutionary algorithms for multiobjective evaluation of watershed management decisions. J. Hydroinform. 4 (2), 83-97 (2002).
  16. Muleta, M. K., Nicklow, J. W. Decision support for watershed management using evolutionary algorithms. J. Water Resour. Plan. Manag. 131 (1), 35-44 (2005).
  17. Rabotyagov, S. S., Campbell, T., Jha, M., Gassman, P. W., Arnold, J., Kurkalova, L., Secchi, S., Feng, H., Kling, C. L. Least Cost Control of Agricultural Nutrient Contributions to the Gulf of Mexico Hypoxic Zone. Ecol. Appl. 20, 1542-1555 (2010).
  18. Rabotyagov, S., Jha, M., Campbell, T. Impact of crop rotations on optimal selection of conservation practices for water quality protection. J. Soil. Water Conserv. 65 (6), 369-380 (2010).
  19. Rabotyagov, S. S., Jha, M., Campbell, T. D. Nonpoint-source pollution for an Iowa watershed: An application of evolutionary algorithms. Canadian Journal of Agricultural Economics/Revue canadienne d'agroeconomie. , (2010).
  20. Rabotyagov, S. S., Jha, M., Campbell, T. Searching for Efficiency: Least Cost Nonpoint Source Pollution Control with Multiple Pollutants, Practices, and Targets. J. Nat. and Environ. Sci. 1, 75-90 (2010).
  21. Ribaudo, M. O. Consideration of off-site impacts in targeting soil conservation programs. Land Econ. 62, 402-411 (1986).
  22. Ribaudo, M. O. Targeting the conservation reserve program to maximize water quality benefits. Land Econ. 65, 320-332 (1989).
  23. Srivastava, P., Hamlett, J. M., Robillard, P. D., Day, R. L. Watershed optimization of best management practices using AnnAGNPS and a genetic algorithm. Water Resour. Res. 38 (3), 1-14 (2002).
  24. Veith, T. L., Wolfe, M. L., Heatwole, C. D. Development of optimization procedure for cost-effective BMP placement. J. Am. Water Resour. Assoc. 39 (6), 1331-1343 (2003).
  25. GAlib: Matthew's Genetic Algorithms Library [Internet]. , Available from: http://lancet.mit.edu/ga/ (1996).
  26. Whittaker, G., Confesor, R., Griffith, S. M., Färe, R., Grosskopf, S., Steiner, J. J., Mueller-Warrant, G. W., Banowetz, G. M. A Hybrid Genetic Algorithm for Multiobjective Problems with Activity Analysis-based Local Search. Eur. J. Operat. Res. , (2007).
  27. Zitzler, E., Laumanns, M., Thiele, L. SPEA2: Improving the Strength Pareto Evolutionary Algorithm for Multiobjective Optimization. CIMNE. , 95-100 (2002).


Spatial Multiobjective Optimization Agricultural Conservation Practices SWAT Model Evolutionary Algorithm Cost-efficient Targeting Water Quality Goals Watershed Management Traditional Economics Methods Off-site Impacts On-site Pollution Complex Biophysical Processes Physically-based Models Simulation-optimization Framework Combinatorial Nature Candidate Solutions Stochastic Operators
Spatial Multiobjective Optimization of Agricultural Conservation Practices using a SWAT Model and an Evolutionary Algorithm
Play Video

Cite this Article

Rabotyagov, S., Campbell, T., Valcu, More

Rabotyagov, S., Campbell, T., Valcu, A., Gassman, P., Jha, M., Schilling, K., Wolter, C., Kling, C. Spatial Multiobjective Optimization of Agricultural Conservation Practices using a SWAT Model and an Evolutionary Algorithm. J. Vis. Exp. (70), e4009, doi:10.3791/4009 (2012).

Copy Citation Download Citation Reprints and Permissions
View Video

Get cutting-edge science videos from JoVE sent straight to your inbox every month.

Waiting X
Simple Hit Counter