Week 2: Optimization Algorithms and Riparian Buffers

Mar 17, 2023

Hi, everyone!

Welcome back to my senior project blog. This week in my internship, I finished coding my heat optimization problem and began a new one–a genetic, or evolutionary, algorithm. Genetic algorithms are optimization methods where, in each generation, the best ‘individuals’ (data sets) are kept and their ‘chromosomes’ (characteristics/values) mixed to form new individuals. A ‘fitness’ measure (cost function) determines which individuals survive to the next generation. I also added ‘mutations’ (random changes in values within the data sets) to try to achieve a fitter individual and get characteristics not present in the original population. Genetic algorithms are useful, for example, in optimizing the shape of an airplane wing (the cost function would be related to air resistance) to see which shapes were best. As any programmer knows, most of the time spend coding is finding and fixing bugs in the code, which can be frustrating but also rewarding. Did you know that ‘bugs’ are so named because in the first computers, actual insects would get into the machine and cause errors, and programmers had to go in, find them, and remove them? I’m glad all the errors I face in my code today are of my own doing, and therefore solvable through logic, not taking apart my computer.

I included a picture of a simulated simple car in a wind tunnel showing the air velocity around the car. I couldn’t resist; I find the models fascinating and want to share them with you.

I also began reading some of the many articles that will teach me all about rainfall, stormwater, pollution, and runoff models. Right now, I am reading about riparian buffers. I learned that they are best at mitigating nutrients in surface water, but not groundwater. There have been many efforts at establishing or maintaining riparian buffers, but Lee et al. argue that efforts to measure their effectiveness have not been as plentiful (Lee, S., McCarty, G. W., Moglen, G. E., Li, X., & Wallace, C. W. (2020). Assessing the effectiveness of riparian buffers for reducing organic nitrogen loads in the Coastal Plain of the Chesapeake Bay watershed using a watershed model. Journal of Hydrology, 585, 124779. doi:10.1016/j.jhydrol.2020.12). Since field evaluation of conservation practices is cost-, labor-, and time-intensive, models of water flow and nutrient flow and absorption have been the main focus recently in determining ‘best management practices’ of pollutants and conservation efforts. There are many of these tools, including the Soil and Water Assessment Tool that Lee et al. used, and I will study them in more depth and tell you more about them next week.

Until then,


This is an example plot of the genetic optimization code that I wrote and plotted. From one generation (curve) to the next, the observed characteristics (blue=best individual; green=worst individual) get closer to the desired characteristics (orange).


Photo credit: Dr. Löhner did most of the CAD to display this car. From George Mason University, Center for Computational Fluid Dynamics. Notice the lower velocity areas in front of and behind the car on the ground (pinkest=fastest-moving air).


3 Replies to “Week 2: Optimization Algorithms and Riparian Buffers”

  1. Arthur H. says:

    Hi, Daria. Do you think that mutations would allow some generations to live on and pass on those mutated genes? Also, do you control the mutations for each generation or just make one at the beginning and see how much they spread?

    1. Daria L. says:

      When forming the new individuals for the new generation, I mix the characteristics of the top 20% from the last generation. Then, if the values for any two individuals in the new generation are too close (distance within a set parameter, which I experimented with changing), I add/subtract randomly a multiple of that set parameter (a mutation) to one of the characteristics (which in this case are numerical values) in one of the individuals. I do this until no two individuals’ characteristics are within that distance. This prevents the population from becoming uniform, and these mutations do carry on to that new generation, which I run through the algorithm to form the next generation after that one, and so on.

  2. Raleigh W. says:

    Hi Daria! Wow, your work looks cool. I can’t wait to see how you incorporate porosity in your final model. Do you think it will take a lot of computer resources to run?

    If you are going to write about rivers, you will need synonyms for “riparian.” If you haven’t encountered these already, “riverine” and “fluvial” are pretty much direct synonyms. “Fluviatile” if you’re fancy, “fluviomarine” and “fluviolacustrine” for phenomena produced by the joint action of rivers and the sea and lakes, respectively. “Riverlike,” “riverward,” “rivery”… so fun!

Leave a Reply