Processing Tools for Genetic Algorithm in software

In my preceding post, I discussed about the basics of Genetic Algorithm and its use in the GIS world. Today I will discuss how to apply the algorithm in software.

Let us take the arbitrary situation, here we need to construct a dam for which we require the following items:

Material Quantity Cost (Rs. For one times) No. of times required(TR) Time Intervals to call the materials( in months)(TI)
Gravel 100 tons 10,000 100 1
Cement 100 kg 50,000 100 2
Iron Pipes 1000 2,00,000 10 5
Steel Pipes 100 30,000 10 7
Labor 10,000 80,00,000 1 10
Trucks 100 5,00,000 100 1


Here, we have the quantity of an item required and its respected cost. Our objective is to maximize No. of times required column (TR) by considering the call of material. Our constraint: call of material items (TI) should not be more than 20 times.

First of all let us open the R software and defining the dataset and import genalg module to run the model


dataset <- data.frame(item = c(“gravel”, “cement”, “iron_pipes”, “steel_pipes”,

“labour”, “trucks”), TR = c(100,100,10,10,1,100), TI = c(1,2,5,7,10,1))  TIlimit <- 20



Now we will define the function which optimizes the value. If it exceeds the TI (call of material) then it return the value 0.


evalFunc <- function(x) {

current_solution_TR <- x %*% dataset$TR

current_solution_TI <- x %*% dataset$TI


if (current_solution_TI > TIlimit)

return(0) else return(-current_solution_TR)



Now we are setting up the loop count and calling up the function which we have created above.

iter = 100

GAmodel <- rbga.bin(size = 6, popSize = 100, iters = iter, mutationChance = 0.01,

elitism = T, evalFunc = evalFunc)


solution = c(1, 1, 1, 1, 0, 1)

dataset[solution == 1, ]


From above solution (1,1,1,1,0,1) finally we come to across the best way to utilize the resources.

In QGIS desktop, we can use Genetic Line Simplifier plugin for applying Genetic Algorithm in GIS perceptive especially for line simplification which is quite flexible and robust to solve the spatial problem.



In Ruby, Genetic Algorithm is applied by using Gimuby as a Ruby library which is used in academic purposes. If in case, user does not know how to target the problem, then there is 50% chance to solve that by using Gimuby.


Hence there are many other software which are capable of applying the Genetic Algorithm which I mentioned above. We can also apply Genetic Algorithm in Python, by using modules i.e.

1)pySTEP: It allow the user to involve population tree with constraints or in other words setting up the rules that identify the identity during evolution.

2) Deap: It runs over two pillars i.e creator and toolbox. Creator allow to create the classes that fulfill the need of evolution algorithm whereas Toolbox contains the evolution operators.

3) Pyvolution: It is a framework for Genetic Algorithm.

So at the end, we can say that decision makers can judge easily in which direction they have to go for the better results.


Image Courtsey :

Related Posts

About The Author

Leave a Reply

1 Comment on "Processing Tools for Genetic Algorithm in software"

Notify of

Sort by:   newest | oldest | most voted
2 years 9 months ago

When the values are discrete values the genetic algorithm is most suitable to solve complex problems.

Sign Up
Fields with (*) are required
Account Info
Password must be at least 7 characters long. To make it stronger, use upper and lower case letters, numbers and symbols.
Type your password again.
Profile Info
Prove you're not a robot