Genetic algorithm for the strategic location of a network of fire hydrants

In Trujillo, a norther city from Peru, the number of fire hydrants is currently 497; only 10% are working out in the center of this city. Faced with this situation, the firefighters do not attend in optimum time the various emergencies happen, making possible the increase of material damages and victims due to the lack of water supply caused by the inoperativeness hydrants and also a non-optimum distribution. In this research, a network of hydrants was strategically located through the design and output of a genetic algorithm, GA. There are many solutions, and only one individual must be selected, the most efficient. It was evaluated by the fitness function about the length from a common point to others where the hydrants are, and the best solution was determined by applying genetic operators like crossover and mutation, which means the location points of the hydrants on the map of the city. The result shows a very good solution for a hydrant network; in addition, the number of hydrants that make up the network with the average distance of the network that reduce the time to attend an emergency. The result shows a very good solution for a hydrant network; the number of hydrants that make up the network with the average distance of the network reduces the time to attend an emergency. It will be useful to redistribute the hydrants for better locations.


INTRODUCTION
Trujillo does not prepare to withstand a major fire; many factors are involved in an emergency, like bad power connections in homes, highly inflammable materials, informal warehouses and lack of water. This problem is faced by firefighters, who use very limited and obsolete tools and materials; they must expose their lives to avoid injuries and fatalities, suffocating the fire in these cases. They also must use hydrants, but these have low water power at the time of emergency, so that the only optimal water supply of hydrant is constrained at night and for some hours; worse if the hydrants are located in non-strategical points of the city.
Trujillo's city hydrant network has 497 hydrants approximately, of which only 10% are working out in the Centre of the city. In this way, a fire cannot be efficiently controlled, and it requires a network of hydrants in optimum condition; it means collecting water from the urban supply hydrant network in Trujillo and must be located in such a way that during an emergency optimize the location of nearest hydrants. SEDALIB is a local water supplier company; the company does not assure that hydrant is working all the time. The boss of the firefighter company said in 2017 that Trujillo does not prepare to make front an emergency from a big fire. Also, he states not having enough budget to purchase equipment and uniforms for the firefighters.

MOTIVATION
In computer science, there are many methods to solve a search problem. Research for selecting the location of new thermal plants include proximity and hazard analysis; e.g., explosions, fire, traffic accidents of dangerous substances, aircraft crashes, etc. [1].
Metaheuristic algorithms are techniques for the optimization of non-linear problems. They can be classified into swarm intelligence-based and evolutionary like GA [2]. A GA is a stochastic search to try to optimize a fitness function; it is inspired by a theory from Darwin, Mendel, and Lamarck. The algorithm reflects a natural selection of individuals from a population who produce offspring for the next generation, which inherit some characteristics from their parents. Each one has a fitness value that if it is better than their parents has more chance to survive. There are three genetic operators, selection, crossover, and mutation, causing the searching among diverse individuals into a state space. The algorithm stops when it gets an individual that solves the problem, has the main fitness utility or when the population converges, it means not find a better individual for many generations [3]. Promising results for GA are found in several problems, such as the metaheuristic approach to the multi-compartment vehicle routing problem (MCVRP) using voracious and genetic algorithm [4] and in the optimization of routes of trained vehicles [5].
For this research, the objective was to design a hydrant network of strategic locations using GA. The representation for the distribution of hydrants in a geographic area is a vector containing locations of hydrants. We study an optimal allocation problem; a GA was considered appropriate although there are other heuristics like spotted hyena optimizer algorithm [6] where the objective function includes minimizing the energy losses cost; GA is one the best alternatives to apply when trying to solve well placement and production allocation problems like in hydrocarbon production optimization [6]. The research justifies socially because a strategic map of hydrants would optimize resources like the time to help in an emergency situation and have a city much more prepared to control a major fire efficiently.
The state-space depends on possible combinations of structure from the individual state. On the one hand, GA explores solutions in parallel, prioritizing the fitness of an objective function like minimizing error, risk, saving costs; or maximizing satisfaction, benefits, and utility. By the other hand, at the end of each cycle, the best information is shared to start a new cycle with the best knowledge of the previous cycle [7].

