Application of genetic algorithm to a gas network for flow optimization

Published: 13 January 2022| Version 2 | DOI: 10.17632/g7nb7b9ys7.2
Matthew Efe Takerhi


This Contains codes for Flow optimization, where the flows of four pies are encoded as genes and a genetic algorithm Search s for the best flow combination that results in the least summation of the pressure drop for every loop in both compressors stations.


Steps to reproduce

The java programming language was used to write the codes in the IntelliJ integrated development environment. The Classes are code templates, that make up the genetic algorithm and Gas Network. The classes that make up the genetic algorithm include genetic algorithm, Individual and population, while the codes that makes up the Gas network include, compressor, compressor station, loop, network, gas, loop, nodepro, and pipe. The Class named constant is used to set various numeric constants and is used for providing constants for the genetic algorithm and gas network. To run the simulation, the parameters for the Gas network were set up in the Network class with the setNetworkUp method. The parameters for the Genetic algorithm were contained in the constant class, the parameters that can be changed to modify the search capacity of the genetic algorithm include: • POPULATION_SIZE • NUMBER_OF_GENERATION • CROSSOVER_RATE_FLOW • MUTATION_RATE_FLOW • TOURNAMENT_SIZE_FLOW To reach the same result the fitness function should be similar, and it determines the fitness individual which is the gas network with the set of flow that gives the summation of the minimum pressure drop for every loop in a compressor station. The approach to utilize the fitness function was to determine the best flow set for the compressor station during half of the generation of the genetic algorithm and it was repeated for the second compressor station for the other half of the generation. The main class contains the codes, where te copies of the class templates are created and run to direct the order and some printout of the simulation and results.


Akademia Gorniczo-Hutnicza imienia Stanislawa Staszica w Krakowie


Petroleum Engineering, Natural Gas Engineering