Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Genetic Algorithm –

Ecological Applications
Class-4:
29th August, 2019

Dr . Rama Chandra Prasad Pillutla


Lab for Spatial Informatics
Travelling Salesman Problem using Genetic
Algorithm
Problem: Given a list of cities and the distances (cost of travel)
between each pair of cities, what is the shortest possible route
(cheapest way) that visits each city and returns to the origin city?”

6
5
3 Two important rules

2 1. Each city needs to be


visited exactly one time
1
8
9 2. Return to the starting
city, so that total
7 4
distance needs to be
calculated accordingly
1 6 5 3 2 8 4 9 7
Gene: a city (represented as (x, y) coordinates)
Individual (aka “chromosome”):
a single route satisfying the conditions above
Population:
a collection of possible routes (i.e., collection of individuals)
Parents:
two routes that are combined to create a new route
Mating pool:
a collection of parents that are used to create our next population
(thus creating the next generation of routes)
Fitness:
a function that tells us how good each route is (in this case, how short
the distance is)
Mutation:
a way to introduce variation in our population by randomly swapping
two cities in a route
Elitism:
a way to carry the best individuals into the next generation
Different Path representations Route

1 6 5 3 2 8 4 9 7 Individual
City/
Genes Population/
3 7 6 1 9 4 8 2 5 Individual Parents

How does the crossover operator works?


The crossover operator in its classical form cannot be directly applied to
the TSP. A simple exchange of parts between two parents would produce
illegal routes containing duplicates and omissions – some cities would
be visited twice while some others would not be visited at all:

Parent 1: 1 6 5 3 2 8 4 9 7 Parent 2: 3 7 6 1 9 4 8 2 5

Child 1: 1 6 5 3 9 4 8 2 5 Chil d 2: 3 7 6 1 2 8 4 9 7
Crossover operators for the TSP
Partially mapped Cross over

P1 1 6 5 3 2 8 4 9 7
C1 3284 Mapping
between the
P2 3 7 6 1 9 4 8 2 5 C2 1948 points

C1 3 2 8 4 1 7 6 3 2 8 4 9 5

C2 1 9 4 8 3 6 5 1 9 4 8 2 7

Order crossover
Copy some random number,
C1 3 2 8 4 pick remaining part from parent in the order they appear
C1 3 2 8 4 7 6 1 9 5
C2
1948
C2 1 9 4 8 6 5 3 2 7
How does the mutation operator works?

Reciprocal exchange Inversion

1 6 5 3 2 8 4 9 7 1 6 5 3 2 8 4 9 7
(a) original chromosomes

1 6 8 3 2 5 4 9 7 1 2 3 5 6 8 4 9 7
(b) mutated chromosomes

How do we define a fitness function in the TSP


The fitness of each individual chromosome is determined as
the reciprocal of the route length.
length.
In other words, the shorter the route, the fitter the
chromosome..
chromosome
Performance graph and the best salesman’s route created in a
population of 20 chromosomes after 100 generations

N = 20, p c = 0.7, p m = 0.001 The total distance: 5.124


11 1
3
Best 0.9 17
10 4
Average 0.8 7 6
20
9 0.7 9
16
Distance

0.6 10 18
8
0.5
7 12 1
0.4

6 0.3
13
0.2
11 2
5
0.1 8 14
19
15 5
4 0
0 10 20 30 40 50 60 70 80 90 100 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Generations
Performance graphs and the best routes created in a
population of 200 chromosomes: mutation rate is 0.001
N = 200, p c = 0.7, p m = 0.001 The total distance: 4.0938
11 1
3
Best 0.9 17
10 4
Average 0.8 7 6
20
9 0.7 9
16
0.6 10 18
8
0.5
7 12 1
0.4

6 0.3
13
0.2 2
11
5
0.1 8 14
15 19
5
4 0
0 10 20 30 40 50 60 70 80 90 100 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Generations
Performance graphs and the best routes created in a
population of 200 chromosomes: mutation rate is 0.01
N = 200, p c = 0.7, p m = 0.01 The total distance: 4.0825
11 1
3
Best 0.9 17
10 4
Average 0.8 7 6
20
9 0.7 9
16
0.6 10 18
8
0.5
7 12 1
0.4

