## 4 Algorithms
### Production of Next Generation of Solutions  
The next generation of solutions is produced using the classic steps of a genetic algorithm [63; 64]: (1) convert the solutions into chromosomes, (2) calculate the fitness function of each solution, (3) perform crossover and mutation of chromosomes, and (4) fine-tune the chromosomes.  
Suppose the target region contains a total of \(n\) areas. We use \(n\) bits to represent each solution. If one bit is 0, irrigation to the corresponding area has been stopped. If not, then water is still supplied. Note that upstream-downstream continuity is considered during the production of the initial solutions and in their crossover and mutation with subsequent chromosomes. The water supply must also fall within the set range.  
The fitness function of each solution is designed to equal (\(1/(dom+1)\)), where _dom_ denotes the number of times each solution is dominated; this was calculated in the previous section. The more times a solution is dominated, the further away it is from the final skyline solutions; the fewer times it is dominated, the closer it is.  
An issue unique to irrigation decision support is the preservation of upstream-downstream relationships among waterways. Applying conventional GAs crossover and mutation rules would result in (1) solutions with discontinuous water supply conditions and (2) solutions with total water demand outside of the set range. We, therefore, designed new chromosome crossover and mutation rules. Suppose the chromosomes crossing over are \(p\) and \(q\): The algorithm will first randomly select a bit as the crossover point and exchange all of the chromosomes in \(p\) and \(q\) downstream of the point. Note that if an exchanged area in a chromosome does not connect upstream, all of the bits in the area linking upstream to the canal are changed to 1. Next, the algorithm randomly selects a bit in the chromosome as the mutation point. If the bit is 0, the algorithm checks whether the point is connected upstream. If so, then the bit is changed from 0 to 1. If not, then the bit is not mutated, and another bit is selected for mutation. If the bit is 1, then the bit at this point and all the bits downstream are changed from 1 to 0.  
Finally, when the new generation of chromosomes has been produced, we check whether the total water demand of the newly produced chromosomes falls within the set range. If a new chromosome fits, it directly becomes a member of the next generation. If not, it is fine-tuned. The first step of fine-tuning is generating a random value for all of the areas. If the total water demand of the new chromosome is below the set range, the areas are checked, beginning with the one with the highest random value. If the bit value of this area is 0 and it is connected upstream, we change the bit value of this branch to 1, meaning that it is given water. In contrast, if the total water demand of the new chromosome is greater than the set range, we check the areas, beginning with the one with the lowest random value. If the bit value of this area is 1, we change the bit value of this area and all of the bit values downstream to 0, meaning that no water is given to this area or those downstream. The above process continues until the total water demand of this chromosome falls within the set range.