## 1 Introduction
For example, some algorithms imitate the social behavior of animals [13], while others might follow the laws of physics to find the best solution. These algorithms are classified into two groups: classic and new-generation algorithms [14]. Classic algorithms, such as the genetic algorithm, have been applied for many engineering problems. It should be noted that classic algorithms might provide proper answers to many problems. However, new generation algorithms, such as the bat algorithm (BA), have been developed to improve the efficiency of optimization [15]. Water quality modeling is another aspect that should be briefly reviewed. Many models have been developed in this regard. However, runoff modeling in agricultural lands needs a model that is able to simulate water quality at the river basin scale. The soil and water assessment tool (SWAT) is one of the most applicable and best-known models for simulating runoff and water pollutants on the river basin scale. This model has been used in many aspects of river basin management in recent studies. For instance, the SWAT was able to simulate the impacts of pesticides in a data-scarce river basin [16]. Moreover, nitrogen leaching was estimated using the SWAT because of winter cover crops [17]. The calibration of the outputs is one of the important steps in using SWAT in practical projects [18]. The SWAT can simulate runoff and water pollutants continuously, which indicates its advantages in agricultural planning. A recent study highlighted the importance of continuous hydrologic simulation in river basin management [19]. Moreover, the SWAT can be used to explore the impact of land change dynamics as well as the impacts of climate change on water quality [20]. We describe the research gap that motivated this study. The optimization of cropping patterns has been described in many previous studies, as cited in the previous paragraphs. However, the previous studies have only considered economic benefits and water con sumption in cropping pattern optimization. The cropping pattern is effective at addressing environmental challenges such as increasing the nitrate concentration in the natural drainage network or the river network of the catchments. Thus, the cropping pattern must be optimized considering environmental purposes. Hence, this study was carried out to design a new cropping pattern that minimizes the nitrate contaminants running off to river networks through agricultural drainage. Based on the above research gap, the objective of this study was to develop and evaluate a novel framework to optimize the cultivation pattern on the catchment scale that mitigates the environmental impacts of runoff from farms. The SWAT was utilized as a water quality model on the catchment scale. Then, the outputs of this model were coupled with an optimization model that minimized the difference between the defined threshold of the water quality parameters and the actual concentration in a simulated period. We selected nitrate as one of the most important pollutants in river ecosystems. High nitrate concentrations might dramatically harm aquatic environments. Initial ecological studies indicated that higher nitrate concentrations can reduce the population of fish species in a case study. Thus, it was selected as a critical water quality parameters in the study area for optimizing the cropping pattern. The main source of the increased nitrate concentration was the agricultural drainage in the study area according to the initial measurements of the nitrate concentration downstream of the agricultural land. Thus, controlling nitrate concentration is a critical task for managing the river habitats in the case study. This study opens new windows to optimize cropping patterns, which is necessary for the sustainable development of agriculture and mitigating its environmental impacts.