RESULTS
Since GA works with the coding of parameters, they evaluate multiple solutions at once (contrary to the linear search). They are characterized by being global search algorithms; they do not have a singular initial search point [7]; all hydrant points were located on the geographical map considering the type of zone and the established rules. Their representation was made into chromosomes, as shown in the Figure 1.
The criteria for the GA are according with the National Building Regulations; e.g., the hydrants should only be supplied by the public service water system, they should be installed on the street corners with the exit points located towards the runway where the fire truck will be parked and in areas no greater than 200 meters. In the present investigation, these criteria were considered for population parameterization (chromosomes) of the GA in its preliminary stage.
The chromosomes are encoded in binary digits. Bit 1 represents the presence of a hydrant, bit 0 its absence. Each chromosome gene represents the geographical coordinates (latitude and longitude) on the map, obtained with Google Earth as shown in Figure 2.
Then the fitness function was designed from the minimum summation resulting from the average distance between the points of the hydrant network, fulfilling the criteria that the distance between hydrants is not greater than 200 meters. The distance is obtained from the difference between points, where each point has latitude and longitude according to the map's coordinates.
As shown in Figure 3, each chromosome is represented by an array of 75 positions. At the beginning of the execution of the GA, each chromosome will be generated randomly in the state space; each chromosome has an individual value, for what the best individual of the population is more fit to be chosen for crossing, during the selection process.
A one for a gene means the hydrant is present at these geographical coordinates; zero means the hydrant is absent.  The fitness function tries to be a very good measure to evaluate the individuals in a population. It was proved that fitness value would increase in the following generations because, in natural selection, individuals with more fitness value have more probability of being chosen for crossover. Thus, many generations later, it will get the best individual from the evolution. For this case, the fitness function is the average distance between n hydrants and some fire places; see the following equations. It was considered hypothetical n referential positions for a fire to calculate the average distance as show in Figure 4.
Equation (2) calculate the sum of all distance value from a population, m is the number of hydrants. Equation (3) got the fitness value of each k chromosome; generation by generation, the fitness value will increase and allow finding a more efficient solution.
We assert that the execution of the genetic operators (there are 3) is repeated to the last generation. The offspring of the selected individuals replace them, as described in the following Figure 5.
During the crossing process, a random value is taken for the crossover point; it indicates the position within the chromosome; bits from this point to   the right are swapped between two chromosomes generating two offspring. It allows an exhaustive search of the state space of the problem. When the crossing process is over, the mutation process starts to get a genetic variability, alternating genes [8,9]. The probability of mutation is often less than 10%.
The number of hydrants at present is 33, representing an average distance of 31 962.25 m; the number of hydrants found after the evolution of GA is 17, which represents an average distance of 2 420 m. The map of hydrants at present and the produced map of hydrants displayed with the outputs from the genetic algorithm are shown in Figure 6.
Currently, there are fewer hydrants present because they are located more strategically. The maintenance costs can be reduced, and fires at the center of Trujillo city can be put out promptly.
The algorithm has converged; it means it does not produce offspring significantly different from many previous generations. The convergence curve is given in Figure 7, which indicates that after 1 000 generations, the average distance takes a minimum value. Table 1 shows a comparative of the average distance after different number of generations.

DISCUSSION
Other linear and non-linear search algorithms were explored. Reaching metaheuristics like GA; considering the great difference between the linear ones that found local optima, they do not explore all search states, unlike those of the genetics that does not stop with the first solution found; they continue to evolve until they reach a solution that meets the stop criteria.
Genetic Algorithms are better than other heuristics such as Backward Search (Backtracking) and Greedy Algorithms (Dijkstra); for the hydrants problem, GA is very useful. The Table 2 shows a comparison with others search algorithms.
Also, another advantage is that it performs parallel searches by several agents simultaneously, making possible any optimization problem, saves costs, and reduces search time of solution; it also allows adjusting the parameters for any problems [10,11].
These results show a feasible solution; Hidalgo shows another solution to distribute the hydrants for Lima city based on metrics and legal framework [12].

CONCLUSIONS
GA was designed by criteria of the National Building Regulations, which allowed to generate the parameters and adapt the matrix of the initial population where the hydrant network will be established, and it was evaluated its evolution in each generation.
The fitness function of the genetic algorithm was determined by taking the average distance from a hypothetical point of fire to the hydrants; after the evolution of the population of individuals, the number of hydrants was reduced from 33 to 17 hydrants (49%).
The network of hydrants in the center of Trujillo was got from the cadastral plans of the company SEDALIB; later, it was determined a better distribution and a low number of hydrants.
The genetic algorithm was implemented in a dynamic web, using the JavaScript programming language, from which scripts were obtained to show the genetic algorithm's performance and the geographical map and its evolution as the generations passed.
Future researches may improve the fitness function to consider other factors like traffic, geographical zones, speed of firefighter trucks, the level of fire, among others. Note: k is the number of generations; l is the size of population.