6 0.3
13
0.2 2
11
5
0.1 8 14
19
15 5
4 0
0 10 20 30 40 50 60 70 80 90 100 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Generations
Genetic programming
An Evolutionary Computation (EC) technique that automatically
solves problems without requiring the user to know or specify the
form or structure of the solution in advance.

It saves time by freeing the human from having to design complex


algorithms, • Not only designing the algorithms but creating ones
that give optimal solutions
The basic step in GP Algorithm

1. Randomly create an initial population of programs from the


available primitives
2. Execute each program and ascertain its fitness
3. Select one or two program(s) from the population with a
probability based on fitness to participate in genetic
operations.
4. Create new individual program (s) by applying genetic
operations with specified probabilities
5. Until an acceptable solution is found or some other stopping
conditions is met (eg. Maximum number of generations is
reached)
6. Return the best so far individual.
The primary genetic operations that are used to create new programs
from existing ones are:

Crossover: The creation of a child program by combining randomly


chosen parts from two selected parent programs,
Mutation: The creation of a new child program by randomly altering
a randomly chosen part of a selected parent program

Representation of Solutions in a GP System


expressed as syntax trees rather than as lines of code

max(x+x,x+3*y)
Initializing the
Population Individuals
in the initial population
are typically randomly
generated,

simplest methods
1 The full method
2. The grow method,
3. Ramped half-and-half
(a widely used
combination of the two
methods)
Crossover Mutation

The output of the GA is a quantity, while output of Examples of primitives in GP


GP is a another computer program function and terminal sets
Applications of Genetic Algorithms to Ecological
Modelling

They offer a tool for parameter optimization and for the development of structurally
dynamic models
In the field of ecology, GA have been used for
1. Parameter optimization, equation discovery, and pattern
searching. Ex. Ludvigan et al (1997) used a GA to search
for optimal bacterial phospholipid fatty acid (PLFA)
combinations to biogeochemical parameters.

2. To look for data patterns such as subsurface zones of bacterial


activity and fish distributions These studies attempt to find
the optimum combination of variables to predict the
distributions of organisms in relation to their habitat.

3. To predict distributions of organisms as a function of spatial


habitat characteristics using species distribution models
that use abundance or presence/absence data.

4. To develop a modeler produces a dynamic "movie" of the


evolution of mechanisms producing the patterns.
To find the optimal foraging strategies for an Anolis lizard
and emergent properties in ants using genetic programming

In the lizard example, the optimal foraging strategy was discovered


based on the location and abundance of the prey, and the velocity of
the lizard. Over time, the lizard can adapt his strategy if the
environmental conditions change. This provides both an example of
controllers strategy and a demonstration that evolutionary programs
can evolve the theories governing complex behavioral strategies
using simple governing rules.

In the ant emergent behavior program a set of rules is used that


governs the actions of individual ants. When these rules are
simultaneously executed, a complex pattern of behavior emerges
that causes the ants to collect and consolidate food pellets into a
single pile.
Model of spatial dynamics in fish, that simulate coordinated
movement of organisms based on simple rules have greatly
improved our understanding of how groups of organisms travel,
sometimes great distances, together in a coordinated fashion.

Natural landscapes have complex patch dynamics that influence


both the distribution of organisms and their interactions.

The evolution of multiple-species within a landscape requires


representation of diverse niches with different evolutionary
Pressures. Organisms may move through the system and change
in number as well as immigrate and emigrate as system properties
change. It is through their ability to simulate evolution in
response to changing environmental conditions and spatial
heterogeneity that GAs can offer most to the field of ecosystems
ecology
Fontaine (1981) created a self-designing ecosystem using a
standard process model and adjusting the parameters. The model
parameters were optimized by running the model for 3 time-steps,
altering the parameters and rerunning the model with the best set
of parameters. The goal of this effort was "the search for a single
principle that adequately describes the evolution of ecosystem
structure and function at all levels of resolution ... "

Ecological models also incorporate evolution and co-evolution


into their frameworks if they are to predict the sustainability of
various ecologies.
Evolution can be incorporated into ecological models through
adaptation of species currently in the system and by forecasting
changes in species composition. Co-evolution in ecological
systems is described by the Gaia theory and which incorporates
the feedback mechanisms common in natural systems.
Representation of this phenomenon is critical for predicting the
future of ecological systems.
Hybrid Genetic Algorithms
Work done by Patel et al. (1998) is an intriguing example of a hybrid NN and
GA. Objective was to design new molecules that would kill bacteria. They
trained a NN on a dataset of chemicals and their ability to kill bacteria. They
then used a GA to rearrange the amino acid sequences to create new
chemicals. The NN then evaluated the efficacy of these new chemicals. This
approach took advantage of the strengths of each technique

D' Angelo-Morrall et al. created a hybrid statistical clustering and GP


model. Their objective was to predict the toxicity to aquatic organisms of a
wide variety of chemicals. As dataset were very diverse, a single equation
could not adequately predict the toxicity of all chemicals. They used k-
means clustering to group the chemicals into similar classes. The GP was
then used to evolve equations to predict the toxicity of each groups of
chemicals. The performance of the hybrid statistical/ GP was compared with
a GP that did both clustering and predictions and K-means analysis that did
both clustering and predictions. When the dataset was of sufficient size for
predictions (training set n=50; testing set n=10) the hybrid approach
outperforms the individual methods.
GARP: Genetic Algorithm for Rule-set Prediction

Predictive Modeling Methodology

Ecological Niche Model


Ecology

Temperature

Projection Onto
Precipitation
Projection Another Region
Over Changed
Algorithm Climate
Geography

Occurrence Points Native Predicted Distribution Invasive


Predicted After Climate Changes Potential
Range
GARP - General Approach

Divide data in training


data set (used to build Point
models) and test data set occurrence data
(to validate the model)
Environmental
Applies an algorithm to Vegetation
vegetação Dimensions
temperatura
the training data set temperatura (Environmental
precipitation
precipitação
BIOCLIM Layers)
soil
relevo
Logistic Regression
etc. Predicted
Distribution
Evaluates model quality,
by asking how errors are
different from random
RP: Rule-set Prediction
Rule: Logical Proposition
If A is true then B
A: precondition
B: result or prediction
Example:
If Tmin_winter in [5,10] & Tavg_winter in [10,22] & Elev
in [1k,2k]
then taxon is present

Training Data-set
P: Set of training data point (spp)
Elements in P: pi = (a, b)
a: environmental variables at that point
b: observed presence or absence

Example: p1 = (10, 12, 2k, Present)


Rule-set Evaluation
P is used to test the rules in R:
If a in A:: If b=B then the rule predicts correctly
If b≠B then the rule DOES NOT predicts correctly
If a not in A: Rule does not apply to the point: test next rule

f(ri): fitness function


Percentage of points that are predicted correctly by the rule
Rule Coding:
r1: If Tmin_win-in [5,10] & Tavg_win- in [10,22] e Elev in [1k,2k] then present
r2: If Tmin_win- in [0,15] & Tavg_win- in [0,50] & Elev in [0,20k] then absent
r3: If [Tmin_win x 0.80 + Tavg_win x (-0.2) + Elev x 0.45] then absent

Rule Tmin_ Tmin_ Tavg_ Tavg_ Elev Elev P/A f(r)


win win win win
r1 5 10 10 22 1k 2k P 50%
r2 0 15 0 50 0k 20k A 12%
r3 0.8 --- -0.2 --- 0.45 --- A 95%
Heuristic Operators
Mutation: random modification of a gene

Before r2 0 15 0 50 0k 20k A 12%

After r4 0 15 0 28 0k 20k A 15%

Crossing over: Exchange of segments between two chromosomes

r1 5 10 10 22 1k 2k P 50%
Before r2 0 15 0 50 0k 20k A 12%

After r5 5 10 10 50 0k 20k P 87%


r6 0 15 0 22 1k 2k A 9%
Survival of The Fittest

Rule f(r) Rule f(r) Survive and


r3 95% r3 95% have offspring
r5 87% r5 87%
r1 50% Rules Threshold
Sorted r1 50%
r4 15% by f(r) r4 15%
r2 12% r2 12%
r6 9% r6 9% Die

Rule f(r) Survivors form a rule


After <n> r3 95% set that represents the
iterations r5 87% ecological niche of
that species
r1 50%

You might also like