SlideShare a Scribd company logo
1 of 126
Download to read offline
SCHOOL OF MECHANICAL AND MANUFACTURING
ENGINEERING
Swarm learning techniques
by
Alexander Champion de Crespigny
Bachelor of Engineering (Mechatronic Engineering)
Submitted: June 1, 2015 Student ID: z3253261
Supervisor: John Page
Abstract
Current swarm systems require a predefined logic to be installed in the swarm. This
logic is required to be changed for di↵erent locations and or situations. If swarm
entities were to learn from previous experiences and from other entities within the
swarm through sensor fusion then this external input would not be required. The
swarm would adopt the most e cient technique over time through a process of
evolution. By carrying out a process of evolution the system can dynamically change
to its environment and improve. The concept of keeping good genes and expelling
the weaker will ensures the success and or survival of the swarm. New genes need
to be added to ensure evolution progresses and change can occur.
Acknowledgements
I would like to thank many people for all their support and assistance during my
thesis research.
Firstly I thank John Page who accepted me as his thesis student and guided me
through the process. His guidance was pivotal in shaping my thesis topic.
I thank Dr Suzy Oglesby for listening and helping me sound out my ideas on
evolution, without her insight on the human brain and physiology I would not have
arrived at the same conclusions.
I thank my father Dr. Richard Champion de Crespigny for helping me sound
out my ideas and coming to conclusions. His insights in to how the human brain
work and how it has evolved over time have was fundamental to my understanding
of evolution.
Thank you to my family who was supported me through the stresses of the
project.
I, the undersigned, declare the following submission to be entirely of my own
undertaking to the best of my knowledge, except where specific acknowledgement is
made.
Alexander Champion de Crespigny
z3253261
June 2015
2
Abbreviations
BE Bachelor of Engineering
EE&T School of Electrical Engineering and Telecommunication
LATEX A document preparation computer program
GA Genetic Algorithm
NATO North Atlantic Treaty Organisation
PSO Partical Swarm Optimisation
UAV Unmanned Arial Vehicle
ATC Air Tra c Control
FL Flight Level
3
Nomenclature
d distance (km)
g gravity (9.81 m/s)
h height (m)
hc UAV ceiling height (m)
Tr turn rate (deg/s)
s time (s)
V velocity (m/s)
Vg ground Speed (m/s)
Vas air speed (m/s)
Vmg UAV maximum ground speed (m/s
Sas sensor accuracy speed (%)
Sav sensor accuracy vertical (%)
OA overall sensor accuracy (%)
RA random chance the sensor detects the lost agent
4
Rand1 random number generated from 0 to 1
✓ angle (deg)
5
Glossary
Bingo Fuel An allocated amount of fuel for an aircraft that allows it to return to
its destination without running out of fuel.
Harem A group of same gendered animals sharing a single mate of the opposite
sex.
Link 16 Link 16 is a jam resistant high speed data link that can communicate
between air, land and sea resources. It is utilised by the United States of
America and it’s NATO allies.
Sensor Fusion The accumulation of data received from an array of several sensors.
The end result of the combined data is superior than a single sensor.
Chinese Whispers When information is passed on in turn by a number of people,
often becoming distorted in the process [8].
Flight Level An aviation term used to refer to an aircrafts altitude. It is usually
referred to in feet however some jurisdictions enforce local ATC and flights to
use meters. To limit time spoken over the radio the last two digits are removed
for simplicity. For example 20,000 ft would be FL (Flight Level) 200ft.
6
Contents
1 Background 14
2 Literature Review 17
2.1 Biomimicry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2 Evolution and breeding techniques . . . . . . . . . . . . . . . . . . . 19
2.3 Fitness proportionate selection . . . . . . . . . . . . . . . . . . . . . . 20
2.4 Genetic algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5 Particle Swarm Optimisation . . . . . . . . . . . . . . . . . . . . . . . 21
2.6 Wake Vortex Surfing . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.7 Minimum Breeding Age . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.8 Delaying Sexual Maturity . . . . . . . . . . . . . . . . . . . . . . . . 23
2.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3 Defining the Model 25
3.1 Computational Software . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2 Search Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.3 Drones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4 Lost Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.4.1 Random Lost Agent . . . . . . . . . . . . . . . . . . . . . . . 30
7
3.4.2 Semi Random Lost Agent . . . . . . . . . . . . . . . . . . . . 30
3.5 Drone Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.6 Drone Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.6.1 Sensor Speed Accuracy . . . . . . . . . . . . . . . . . . . . . . 32
3.6.2 Altitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.7 Overall Sensor Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.8 Start Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.8.1 Original start position . . . . . . . . . . . . . . . . . . . . . . 34
3.8.2 Continued moving . . . . . . . . . . . . . . . . . . . . . . . . 35
3.9 Evolution of the simulation . . . . . . . . . . . . . . . . . . . . . . . . 35
3.9.1 Breeding (Evolutions) . . . . . . . . . . . . . . . . . . . . . . 37
3.9.2 Sexual Maturity (Breeding age) . . . . . . . . . . . . . . . . . 38
3.9.3 Time to find lost object (Time Out) . . . . . . . . . . . . . . 38
3.9.4 Mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.9.5 Example of a complete evolution cycle . . . . . . . . . . . . . 40
3.9.6 Turning the UAVs . . . . . . . . . . . . . . . . . . . . . . . . 43
4 Running the Model 44
4.1 Locate the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.2 Open and run with Matlab . . . . . . . . . . . . . . . . . . . . . . . . 45
4.2.1 Simulation Status . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.3 Simulation Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5 Future Work 50
5.1 Homogeneous Characteristics . . . . . . . . . . . . . . . . . . . . . . 50
5.1.1 Wake vortex surfing . . . . . . . . . . . . . . . . . . . . . . . . 50
8
5.1.2 Manoeuvring Speed . . . . . . . . . . . . . . . . . . . . . . . . 51
5.1.3 Flight pattern optimisation . . . . . . . . . . . . . . . . . . . 51
5.1.4 Distance between agents . . . . . . . . . . . . . . . . . . . . . 52
5.1.5 Breeding techniques . . . . . . . . . . . . . . . . . . . . . . . 52
5.2 Non Homogenous Physical Characteristics . . . . . . . . . . . . . . . 52
5.2.1 Drifting Ship . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.2.2 Impeding factors . . . . . . . . . . . . . . . . . . . . . . . . . 53
6 Real World Applications 54
6.1 New and Changing areas of interest . . . . . . . . . . . . . . . . . . . 54
6.2 Suspected Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7 Results and Discussion 56
7.1 Resetting the Start location . . . . . . . . . . . . . . . . . . . . . . . 56
7.1.1 Random lost agent evolution . . . . . . . . . . . . . . . . . . . 56
7.1.2 Adding a disturbance . . . . . . . . . . . . . . . . . . . . . . . 60
7.2 Continuing on path . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.2.1 Random lost agent evolution . . . . . . . . . . . . . . . . . . . 62
7.2.2 Adding a disturbance . . . . . . . . . . . . . . . . . . . . . . . 65
7.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.3.1 Sexual maturity age . . . . . . . . . . . . . . . . . . . . . . . 68
7.3.2 Randomness and Repeatability . . . . . . . . . . . . . . . . . 68
7.3.3 Mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.3.4 Starting Position . . . . . . . . . . . . . . . . . . . . . . . . . 69
7.3.5 Semi Random Disturbance Fitting . . . . . . . . . . . . . . . 69
7.3.6 Unexplainable spike increase in search time . . . . . . . . . . . 69
9
8 Conclusion 71
9 Personal Remarks 73
9.1 The idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
9.2 Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . 74
9.2.1 AnyLogic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
9.2.2 Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Bibliography 77
Appendix 1 79
10
List of Figures
2.1 Animals swarming . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1 Search Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2 Drone Process model . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3 A UAV search drone . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.4 Four UAV search drones . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.5 Random Lost Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.6 Semi Random Lost Agent . . . . . . . . . . . . . . . . . . . . . . . . 31
3.7 Sensor range with varying altitude [18] . . . . . . . . . . . . . . . . . 33
3.8 Resetting of drone location from finding the lost agent . . . . . . . . 34
3.9 Continuation of drone direction before and after detection of lost object 35
3.10 Pseudo Program Structure . . . . . . . . . . . . . . . . . . . . . . . . 37
4.1 Simulation program m-file . . . . . . . . . . . . . . . . . . . . . . . . 44
4.2 Opening Simulation program m-file . . . . . . . . . . . . . . . . . . . 45
4.3 Selecting simulation program m-file . . . . . . . . . . . . . . . . . . . 46
4.4 Run the Matlab program . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.5 Change Folder Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.6 Input Evolution Variables . . . . . . . . . . . . . . . . . . . . . . . . 47
11
4.7 Status of the simulation . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.8 Simulation Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1 Wake Vortex Surfing [1] . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.1 Average time to find lost agent without a disturbance . . . . . . . . . 57
7.2 Linear line of best fit applied to the time to find the lost agent without
a disturbance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.3 Average time to find lost agent with a disturbance added at evolution
stage 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.4 Average time to find lost agent without a disturbance and continuing
on the UAVs path without resetting its position . . . . . . . . . . . . 63
7.5 Linear line of best fit applied to the time to find the lost agent without
a disturbance and continuing on the UAVs path with out resetting
its position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.6 Average time to find lost agent with a disturbance and continuing on
the UAVs path without resetting its position . . . . . . . . . . . . . . 66
7.7 Linear line of best fit applied to the time to find the lost agent with a
disturbance and continuing on the UAVs path with out resetting its
position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.8 Evolution Cycles: 10, Sexual Maturity age: 15, Timeout: 100,000 . . 70
12
List of Tables
3.1 Process model values . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.2 Drone Characteristics and values . . . . . . . . . . . . . . . . . . . . 31
3.3 Drone Set Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.4 Example of Mutations . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.5 Initialised UAV characteristic values . . . . . . . . . . . . . . . . . . . 41
3.6 Initialised UAV characteristic values, * denotes the values changed
due to mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.7 Initialised UAV characteristic values, * denotes the values changed
due to mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
7.1 Results UAVs: 8, no disturbance . . . . . . . . . . . . . . . . . . . . 57
7.2 Results UAVs: 8, with sine wave disturbance . . . . . . . . . . . . . . 60
7.3 Results UAVs: 8, no disturbance . . . . . . . . . . . . . . . . . . . . 62
7.4 Results UAVs: 8, with wine wave disturbance . . . . . . . . . . . . . 65
13
Chapter 1
Background
Search and rescue is a high stake, high risk area of work for governments and organ-
isations. For the people who are lost it may be a life or death situation. Developing
new and improved strategies will ultimately decrease the risk to search operators
and increase the chance of survival for displaced persons.
Search and rescue is a very expensive activity, the main cost incurred in these
operations is training, fuel, salaries and equipment. If training and salaries could be
reduced then the cost involved would decrease dramatically.
An example of an ongoing and very expensive search mission is the search for
the wreckage of the Malaysian Airlines flight MH370 that disappeared en route from
Kuala Lumpur to Beijing in early 2014. The aircraft is believed to have ditched into
the Indian Ocean o↵ the western coast of Australia. In order to just begin the
search aircraft fly for several hours to just reach the search zone, even flying from
the closest airport in Australia.
There are three main ways in which the wreckage was searched for.
14
1. Airborne surveillance
Aircraft limitations meant that the aircraft could not remain in the area long be-
fore it reached bingo fuel. By the time the crew reached the search area they were
already fatigued. With the limited time they had, they searched the ocean with on-
board sensors and eye-sight. This process is extremely costly and ine↵ective when
the search area is remote to any airfields.
2. Seaborne surveillance
Ships were used to search the area using a combination of surface radar, eyesight
and sonar devices. The distance a person can see to the horizon is limited by the
curvature of the earth. The distance to the horizon can be roughly calculated by
equation 1.1. The greater the height above the sea level the further you can see,
however the ability to see detail decreases with distance. Searching onboard a ship
is ine↵ective as the searchers do not have enough height above sea level to cover a
large search area.
d = 3.57 ⇥
p
h (1.1)
3. Low Earth Orbit surveillance
Satellites were used to view the ocean surface. This however was limited by camera
resolution as it was necessary to look for very small objects such as seat cushions or
life jackets which are very hard to identify from space. Atmospheric interference also
interfered as clouds blocked visual observation. Each image also had to be processed
either by a person directly viewing or a computer program that was programmed
to identify wreckage which may not accurately detect the wreckage.
15
Each of the three search methods above have positive and negative characteristics
however there are ways that the benefits from each aspect can be combined to create
a better mechanism for search.
Currently search and rescue operations are undertaken by government and civil-
ian contractors. Many of these operators utilise unmanned surveillance options in
the form of satellites and drones however they are all controlled externally by a
human that is located somewhere around the world who manually has to input
search parameters. These search and rescue techniques have been improved by hu-
man reasoning and research however they are slow to adapt and often generic to
all situations. This research thesis has developed a model to simulate a swarm of
UAVs that are given a search area and then the swarm will deduce the best search
pattern and strategy for recovery. As computers are able to process millions of cal-
culations per second they can run algorithms to deduce the most e cient search
method though a process of evolution. Humans do not have the ability to process
this amount of data quickly as our brain cannot compare to the pure mathematical
computation power of todays computer processors.
There is no way to guarantee that the lost object will be found however the
swarm of UAVs will adapt to the scenario and deduce the best characteristics that
a UAV should possess to search the area.
16
Chapter 2
Literature Review
Swam intelligence systems focus the ability of a set of agents which will be referred to
as UAVs to learn and adapt to its surroundings. To start my research I began with
a generic Google search and read Wikipedia articles. Whilst Wikipedia is unreliable
it gave me academic references to start with, I was then able to follow the references
and find creditable academic articles which I then based my research for this thesis
on.
2.1 Biomimicry
Swarms are used extensively in nature, this can be easily seen in the way a flock of
birds fly or a school of fish swim as seen in figure 2.1. Early concepts of modelling a
swarm were based around the principles that each agent moved in the same direction
as its neighbours, remained close to its neighbours and avoided colliding with its
neighbour. This model is called the Boids computer program which was created by
Craig Reynolds in 1986 [20].
Swarms have a very useful application in modern times. Animals in nature are
17
(a) Birds flying in a V-Formation [10] (b) Fish Swarming [17]
Figure 2.1: Animals swarming
able to detect their surroundings and adapt to their environment, this adaptation
has been ongoing for billions of years. If a man made swarm of UAVs could detect
its surrounding environment it could adapt to the best way to search the area and
it would ultimately be superior to human search tactics [21].
Insects are a excellent example of swarms at work, ant colonies use swarm organ-
isational movement. When an ant walks it leaves a trail of pheromones like a trail
of breadcrumbs other ants are draws to strong concentrations of these pheromones.
When a food source is located the finding ant takes a bit of this food back to the ant
colony and then returns for more food thus increasing the chemical concentration of
the pheromone trail. It is likely that other ants will stumble across the same food
source and they will also add to the concentration though the process of returning
back to the ant colony. Other ants are then drawn to the concentrated pheromone
trail and acts as a path for ants to get to food [5]. The ants model is a very basic
simulation to run but it is an e↵ective way to search an area.
18
2.2 Evolution and breeding techniques
Evolution is a continuing process that has been developing over millions of years,
the current theory is that the strongest genes survive and are passed down to their
children [6]. There are two types of breeding techniques that are seen in nature.
The first is the group style where each agent has the ability to breed with any other
agent in the swarm or group this allows for a mixing of all gene types. This mixing
of all genes leads to characteristics that are suited for particular environments as
mutations occur which are better suited for the environment. This process of mating
promotes a large range of genetic diversity. Group breeding is well suited to swarms
that are subjected to changing environments as there is a large range of genetic
diversity which enables the species to adapt quickly.
The second type of breeding is called prime breeding and is where a dominate
male breeds with a harem of females. An example of prime breeding in nature can be
seen in elephant seal colonies where a bull male controls a harem of females and he
alone mates with them [19]. Prime breeding is not relegated only to elephant seals,
it has been observed in animals such as grouse, peafowl, lions and mountain gorillas.
It is also worth noting that in some animal species a dominate female mates with a
harem of males. This can be observed in birds like the jacana, and phalarope, it has
also been observed with the spotted hyena. Fighting is common between the sex
that is vying to mate with the harem. The dominate breeder will maintain security
over their harem and will fight o↵ any intruders or sexual competition. Sneaky
males or females will try to sneak in and mate with the harem, this provides a very
small amount of genetic diversity. Previous research on this topic has shown that
this style of mating is not well suited to changing environments. If the environment
19
changes too quickly the species may not be able to adapt to changes quickly enough
and the population may become extinct.
2.3 Fitness proportionate selection
Mathematical models are used to emulate real world evolutionary behaviour. The
fitness proportionate selection model [16] can be analogised as a roulette wheel in
a casino. Each section on the wheel is a type of gene. A stronger gene is given a
higher fitness value and a weaker gene is given a smaller value. A larger fitness value
correlates to a larger area on the roulette wheel and thus a higher chance that the
ball will land there. With a normal distribution the genes that are strongest (large
fitness value) will become dominate and still allow for a small amount of weaker
genes to be added and cause mutations. This model emulates real world breeding
well.
2.4 Genetic algorithm
The Genetic Algorithm (GA) was developed by John Holland [14]. The GA is based
on Charles Darwin’s theory of survival of the fittest. The model selects mating pairs
based on their ability to adapt to their environment. The genes from the strongest
mates are passed on to their children [7]. These children are then mixed into the
population and the process is repeated. As mixing occurs a fitness forms and the
strongest genes are passed down to each generation until a optimised solution is
found.
20
2.5 Particle Swarm Optimisation
Particle Swarm Optimisation (PSO) was developed by Kennedy and Eberhart [9].
PSO was developed by monitoring how swarms of ants, schools of fish and herds
of animals were able to find water and food sources in areas they had never been
to before, whilst avoiding dangerous predators [7]. This communication is made
possible by each animal communicating to its neighbour and the flow on e↵ect just
like Chinese whispers. By understanding how this information is transferred it can
be adapted to a swarm of UAVs where the information discovered at one side of the
swarm can be passed back to the rest of the swarm so a decision can be made on
how to proceed.
2.6 Wake Vortex Surfing
Birds have been saving energy by flying in V formations for millions of years. Aircraft
are also able to benefit from the updraft of the wake vortex generated by the leading
aircraft. Recent US Airforce trials have seen a decrease of up to 20% in fuel flow when
surfing the wake vortex of a leading aircraft [4]. To take advantage of this e ciency
aircraft must fly in tight formations, the benefits are reduced fuel consumption which
leads to less fuel needed for a given leg or an increase in range. Significant risks
are involved as wake vortex turbulence is very dangerous. Several fatal incidents
have occurred when an aircraft passed into a wake vortex. If the trailing aircraft is
not able to position itself correctly the forces from the vortex could tear the aircraft
apart. The formation requires the aircraft to fly in very close proximity and the risk
of a mid air collision is greatly increased. However with advanced autopilots and
21
Link-16 communication systems the aircraft are able to safely position themselves
in the correct part of the wake vortex and avoid collisions.
2.7 Minimum Breeding Age
Evolution by definition is constantly changing, researchers have applied simulated
computer models to mimic natures evolution. An interesting aspect of evolution is
the need for animals to have a minimum breeding age. When humans reach their
minimum breeding age they undergo a physical, psychological and physiological
change. This change is so significant that human cultures have created a name
for the change called ’puberty’. In boys changes are noticeable in the their voice,
body hair, genitals and breasts [11]. In girls changes are noticed in their breasts,
widening of the hips, body hair, genitals and menstruation [12]. The changes an
animal undergoes during sexual maturity are vital to successful evolution.
In order to reproduce animals must reach an age of sexual maturity, this time
gap from birth to sexual maturity is key to the success of evolution. This initial time
gap allows for each individual to prove that their genetics are worthy to be passed
on to another generation. If the individual is born with weak genes then they will
most likely die within the time before they reach the age of sexual maturity. The
timing of the sexual maturity is vitally important, if the age is set to low weaker
animals are able to spread their weaker genes, this will cause a weaker progeny to
be produced and an ever increasing spiral of bad genes may occur. However if the
timing is left to long the same e↵ect occurs where the species dies out due to weaker
genes being passed on [3]. There is a convergence in age at which a species sexually
matures and the expected life span of its progeny [3]. This process has been evolved
22
over time to the ages of 18-20 years old for human beings [15].
2.8 Delaying Sexual Maturity
There is a correlation between the age of sexual maturity and a the expected life
span of that species. Homo Sapiens (humans) are closely related to hominoids,
these animals can be seen as steps in our own human evolution over time. Gorillas
sexually mature at an age of 8 - 9 years old and they have a average life expectancy
of around 40 years old [15]. Humans reach sexual maturity at an age of 18-20
years old and have a average life expectancy of 80 years old [15]. A trend can be
observed by going back through our ancestors and examining the age at which they
reach sexual maturity and their expected life span. Earlier on our ancestors reached
sexual maturity at a younger age and had shorter life expectancies. The age at
which we reach sexual maturity over millions of years has increased. This age in
increased sexual maturity also correlates to a longer average expected life span [15].
An interesting comparison would be to compare the humans sexual maturity age
with those of pygmy humans who only have life expectancies of 20-24 years old. I
was not able to find any data on this and I expect that they are an exception to the
above theory. Evolution may make them extinct over time as they do not have the
correct ratio of reproductive age to life expectancy. Therefore it can be observed
that as a species successfully evolves its life span increases and along with this its
sexual maturity age also increases.
23
2.9 Summary
The basis of this research is to reduce the human input needed in robotic swarm
tasks such as search and rescue operations. The research is poised to develop smart
breeding algorithms for swarms to come up with strategies that are better than cur-
rent human methods. Robots have the ability to process information and therefore
can compute more permutations per second. The end result is to come up with lean
methods in a very fast time drawing on the swarms previous experiences and taking
advantage of high speed computations.
24
Chapter 3
Defining the Model
3.1 Computational Software
Matlab was used to program the evolution simulation, this choice was made as
Matlab provided the most diversity. Anylogic was explored however the use of a
GUI to program the interface presented limitations, this was a hard decision as
Anylogic is design made agent based modelling software.
3.2 Search Area
The search area was designed to be a very simple 3D cartesian layout as seen in
figure 3.1
25
Figure 3.1: Search Area
3.3 Drones
Each UAV was modelled as a di↵erent entity. Each drone was isolated and there
was no communication between them except when breeding. Each drones motion
was governed by a process model. This model was taken from the motion of a car
see the equation 3.3 [13]. This model of movement allowed for a very simple two
dimensional cartesian movement based upon a changing speed and steering angle.
The values used in the simulation can be seen in table 3.1. Altitude is set as a
constant in each simulation and there are no height changes within one evolution
cycle.
26
˙x (t) = v (t) · cos (✓ (t))
˙y (t) = v (t) · sin (✓ (t))
˙✓ (t) = tan (↵ (t)) ·
v (t)
L
Figure 3.2: Drone Process model
Variable Value Unit Description
v Evolves m/s Speed
✓ Evolves deg Current Heading
t 0.01 sec Time Step
↵ 0 deg Desired Heading
L 1 m m Vehicle Length
Table 3.1: Process model values
The drone is represented in a Matlab figure plot seen in figure 3.3. The drone is
represented by a coloured asterix inside a green circle. The green circle represents
the perimeter of the sensor search area cone projected onto the ground. Anything
within this area is able to be detected by the drone. Figure 3.4 shows four drones
stationary in the search area.
27
Figure 3.3: A UAV search drone
28
Figure 3.4: Four UAV search drones
3.4 Lost Agent
A lost agent was placed within the search area, this random agent was placed in two
poses the first was a completely random pose and the second was a semi random
pose. It is denoted in the model by a small red diamond. This can be seen in
figures 3.5 for the completely random lost agent and 3.6. for the semi random lost
agent.
29
3.4.1 Random Lost Agent
The random lost agent is placed at a random position in the search area, this can
ben seen in figure 3.5. The random values were generated by a random number
generator with limits of the boundaries of the search area.
Figure 3.5: Random Lost Agent
3.4.2 Semi Random Lost Agent
The semi random lost agent was placed in a semi random position. A sine wave
was generated with an amplitude that matched the height of the search area. The
lost agent was then randomly placed at a point along that curve which can be seen
in figure 3.6. This curve could be any shape however a sine wave is simple and
very easy to implement. The random number was generated by a random number
generator between the ranges of search area x-axis.
30
Figure 3.6: Semi Random Lost Agent
3.5 Drone Characteristics
Each drone had unique characteristics, these characteristics can be referred to as
genes in evolutionary terms, the range of characteristics that the UAVs could adopt
are specified in table 3.2. A speed of 50,000 m/s is not a realistic speed this speed
was allowed in order to allow for a faster simulation. A scaling factor needs to be
applied.
Allowable range values
Characteristic Minimum Maximum
Speed 0 m/s 50,000* m/s
Altitutude 0 m 2,000 m
Initial Angle -180 deg 180 deg
Table 3.2: Drone Characteristics and values
31
3.6 Drone Sensors
The simulation changes three behavioural characteristics in the swarm of drones.
The drones are homogeneous in nature and only the software is able to be changed
section 5.2 delves in to non homogenous physical variations in the drones.
3.6.1 Sensor Speed Accuracy
In reality sensors do not have 100% accuracy. When moving slower the sensor has
more time to analyse the area being searched than if it was flying faster. In the
simulation the sensor accuracy varies according the equation 3.1. For simplicity the
UAV will have a maximum ground speed of 50000 m/s (This value is allowed to be
very large to speed up the simulation, it also has a very low chance of detecting the
lost agent).
Sas = 1
Vg
Vmg
(3.1)
3.6.2 Altitude
The higher the UAV flies the more area the sensor is able to cover due to the cone
e↵ect shown in figure 3.7. This however decreases the accuracy of detection. The
sensor accuracy will vary depending on its altitude which is shown in equation 3.2.
The UAV will have a service ceiling of 2,000m.
Sav = 1
h
Hc
(3.2)
32
Figure 3.7: Sensor range with varying altitude [18]
3.7 Overall Sensor Accuracy
The total accuracy of the sensor is calculated in equation 3.3.
OA = Sav ⇥ Sas (3.3)
As in reality the chance of detecting an object is not guaranteed, a random
number generator is used to determine if the sensor is able to detect the lost agent
as seen in equation 3.4.
RA = OA + Rand1 (3.4)
3.8 Start Position
The simulation had two options. Once the UAV had detected the lost agent the
UAVs could return to their original starting positions or they could continue moving
33
along their path.
3.8.1 Original start position
When the UAV detects the lost agent they reset to their original start location. This
can be seen in figure 3.8.
(a) Before Find of Lost agent
(b) After find of lost agent
Figure 3.8: Resetting of drone location from finding the lost agent
34
3.8.2 Continued moving
When the UAV detects the lost agent it continues on its path that it was originally
on. When the system undergoes evolution the UAVs return to their starting position
this is shown in figure 3.9.
Figure 3.9: Continuation of drone direction before and after detection of lost object
3.9 Evolution of the simulation
The simulation starts with each drone set with an initial Speed, Altitude and Ini-
tial angle the set points that are used in the simulation can be seen in table 3.3.
Random denotes that the point is set from a random number generator that ranges
between the maximum and minimum of variable which can be seen in table 3.2.
These variables are designed to change throughout the simulation as it evolves.
35
Initial Characteristic Values
Drone Speed Altitude Angle x-pos y-pos
1 Random Random Random -4000 79,999
2 Random Random Random -3000 79,999
3 Random Random Random -2000 79,999
4 Random Random Random -1000 79,999
5 Random Random Random 1000 79,999
6 Random Random Random 2000 79,999
7 Random Random Random 3000 79,999
8 Random Random Random 4000 79,999
Table 3.3: Drone Set Points
The simulation is broken into three stages, Evolutions, Sexual Maturity and
Time out. A graphical representation of the looping code can be seen in figure 3.10
36
Figure 3.10: Pseudo Program Structure
3.9.1 Breeding (Evolutions)
The term evolution that is referred to in this thesis is similar to the natural process
of prime breeding. In the simulation the number of times the system evolves means
how many times the ’alpha’ UAV mates with the other drones and passes down its
characteristics.
37
3.9.2 Sexual Maturity (Breeding age)
Sexual maturity denotes the number of times the system tries to find the lost agent
(The number of times the lost agent is found). The drone characteristics do not
evolve during this time. There is a strong link with the sexual maturity age and the
ability for the system to successfully evolve. For example if the sexual maturity is
set to 10 cycles the system will try to find the object 10 times. If the system finds
the lost agent it will reset and go on to cycle 2 of 10, then 3 of 10, etc... When
this cycle runs 10 times the UAV that has found the lost object the most amount
of times is designated the ’alpha’ UAV.
Each of the other remaining drones will then choose to take one of the alpha
drones characteristics. This selection of a random characteristic is done randomly
so a drone will only take one of the characteristics shown in table 3.2.
3.9.3 Time to find lost object (Time Out)
The length of one iteration of the maturity cycle is limited. This limit is to ensure
that if none of the UAVs detect the lost agent they do not get stuck in an infinite
loop and never evolve. The limit was set to 100,000 iterations. An example of when
the system could get stuck in an infinite loop and never detect the lost agent is if all
the drones altitude or speed were set to zero, another circumstance where this could
occur is if the search angeles were set to be perpendicular to the x or y axis. The
Drone usually finds the lost agent within 10,000 iterations. The longest iteration
time until the lost object was detected that I observed was 45,000 iterations. The
time out function is a safety measure to ensure that change occurs mutations should
always get the system out of an infinite loop.
38
3.9.4 Mutations
As stated in subsection 3.9.3 the drones can be caught in a state where they do not
detect the lost agent. If the system is allowed to continue in this manner the system
will not ever evolve as no one of them detects the lost object and thus none of them
would pass on genes that will lead to a successful find of the lost agent. In nature
these groups of animals would go extinct.
Thus it is very important to ensure that mutations occur within the drones
characteristics. This is done by adding random values for each characteristic during
each time the system evolves.
Mutation was was achieved by by selecting three random numbers within the
range of 1 to the number of drones. For instance if there were 15 drones a random
number was generated between 1 and 15.
Mutation Example:
The simulation comprises of 15 drones. Each drone is assigned random characteris-
tics and has gone through one set of evolution. The other 14 UAVs have taken one
of the alpha drones strongest characteristics at random.
For the mutation to occur a set of three random numbers are generated in the range
of 1 through to 15.
The random numbers generated are 4, 11 and 9. These numbers correspond to UAVs
4, 11 and 9.
• Drone 4 will assign a random angle to its angle gene.
39
• Drone 11 will assign a random speed to its speed gene.
• Drone 9 will take assign a random altitude to its altitude gene.
This example of the mutations being added to the drones can be seen in table 3.4
All the ’mutated’ genes that have been entered are generated by a random number
generator that has limits that can be seen from table 3.2
Characteristics
Drone Speed Altitude (m) Angle (deg)
1 Unchanged Unchanged Unchanged
2 Unchanged Unchanged Unchanged
3 Unchanged Unchanged Unchanged
4 Unchanged Unchanged New Random Angle
5 Unchanged Unchanged Unchanged
6 Unchanged Unchanged Unchanged
7 Unchanged Unchanged Unchanged
8 Unchanged Unchanged Unchanged
9 Unchanged New Random Altitude Unchanged
10 Unchanged Unchanged Unchanged
11 New Random Speed Unchanged Unchanged
12 Unchanged Unchanged Unchanged
13 Unchanged Unchanged Unchanged
14 Unchanged Unchanged Unchanged
15 Unchanged Unchanged Unchanged
Table 3.4: Example of Mutations
3.9.5 Example of a complete evolution cycle
The system has 4 UAVs The simulation is initialised with the following values:
• Evolutions: 2 loop iterations
• Sexual Maturity Age: 4 loop iterations.
• Time Out: 100,000 loop iterations
Table 3.5 shows the values of the UAVs characteristics upon initialisation before
any search has begun.
40
During the search the program will loop through the third nested loop until a
UAV is reached.
This will repeat four times, once this has completed then alpha drone will be
identified.
• UAV 1 : 0 Detects.
• UAV 2 : 1 Detects.
• UAV 3 : 0 Detects.
• UAV 4 : 3 Detects. (Alpha UAV)
• UAV 5 : 0 Detects.
UAV 4 has detected the lost agent the most times and is designated the alpha
UAV. UAV 1, 2, 3 and 5 will now take a characteristic at random from UAV 4.
At the sam time a mutation will occur where UAVs 1, 3 and 5 will take a random
variable from within the allowable characteristic values. Table 3.6 shows the changed
values.
Characteristics
Drone Speed Altitude (m) Angle (deg)
1 450 600 -125
2 250 400 -150
3 300 200 30
4 350 800 39
5 400 1000 179
Table 3.5: Initialised UAV characteristic values
41
Characteristics
Drone Speed Altitude (m) Angle (deg)
1 350 600 12*
2 350 400 -150
3 350 1000* 30
4 350 800 39
5 10* 800 179
Table 3.6: Initialised UAV characteristic values, * denotes the values changed due
to mutations
The above process is repeated and this time UAV 2 is found to be the alpha
UAV. UAVs 1,2 and 5 have been randomly selected for mutations 3.7 shows the
changed characteristic UAV values.
Characteristics
Drone Speed Altitude (m) Angle (deg)
1 1234* 400 12
2 350 600* -150
3 350 400 30
4 350 800 12
5 350 800 *-178
Table 3.7: Initialised UAV characteristic values, * denotes the values changed due
to mutations
42
3.9.6 Turning the UAVs
In the search area the UAVs fly around looking for the lost agent. In order to stay
in the search area they turn once they reach the edge of the perimeter. Collisions
between UAVs are ignored. When a drone reaches the perimeter the angle at which
it is currently flying is reflected o↵ the boundary. The angle of incidence is equal to
the angle of reflection.
43
Chapter 4
Running the Model
This chapter provides a detailed overview of how to run the program, the simulation
has been designed to be user friendly. Matlab can be run on Windows, Mac and
linux based operating systems.
4.1 Locate the program
Locate the program the file can be seen in figure 4.1. Every function that is needed
is included within the m-file. There is no need for any other functions or add-ins.
Figure 4.1: Simulation program m-file
44
4.2 Open and run with Matlab
Ensure that the version of Matlab you are running is 2015a or older. If the program
is run with an earlier version some of the included functions may not exist and it
will result in an error.
Open the Matlab program
Select the open button.
Figure 4.2: Opening Simulation program m-file
45
Open the simulation m-file see figures
Open the ”DroneEvolutionSimulation.m” file.
Figure 4.3: Selecting simulation program m-file
Begin the Simulation
Select run to start the simulation
Figure 4.4: Run the Matlab program
46
Change file path
Change the file path to the program
Figure 4.5: Change Folder Path
Input Evolution Variables
Input the Evolution variables for this example I have set the values to the corre-
sponding values in figure 4.6.
Once ”Ok” is selected the program will start and run until completion.
Figure 4.6: Input Evolution Variables
4.2.1 Simulation Status
The status of the simulation can be seen in the Matlab command line an example
is provided in 4.7.
47
Figure 4.7: Status of the simulation
4.3 Simulation Outputs
The program will run until completion where a series of results will automatically
be generated.
Once the simulation has finished it will output plots, these plots are listed in the
list below with a link to an example figure.
• Scatter plot of the time to find the lost object in each evolution cycle 4.8a.
• The mean time to find the lost object in each evolution cycle 4.8b.
• A first order polynomial line of fit in each evolution cycle 4.8c.
• A second order polynomial line of fit in each evolution cycle 4.8d.
The program run time can take several hours and result in very high GPU and
CPU processing power. If running on a laptop or battery power computer ensure
that it is connected to a power supply and has ventilation to ensure the computer
cooling systems can function at their maximum potential.
48
(a) Iterations to find per evolution cycle
(b) Mean iterations to find per evolution cy-
cle
(c) First Order Polynomial Fit (d) Second Order Polynomial Fit
Figure 4.8: Simulation Outputs
49
Chapter 5
Future Work
5.1 Homogeneous Characteristics
The simulation only included drones with three behavioural characteristics that
evolved. Future work could add to these characteristics. Future work could include
adding behavioural characteristics listed in the subsections below
5.1.1 Wake vortex surfing
Like a flock of birds flying in a V-formation if an aircraft positions itself in the
updraft of the wake vortex of the aircraft in front an aerodynamic advantage can
be achieved. Greater aerodynamic e ciency is achieved and flight endurance can
be increased. Figure 5.1 shows the positioning of an aircraft that is wake vortex
surfing. As this is a very complex aerodynamic process a simplification could be
to place an extending cone behind the aircraft and the aircraft will be said to be
surfing if it is within that cone. Future work could go even further and model
the aerodynamic forces generated from each aircraft so an exact position could be
50
generated and optimised.
Figure 5.1: Wake Vortex Surfing [1]
5.1.2 Manoeuvring Speed
As the UAV flies faster its turn radius is increased due to G-loading limitations on
the aircraft. If the UAV flies slower the turn radius is decreased. The UAV could
be programmed to fly to curvatures of turns and optimised.
5.1.3 Flight pattern optimisation
Each UAV could communicate to a central database and update its position. This
database will record a breadcrumb trail so other UAVs know that the area has
already been covered. Each UAV will be responsible for plotting its own routes and
will take into consideration the breadcrumb trails on a one by one basis. The UAVs
will assess how much virgin airspace is around and how to best fly to that area
and the most e cient way to cover the most ground without flying over excessive
amounts of bread trails.
I had attempted to implement this into my simulation at the beginning however
the path planning required was an enormous amount of work and required extreme
51
amounts of CPU cycles. It was abandoned due to time constraints.
Communication strategies
How often the UAVs communicates with the central database updating its bread-
crumb trails. Some UAVs will update the central database every second whilst
others will update at a much slower rate.
5.1.4 Distance between agents
The distance between the UAVs at the start will be varied. It may be beneficial to
have a large dispersion to begin with rather than all the drone clumped together.
This will include vertical separation.
5.1.5 Breeding techniques
Prime vs. group style mating will be included. Some UAVs would prefer to mate
with the UAV that has the most lost ship finds. Whilst others would mate with
the closest UAV available. This will be varied with individual genes. The UAV life
span could be varied. Some UAVs will live for a one mating iterations whilst others
could live from one to 10 mating iterations.
5.2 Non Homogenous Physical Characteristics
Physical characteristics could be altered. Physical characteristics are features that
cannot be altered by software as they are hardware changes and need physical labour
to be performed on each UAV.
52
5.2.1 Drifting Ship
The lost agent could be programmed to move in a random direction and speed and
see if the swarm can optimise the search for the moving agent.
5.2.2 Impeding factors
Factors such as wind, physical obstacles or whether phenomenon could be included
in the model. The UAVs would have to deal with sensor shadow and obscuration.
53
Chapter 6
Real World Applications
There are numerous applications of genetic algorithms in the real world. My research
has a narrow focus on search pattern optimisation. However these methods can be
used to optimise an almost infinite number of solutions.
6.1 New and Changing areas of interest
When searching for an object the search patterns change depending on the landscape
the search is taking place on and what you are searching for. For example if a plane
had crashed in the desert the type of search methods used to find the downed plane
would di↵er to those used if the plane had crashed in a mountainous jungle region.
In a traditional hot desert (one with sand dunes, as opposed to the arctic and
subarctic deserts). the area has sparse vegetation and the ground is not obstructed
from view. The only impediment to visual or sensor detection ability is where sand
dunes create a shadow or black spot behind itself. An optimal search method that
yielded the most number of detections is likely to have the search drones flying at a
high altitude to take advantage of the open unobstructed ground and minimise the
54
black spots caused by high sand dunes.
However in the mountainous jungle region flying high will not yield many de-
tections of the lost agent. This is due to a dense tree canopy obscuring the ground
from view and very large regions of mountains that block the drones sensors from
being able to see what lies on the other side.
I am not able to say what the optimised solution for searching in these areas
would be but if the parameters were programmed into the simulator it would be
able to optimise the characteristics.
These characteristics could then be saved into a repository, when a new swarm
of drones is searching an area it could look up previous search types and program
its search drones to use the best characteristics from last time. As the situation will
never be exactly the same the system will continue to adapt and evolve to become
more and more optimised.
6.2 Suspected Routes
By knowing a route an object may have taken or moves in a search area can be
deduced. For example if a lost agent was known to be moving along in a sinusoidal
pattern the location would be unknown but the possible path is defined. In the UAV
evolution simulation the lost object is placed randomly on a sine wave. This concept
is explained in section 3.4.2. An example where the could be applied would be if an
aeroplane crashed and its pattern of movement was known. The suspected movement
pattern could be applied into the simulation and the drones would optimise their
search pattern to the suspected pattern of movement. These parameters could be
entered into the real search drones.
55
Chapter 7
Results and Discussion
7.1 Resetting the Start location
The simulation was set such that every time the lost agent was found the UAVs
would return to the initial start location, this is explained in more detail in section
3.8.1.
7.1.1 Random lost agent evolution
The simulation was set to run for 10 evolutions and the age of sexual maturity was
varied. The lost agent position was set randomly for every evolution cycle. Every
time the UAVs found the lost agent they return to the original start location. 8
UAVs were used, table 7.1 show the input values for the simulation. The results are
shown in figures 7.1 and 7.2.
56
8 UAV agents
No Distrubance
Evolutions Age of Sexual Maturity Timeout Figures
10 1 100,000 7.1a & 7.2b
10 5 100,000 7.1b & 7.2b
10 10 100,000 7.1c & 7.2c
10 20 100,000 7.1d & 7.2d
Table 7.1: Results UAVs: 8, no disturbance
(a) Evolution is not occurring, Sexual Matu-
rity Age: 1
(b) Evolution is not occurring, Sexual Matu-
rity Age: 5
(c) Evolution is occurring, Sexual Maturity
Age: 10
(d) Evolution is occurring, Sexual Maturity
Age: 20
Figure 7.1: Average time to find lost agent without a disturbance
57
(a) Evolution is aparently occurring, Sexual
Maturity Age: 1
(b) Evolution is not occurring, Sexual Matu-
rity Age: 5
(c) Evolution is occurring, Sexual Maturity
Age: 1
(d) Evolution is not occurring, Sexual Matu-
rity Age: 1
Figure 7.2: Linear line of best fit applied to the time to find the lost agent without
a disturbance
Discussion
Figures 7.1a and 7.2b show simulations that have been run for 10 evolution cycles
and have sexual maturity ages of 1 and 5 respectively. The graphs show the systems
are not evolving as the time taken to find the lost agent are increasing. figure
7.2a is distorted by an outlier in the data set shown in 7.1a as the system gets
slower in finding the lost agent, the system returns to the norm however this is not
an improvement on the UAV characteristics. 7.2b shows that the trend is for the
system to find the lost agent slowes each time. Once the Sexual maturity age passes
58
10 iterations the simulation shows that the UAVs start to evolve and find the lost
agent faster. figures 7.2c and 7.2d show a trend for finding the lost agent faster each
time. Mutations have caused the search time to increase in some instances however
the system recovers and the trend is to find the trend line suggests the lost agent is
found faster each time.
59
7.1.2 Adding a disturbance
The simulation was set to run for 10 evolutions and the age of sexual maturity varied.
Every time the UAVs find the lost agent they return to the original start location.
The simulation is set to evolve to find the lost agent which is placed randomly for
the first 5 evolutions. From evolution 6 through to 10 the lost agent was placed
randomly on a sine wave the implementation of this is shown in section 3.4.2. Eight
UAVs were used, tables 7.2 show the input values. The results are shown in figure
7.3.
8 UAV agents
Sine Disturbance Added at 5 Evolutions
Evolutions Age of Sexual Maturity Timeout Figure
10 1 100,000 7.3a
10 5 100,000 7.3b
10 10 100,000 7.3c
10 50 100,000 7.3d
Table 7.2: Results UAVs: 8, with sine wave disturbance
60
(a) Evolution is not occurring, Sexual Matu-
rity Age: 1
(b) Evolution is unclear if it is occurring, Sex-
ual Maturity Age: 5
(c) Evolution is occurring, Sexual Maturity
Age: 10
(d) Evolution is occurring with an outlier at
evolution cycle 9, Sexual Maturity Age: 50
Figure 7.3: Average time to find lost agent with a disturbance added at evolution
stage 6
Discussion
Figure shows simulations that have been run for 10 evolution cycles and have sexual
maturity ages of 1 and 5 respectively. A disturbance was added at evolution cycle
6. The graphs show that simulations 7.3a and 7.3b are not evolving to find the
lost agent faster. Once the Sexual maturity age passes 10 iterations the simulation
shows that the UAVs start to evolve and find the lost agent faster. Mutations have
caused the search time to increase in some instances and cause outliers however the
the system recovers and the trend is to find the lost agent faster each time.
61
7.2 Continuing on path
When the UAV finds the lost agent it continues on its path and the drones location
does not reset, this is explained in more detail in section 3.8.2
7.2.1 Random lost agent evolution
The simulation was set to run for 10 evolutions and the age of sexual maturity was
varied. The lost agent was set randomly for every evolution. Every time the UAVs
fine the lost agent they continue on their path. The UAVs reset to the home location
after every evolution. Eight UAVs were used, table 7.3 show the input values. The
results are shown in figures 7.4 and 7.5.
8 UAV agents
No Distrubance
Evolutions Age of Sexual Maturity Timeout Figures
10 1 100,000 7.4a & 7.5a
10 5 100,000 7.4b & 7.5b
10 10 100,000 7.4c & 7.5c
10 20 100,000 7.4d & 7.5d
Table 7.3: Results UAVs: 8, no disturbance
62
(a) Evolution is not occurring, Sexual Matu-
rity Age: 1
(b) Evolution is not occurring, Sexual Matu-
rity Age: 5
(c) Evolution is starting to occure, Sexual
Maturity Age: 10
(d) Evolution is occurring, Sexual Maturity
Age: 20
Figure 7.4: Average time to find lost agent without a disturbance and continuing
on the UAVs path without resetting its position
63
(a) Evolution is not occurring, Sexual Matu-
rity Age: 1
(b) Evolution is not occurring, Sexual Matu-
rity Age: 5
(c) Evolution is occurring, Sexual Maturity
Age: 10
(d) Evolution is occurring, Sexual Maturity
Age: 20
Figure 7.5: Linear line of best fit applied to the time to find the lost agent without
a disturbance and continuing on the UAVs path with out resetting its position
Discussion
The graphs above in section 7.2.1 show that evolution is not occurring to optimise the
simulation in simulations where the minimum breeding age is set below 10 iteration
cycles. Once the system reaches a sexual maturity age of 10 cycles then evolution
starts to optimise the time to find the lost agent.
64
7.2.2 Adding a disturbance
The simulation was set to run for 10 evolutions and the age of sexual maturity
varied. Every time the UAVs fine the lost agent they continue on their path the
reset every evolution cycle. The simulation is set to evolve to find the lost agent
which is placed randomly for the first 5 evolutions. From evolution 6 through to
10 the lost agent was placed randomly on a sine wave the implementation of this is
shown in section 3.4.2. 8 UAVs were used, tables 7.4 show the input values. The
results are shown in figures 7.6 and 7.7.
8 UAV agents
Sine Disturbance Added at 5 Evolutions
Evolutions Age of Sexual Maturity Timeout Figures
10 1 100,000 7.6a & 7.7a
10 5 100,000 7.6b & 7.7b
10 10 100,000 7.6c & 7.7c
10 20 100,000 7.6d & 7.7d
Table 7.4: Results UAVs: 8, with wine wave disturbance
65
(a) Evolution is not occurring, Sexual Matu-
rity Age: 1
(b) Evolution is not occurring, Sexual Matu-
rity Age: 5
(c) Evolution is occurring, Sexual Maturity
Age: 10
(d) Evolution is occurring, Sexual Maturity
Age: 20
Figure 7.6: Average time to find lost agent with a disturbance and continuing on
the UAVs path without resetting its position
66
(a) Evolution is aparently occurring, Sexual
Maturity Age: 1
(b) Evolution is not occurring, Sexual Matu-
rity Age: 5
(c) Evolution is occurring, Sexual Maturity
Age: 10
(d) Evolution is apparently occurring but it
is not acutally, Sexual Maturity Age: 20
Figure 7.7: Linear line of best fit applied to the time to find the lost agent with a
disturbance and continuing on the UAVs path with out resetting its position
Discussion
Again for simulations where the sexual maturity age is set below 10 iteration cycles
the system does not optimise.
7.3 Discussion
The results above have yielded interesting outcomes. The results that I encoun-
tered were as I had expected but required further analysis to fully understand their
implications.
67
7.3.1 Sexual maturity age
The age at which drone is allowed to breed is vitally important for the swarm to
optimise its characteristics. 7.3a is an excellent example where the age at which the
drones were allowed to breed did not improve the search time for the lost agent. The
search times oscillate and do not improve. When compared to simulations where
the sexual age of maturity is greater than or equal 10 iteration cycles such as in 7.3c
it is clear that the swarm needs time to prove a particular UAVs genes are superior.
The reason the age needs to be set is because a UAV may have a lucky find by
chance and not have the best genes for the scenario.
7.3.2 Randomness and Repeatability
Every simulation run was di↵erent, the plots above do not run o↵ a common data
set rather they are ’online versions’. The nature of random generators means that
each simulation is unique and di↵erent to the next. Using trend lines and averages
the overall picture of each simulation was able to be extrapolated.
7.3.3 Mutations
Mutations are critical in allowing the simulation to adapt to changing environments.
If the simulation is allowed to only take the characteristics of the most successful
drone then if all the drones may get stuck in an infinite loop as all their characteristics
could be the same and none of them would ever find the lost object. The mutations
are vital as they will upset the balance and inject a new characteristic that can pull
the swarm out of an infinite loop.
68
7.3.4 Starting Position
The a comparison of the plots in sections 7.1 and 7.2 show that the swarm is able
to adapt to the system if it is allowed to remain on its trajectory and not reset its
position every time the lost agent is found. This reduces the chance of a lucky find
by a UAV as they make themselves more and more unique by not resetting their
start position.
7.3.5 Semi Random Disturbance Fitting
The removal of complete uncertainty of the lost agents position by placing it ran-
domly on a sine curve does not upset the system to a point where it can be further
optimised. The plots above do not show an decrease in time to find the lost agent,
rather the simulation times to find the lost agent decrease at a expected rate as
before the disturbance was added.
7.3.6 Unexplainable spike increase in search time
There is an interesting feature that I am not able to explain in the results. For
around 50% of simulations an increase in time taken to find the lost agent on the
second, third or fourth evolutionary step is recorded. This can be seen in figure
7.8a.
When the scatter plot is analysed in figure 7.8b it is clear that the average time
to detect the lost agent is longer.
69
(a) Average time taken to find lost agent
(b) scatter plot of time taken to find lost
agent
Figure 7.8: Evolution Cycles: 10, Sexual Maturity age: 15, Timeout: 100,000
70
Chapter 8
Conclusion
Through the use of a genetic algorithm the search characteristics of a swarm of
UAVs was able to be optimised to find a lost agent faster.
A homogenous swarm of search drones was able to evolve their characteristics
to find a randomly placed lost object. Their speeds of detection increased as their
genetics changed and adapted to the environment.
A vital part of evolution that was identified was the need to delay the age of
sexual maturity. If the age of sexual maturity was set to young the system stayed
in its current state and a improvement of detection times was not noticed. However
if the age of sexual maturity was delayed then the UAVs with the strongest charac-
teristics was able to prove that it was the ’alpha’ UAV and passed down its superior
genes to the other drones. The reason the system did not evolve if the age of sexual
maturity was set to young is that some of the UAVs would have a lucky find of the
lost agent. It is an interesting comparison to reality in nature where if animals or
humans mate to early they may pass down defective genes.
A semi random lost path was used to place the lost agent randomly on a sine
71
wave. From the simulations there was not a noticeable change in the time to taken
to find the lost agent when the lost agent was placed on the sine wave. The system
was not able to adapt to find a semi random lost agent faster than a fully random
lost agent.
An unexplainable scenario readily occurs on the second, third or fourth step of
evolution where the time to find the lost agent increases and then decreases. This
increase in search time was not able to be explained and was evident in around 50%
of simulations.
The thesis was a success, the aim of achieving a system that is able to modify
itself in order to find a lost agent faster was accomplished. There is more scope for
research and fine tuning and further applications.
72
Chapter 9
Personal Remarks
9.1 The idea
I grappled with my thesis topic for many months. The topic morphed and grew like
a tree root searching for water. I took some paths that I thought were good but
turned out to be dead ends until eventually like a process of evolution I found water
(my final idea).
I had just returned to Australia and UNSW from probably the most exciting
time of my life. I was working and living in France working for Airbus in their Re-
search and Development team. I was brimming with ideas on the aviation industry
and found a new passion that I wanted to move my life in. I had worked next to
people who were developing revolutionary software and hardware that will be imple-
mented in the aviation industry in the next 20 years. One of my colleagues at lunch
mentioned the idea of surfing the wake vortex of another aircraft in order to reduce
fuel consumption. I was bright eyed and thought this was the best idea since sliced
bread. I instantly became interested. I wanted to extend the endurance of aircraft
73
flying so that they could fly further distances or use less fuel when flying. I wanted
to implement this with drones as any lift producing surface will produce a vortex,
meaning even helicopters can ride the vortex. Much work is being conducted with
the USAF (United States Airforce) in the fuel saving e↵ects this can have. I came
into my first meeting with my supervisor and he said that this idea had merit but
as I came from a mechatronics background that this would be a bit over my head. I
had not been exposed to the aerodynamics required to calculate the optimum points
for aircraft positioning. He instead said that I could mimic this e↵ect by placing a
cone wake e↵ect o↵ the end of the rotor and place each vehicle in this and say that
they were surfing the vortex. I was happy to do this but it left me with the worlds
shortest thesis topic. He realised my dilemma and suggested that this could be a
characteristic that aircraft exploit. He suggested a research area looking in the fact
that aircraft could learn from their surroundings. For instance an Aircraft flying
over the dessert searching for a lost person would need to utilise di↵erent search
tactics to aircraft flying over the sea or a mountainous area. I thought that this
was an incredibly interesting area and was hooked. Their existed almost endless
permutations that I could research, I chose to simplify my model and have a lost
ship at sea with aircraft searching for it. This was a simple 3D model that I could
build upon.
9.2 Programming Languages
Initially my thesis supervisor suggested that I run the simulation in a program called
”AnyLogic” I ran into licensing issues and I was unfamiliar with the way the program
ran. I was told that I was able to select any program of my choice, I began a search
74
and comparison of languages that I could use. During my university career I have
programmed in C, C++, C#, and Matlab. As I learnt the fundamentals of C first
the rest of the programming languages were a natural progression as they were all
derived from C. The adage is if you can program in C you can program in anything.
9.2.1 AnyLogic
Initially I was told that ”Anylogic” could be used to simulate processes and that
this would be a suitable software package to run my simulation on. I spent about
a few hours a week for six weeks in my supervisors o ce running through tutorials
and learning how the software worked. There was a steep learning curve, Anylogic
is a proven platform that is can be used to model Discrete Event, Agent Based
and System Dynamics Simulation [2]. I knew that Anylogic was a industry proven
method that would work. It provided a large database of predefined variables and an
excellent GUI (Graphical User Interface). However for my thesis I required greater
functionality. This meant that I needed to learn ”Java”. I contacted Anylogic head
quarters in the USA and looked into undertaking one of their programming courses.
They did not have any courses in Australia. If I was to take one of these courses
I would need to travel to the USA. I was willing to spend the money on an airfare
and undertake the course but in the end I was not able to take the time o↵ from
university. I understood that Java is a industry standard however I was not willing
to take the leap of faith to learn a completely new programming language. I needed
an alternative way to run my simulation.
75
9.2.2 Matlab
My next thought was to use Matlab, my supervisor was very flexible and would have
let me use smoke signals if I could make them into a working model. The UNSW
courses that I have done so far have a great reliance on Matlab for the bulk of their
course work. I had used it in many subjects and had even started using it in place
of other programs like Microsoft Excel to complete assignments for other subjects.
I conducted an internship with Airbus in France for six months. The bulk of my
work there utilised Excel and Matlab. I was familiar with Matlab prior to working
at Airbus but at the end of my employment I was a very capable programmer.
Programming in Matlab would mean that I would have to create everything
from scratch and that there would not be an existing programming environment
that I could just put parameters into and make it work. This was a large leap of
faith as my supervisor told me that the success of my thesis rested on my ability
to get the simulation working. I didn’t know if I had the computing knowledge and
programming experience to do this. Needless to say I was very nervous, I knew that
there were a vast amount of resources at UNSW if I ran into trouble with Matlab.
I decided in the end that Matlab was the best approach as it would allow the most
flexibility, the only limitation that I would have with Matlab was my programming
ability.
At the end of my thesis now I am very glad I used Matlab to run my simulations.
76
Bibliography
[1] Aerospace and defense. 2014.
[2] Anylogic, May 2015.
[3] K. Bo´nkowska S. Cebrat A. Laszkiewicz, P.Biecek. From Genetics to Mathe-
matics, volume 79 of Series on Advances in Matematics for Applied Sciences.
World Scientific Publishing Company, 2009.
[4] Stefan R.Flanzer Tristan C. Blake, William Bieniawski. Surfing aircraft vorti-
cies for energy. The Journal of Defense Modeling and Simulation: Applications,
Methodology, Technology, 2013.
[5] Sharkey; AmandaJ C. Robots, insects and swarm intelligence. Artificial Intel-
ligence Review, 26(4):255–268, December 2006.
[6] Charles Darwin. The Origin of Species by Means of Natural Selection. 1859.
[7] Rania Hassan; Babak Cohanim; Olivier de Weck. A comparison of particle
swarm optimization and the genetic algorithm. American Institute of Aeronat-
ics and Astronautics, pages 1 – 13.
[8] The Free Dictionary. The free dictionary, April 2015.
77
[9] James Kennedy; Russell Eberhart. Particle swarm optimization, neural net-
works. IEEE, 4:1942 – 1948, Nov/Dec 1995.
[10] Frauke Feind. Geese. pixabay right free, 2014.
[11] Western Australian State Government. Boys and puberty. Booklet online.
[12] Western Australian State Government. Girls and puberty. Online Booklet.
[13] Jose Guivant. Advanced autonomous systems - task 0. Technical report, 2015.
[14] John Holland. Genetic algorithms, computer programs that ”evolve” in ways
that resemble natural selection can solve complex problems even their creators
do not fully understand. Scientific American, July 1992.
[15] Cadell Last. Current Aging Science, volume 7. Bentham Science, 2014.
[16] Adam Lipowski; Dorota Lipowska. Roulette-wheel selection via stochastic ac-
cptance. Physica A, 391(6):2193 – 2196, March 2012.
[17] PixelAnarchy. Fish. Pixabay right free, June 2006.
[18] Jonathan Price. Determining altitude agl using optical flow. 2014.
[19] J. Harwood; J.J Prime. Some factors a↵ecitng the size of british grey seal
populations. Journal of Applied Ecology, 15:401–411, August 1978.
[20] Craig W. Reynolds. Flocks, herds and schools: A distributed behavioral model.
SIGGRAPH Comput. Graph., 21(4):25–34, 1987.
[21] M ; Rash J.L ; Xukai Zou Yuan-Shun Dai; Hinchey, M; Madhusoodan. A pro-
totype model for self-healing and self-reproduction in swarm robotics system.
78
pages 3–10, Indianapolis, IN, 2006. Dependable, Autonomic and Secure Com-
puting, 2nd IEEE International Symposium, IEEE.
79
Matlab Code
1 %Author: Alexander Champion de Crespigny
2 %Date Last Edit: 31 May 2015
3 %Program: My theis simulation file that optimises the characteristics
,! of a drone simulation searching for a ship at sea.
4
5 function DroneEvolutionSimulation()
6 Erase()
7
8 global MySearch
9 global Genetics
10 global Map
11 global LengthSearch
12 global Position
13 global Breeding Stats
14 global DNA2USE
15 global Results
16 global Evolutions
17 global TimetoProveDNA
18 global currentEvolution
19 global AngleHistory
80
20 global timeout Length
21 global ResultsPlot
22
23 %50 50 100 took 14431 seconds = 4 hours
24
25 MySearch.NumberOfDrones = 8;
26
27 % Map Size
28 Map.xmin = -80000; Map.xmax = 80000;
29 Map.ymin = -80000; Map.ymax = 80000;
30
31 Inputs();
32
33
34 % Evolutions = 2;
35 % TimetoProveDNA = 1;
36 % timeout Length = 100000;
37
38
39 Genetics.Min Alt = 0;
40 Genetics.Max Alt = 2000;
41 Genetics.Min Speed = 0;
42 Genetics.Max Speed = 50000;
43 Genetics.Min Angle = -180;
44 Genetics.Max Angle = 180;
45
46 Genetics.RandomAngle = (Genetics.Min Angle:1:Genetics.Max Angle); %
,! creates a matrix of random angles that can be entered to cause
,! mutations
81
47
48 %Each new column is a different drone
49
50
51 Genetics.Altitude = randi([Genetics.Min Alt, Genetics.Max Alt],[1,8]);
52 Genetics.Speed = randi([Genetics.Min Speed, Genetics.Max Speed
,! ],[1,8]);
53 Genetics.Angle = randi([Genetics.Min Angle, Genetics.Max Angle
,! ],[1,8]);
54
55
56 % Genetics.Altitude = [100 ; 400 ; 600 ; 800 ; 1200 ; 1400 ; 1600 ;
,! 1800 ];
57 % Genetics.Speed = [100 ; 500 ; 800 ; 1000 ; 1500 ; 2000 ; 2500 ;
,! 3000 ];
58 % Genetics.Angle = [1 , 46 , 90 , 136 , 179 , -44 , -90 ,
,! -134 ]; %90 is straight up anything else bounces off walls
59 % Genetics.Angle =
60 %Search Type
61 % 1 = Linear
62 % 2 = Box
63 % 3 = Circular
64 % 4 = random
65 Genetics.Search Type = [1; 1; 1; 1; 1; 1; 1; 1]; %1 =
66 AngleHistory = zeros(MySearch.NumberOfDrones, Evolutions);
67 tic
68 TimetoFind = zeros(TimetoProveDNA, Evolutions);
69 for k = 1:Evolutions
70 currentEvolution = k;
82
71 if k ~= 1
72 Breed();
73 end
74 Simulation = 1;
75
76 AngleUsageoverBreeding()
77
78 Position.UAV 1 = [0-4000,Map.ymin+1,deg2rad(Genetics.Angle(1))
,! ]; %Startx, Starty, Start Angle
79 Position.UAV 2 = [0-3000,Map.ymin+1,deg2rad(Genetics.Angle(2))
,! ];
80 Position.UAV 3 = [0-2000,Map.ymin+1,deg2rad(Genetics.Angle(3))
,! ];
81 Position.UAV 4 = [0-1000,Map.ymin+1,deg2rad(Genetics.Angle(4))
,! ];
82 Position.UAV 5 = [0+1000,Map.ymin+1,deg2rad(Genetics.Angle(5))
,! ];
83 Position.UAV 6 = [0+2000,Map.ymin+1,deg2rad(Genetics.Angle(6))
,! ];
84 Position.UAV 7 = [0+3000,Map.ymin+1,deg2rad(Genetics.Angle(7))
,! ];
85 Position.UAV 8 = [0+4000,Map.ymin+1,deg2rad(Genetics.Angle(8))
,! ];
86 for i = 1:TimetoProveDNA
87
88
89
90 MySearch.Detected = 0;
91
83
92 LengthSearch = 10;
93 index = 1;
94
95 figure(1); clf;
96 % figure('name','Drone Evolution Simulation','Visible','on
,! ','NumberTitle','off');
97 hold on
98 zoom on
99 MySearch.Map = plot(0,0) ; % Defines the map
100 MySearch.Wave = plot(0,0);
101 axis([Map.xmin,Map.xmax,Map.ymin,Map.ymax]); % Makes the graph
,! a certain size
102 xlabel('Distance (m)')
103 ylabel('Distance (m)')
104
105
106 %%Plot the Drones
107 MySearch.UAV1.Pos = plot(Position.UAV 1(1),Position.UAV 1(2),'y
,! *') ; %UAV 1
108 MySearch.UAV2.Pos = plot(Position.UAV 2(1),Position.UAV 2(2),'m
,! *') ; %UAV 2
109 MySearch.UAV3.Pos = plot(Position.UAV 3(1),Position.UAV 3(2),'c
,! *') ; %UAV 3
110 MySearch.UAV4.Pos = plot(Position.UAV 4(1),Position.UAV 4(2),'r
,! *') ; %UAV 4
111 MySearch.UAV5.Pos = plot(Position.UAV 5(1),Position.UAV 5(2),'g
,! *') ; %UAV 5
112 MySearch.UAV6.Pos = plot(Position.UAV 6(1),Position.UAV 6(2),'b
,! *') ; %UAV 6
84
113 MySearch.UAV7.Pos = plot(Position.UAV 7(1),Position.UAV 7(2),'r
,! +') ; %UAV 7
114 MySearch.UAV8.Pos = plot(Position.UAV 8(1),Position.UAV 8(2),'k
,! *') ; %UAV 8
115
116 MySearch.UAV1.Circle = plot(Position.UAV 1(1),Position.UAV 1(2)
,! ,'g') ; %UAV 1
117 legend(' ' ,'Sine Wave', 'Drone 1','Drone 2','Drone 3', 'Drone
,! 4','Drone 5','Drone 6','Drone 7', 'Drone 8','Sensor Area
,! ', 'Location','southoutside','Orientation','horizontal')
,! ;
118
119 MySearch.UAV2.Circle = plot(Position.UAV 2(1),Position.UAV 2(2)
,! ,'g') ; %UAV 2
120 MySearch.UAV3.Circle = plot(Position.UAV 3(1),Position.UAV 3(2)
,! ,'g') ; %UAV 3
121 MySearch.UAV4.Circle = plot(Position.UAV 4(1),Position.UAV 4(2)
,! ,'g') ; %UAV 4
122
123 MySearch.UAV5.Circle = plot(Position.UAV 5(1),Position.UAV 5(2)
,! ,'g') ; %UAV 5
124 MySearch.UAV6.Circle = plot(Position.UAV 6(1),Position.UAV 6(2)
,! ,'g') ; %UAV 6
125 MySearch.UAV7.Circle = plot(Position.UAV 7(1),Position.UAV 7(2)
,! ,'g') ; %UAV 7
126 MySearch.UAV8.Circle = plot(Position.UAV 8(1),Position.UAV 8(2)
,! ,'g') ; %UAV 8
127 %%
128
85
129 MySearch.Lost = plot(0,0,'rd') ; %lost agent
130 % zoom on % I don't know what this does.
131 box on % makes a continous box around the graph
132 % set(gca,'xtick',[],'ytick',[]) % removes the tick marks
,! off the graph
133 title('Search Area'); %Adds the title to the graph
134 if k <= Evolutions/2
135 RandOrSin = 1;
136 else
137 RandOrSin = 2; %turn back on for sine wave
138 end
139 Lost Agent(RandOrSin);
140
141 while MySearch.Detected == 0;
142
143 if index <= timeout Length
144 printSatus(index,timeout Length, i, k, Evolutions,
,! TimetoProveDNA);
145
146 UAV1(index);
147 UAV2(index);
148 UAV3(index);
149 UAV4(index);
150 UAV5(index);
151 UAV6(index);
152 UAV7(index);
153 UAV8(index);
154 pause(.0001);
155 index = index + 1;
86
156 if MySearch.Detected == 1
157 Breeding Stats(Simulation, 1) = MySearch.
,! SucessuflDrone; % what drone detected the
,! object
158 % Breeding Stats(Simulation, 2) =
,! MySearch.SucessfulSpeed;
159 % Breeding Stats(Simulation, 3) =
,! MySearch.SucessfulAltitude;
160
161
162
163
164 end
165 else
166 MySearch.Detected = 1;
167 end
168 end
169
170 TimetoFind(i,k) = index;
171 Results = TimetoFind;
172 save('Results');
173 Simulation = Simulation + 1;
174
175
176 pause(0.0001);
177 end
178 % pause(0.0001);
179
180 save('Breeding Stats')
87
181 BestDrone()
182 end
183 toc
184
185 processResults(TimetoFind)
186 end
187
188 function printSatus(index,timeout Length, i, k, Evolutions,
,! TimetoProveDNA)
189 clc
190 fprintf('Evolution cycle %d of %dn', k, Evolutions);
191 fprintf('Run cycle %d of %dn', i, TimetoProveDNA);
192 fprintf('Iterations until time out %dn', (timeout Length-index));
193 end
194
195 function BestDrone()
196 global Breeding Stats
197 global MySearch
198 global Genetics
199 global DNA2USE
200
201 BestestDrone = zeros(MySearch.NumberOfDrones, 1);
202 if isempty(Breeding Stats) ~= 1
203 for i = 1: MySearch.NumberOfDrones
204 BestestDrone(i,1) = sum(Breeding Stats(:, 1) == i);
205 end
206 end
207 [~, Bestest1Drone] = max(BestestDrone);
208
88
209 %Strongest Characteristics
210 % DroneID, Speed, Altitude, Search Type
211 DNA2USE = [Bestest1Drone, Genetics.Altitude(Bestest1Drone), Genetics.
,! Speed(Bestest1Drone), Genetics.Angle(Bestest1Drone)];
212 end
213
214 function Breed()
215 % Breed % I want the other drones to take 1/3 of the sucessful drones
,! DNA(persay)
216 global Breeding Stats
217 global Genetics
218 global DNA2USE
219 global MySearch
220
221 %Genetic to take at a random
222 for i = 1:MySearch.NumberOfDrones
223 Gene2take = randi([2,4],[1,1]);
224 if Gene2take == 2
225 Genetics.Altitude(i) = DNA2USE(Gene2take);
226 else if Gene2take == 3
227 Genetics.Speed(i) = DNA2USE(Gene2take);
228 else if Gene2take == 4
229 Genetics.Angle(i) = DNA2USE(Gene2take);
230 end
231 end
232 end
233 end
234
235
89
236 % Mutations also need to occur and this can be seen as recessant genes,
237 % lets take genes from the origional sample and implement them.
238
239 RandDrone = randi([1,MySearch.NumberOfDrones], [1,3]); % Choose a
,! random drone
240 RandAngle = randi([-180,180],[1,1]); % Choose a random angle
241 RandSpeed = randi([Genetics.Min Speed,Genetics.Max Speed],[1,1]);
242 RandAlt = randi([Genetics.Min Alt,Genetics.Max Alt],[1,1]);
243
244 Genetics.Angle(RandDrone(1)) = RandAngle; %assign random angle to
,! random
245 Genetics.Speed(RandDrone(2)) = RandSpeed;
246 Genetics.Altitude(RandDrone(3)) = RandAlt;
247
248 end
249
250 function AngleUsageoverBreeding()
251 global Genetics
252 global currentEvolution
253 global MySearch
254 global Evolutions
255 global AngleHistory
256
257 for l = 1:MySearch.NumberOfDrones
258 AngleHistory(l,currentEvolution) = Genetics.Angle(l);
259 end
260 save('AngleHistory');
261 end
262
90
263 function [xp, yp] = Circle(r)
264 %x and y are the coordinates of the center of the circle
265 %r is the radius of the circle
266 %0.01 is the angle step, bigger values will draw the circle faster but
267 %you might notice imperfections (not very smooth)
268 ang=0:0.01:2*pi;
269 xp=r*cos(ang);
270 yp=r*sin(ang);
271
272 end
273
274 function Detected(Distance, Radius, Drone Number, Altitude, Speed)
275 global MySearch
276 global Genetics
277
278 %Speed Accuracy
279 Speed Accuracy = 1 - (Speed/Genetics.Max Speed);
280
281 %Altitude Accuracy
282 Altitude Accuracy = 1 - (Altitude/Genetics.Max Alt);
283
284 %Total Accuracy
285 Total Accuracy = Speed Accuracy * Altitude Accuracy;
286
287 Random Number = rand(1);
288 Total Accuracy = (Total Accuracy + Random Number);
289
290 if Distance <= Radius
291 if Total Accuracy >= 1
91
292 MySearch.Detected = 1;
293 Sucessful Drone(Drone Number, Altitude, Speed);
294 else
295 end
296 end
297 end
298
299 function Sucessful Drone(Drone Number, Altitude, Speed)
300 global MySearch
301 fprintf('The Object was detected by Drone: %dn', Drone Number);
302 MySearch.SucessuflDrone = Drone Number;
303 MySearch.SucessfulSpeed = Speed;
304 MySearch.SucessfulAltitude = Altitude;
305 end
306
307 function Distance = UAV2Lost(UAVPos)
308 global MySearch
309 Distance = sqrt(((UAVPos(1) - MySearch.Lost Pos(1))ˆ2) + ((UAVPos(2) -
,! MySearch.Lost Pos(2))ˆ2));
310 end
311
312 function Lost Agent(RandOrSin)
313 global MySearch
314 global Map
315 % Position of the lost agent
316 % Plots a random position
317 if RandOrSin == 1
318 XLostPos = randi([Map.xmin,Map.xmax],[1,1]); % This generates a X &
,! Y coordiante randomly within the map region
92
319 YLostPos = randi([Map.ymin,Map.ymax],[1,1]);
320
321 %Plots a random position on a sine curve
322 else if RandOrSin == 2
323 Amplitude = (abs(Map.ymin) + abs(Map.ymax))/2;
324 x = randi([Map.xmin, Map.xmax],[1,1]);
325 t = (Map.xmin:1:Map.xmax);
326 a = Amplitude*sin(t/3000);
327 x = abs(x*2);
328 XLostPos = t(x);
329 YLostPos = a(x);
330 set(MySearch.Wave, 'xdata', t, 'ydata', a);
331 end
332 end
333
334 Position = [XLostPos, YLostPos]; % This is an (X, Y) coordinate that is
,! generated randomly
335 set(MySearch.Lost, 'xdata', Position(1), 'ydata', Position(2));
336 MySearch.Lost Pos = [Position(1), Position(2)];
337 end
338
339 function Radius = SensorRadius(Altitude)
340 %This funcion takes in the UAVS altitude and then return a searchable
,! area
341 %for the sensor based on its altitude
342
343 Sensor Angle = 90; %deg total sweep so from the vertical it is 15deg
344
345 if Altitude < 0
93
346 fprintf('Drones cannot fly so low it had crashed');
347 else
348 Sensor Angle = deg2rad(Sensor Angle/2);
349 Half Radius = Altitude * tan(Sensor Angle);
350 Radius = 2*Half Radius;
351 end
352 end
353
354 function BoxSearch UAV 1(Speed, index, Radius)
355 global LengthSearch
356 global Position
357 L = 1;
358 dt = 0.01;
359 Alpha = 0;
360
361 [Dist2Top, Dist2Left, Dist2Bottom, Dist2Right] = Dist Circle2MapEdge(
,! Radius);
362
363 for i = 1:100
364 if Dist2Top <= i*Radius
365 Position.UAV 1(3) = deg2rad(180); % Turns left
366 end
367
368 if Dist2Left <= i*Radius
369 Position.UAV 1(3) = deg2rad(270); % Turns Down 
370 end
371
372 if Dist2Bottom <= i*Radius
373 Position.UAV 1(3) = deg2rad(0); % Turns Right 
94
374 end
375
376 if Dist2Right <= i*Radius
377 Position.UAV 1(3) = deg2rad(90); % Turns up 
378 end
379
380 end
381
382 % if Dist2Left <= 2*Radius
383 % Position.UAV 1(3) = deg2rad(270); % Turns Down 
384 % end
385 %
386 % if Dist2Bottom <= 2*Radius
387 % Position.UAV 1(3) = deg2rad(0); % Turns Right 
388 % end
389 %
390 % if Dist2Right <= 2*Radius
391 % Position.UAV 1(3) = deg2rad(90); % Turns up 
392 % % iteration = iteration + 1
393 % end
394
395 % needs to work out size of search are then adapt to search area
,! size
396 x2 = zeros(3, LengthSearch);
397
398 x2(:,index) = [Position.UAV 1(1); Position.UAV 1(2); Position.UAV 1(3)
,! ];
399
400 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index));
95
401 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index));
402 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha);
403
404 Position.UAV 1 = x2(:, index+1);
405 end
406
407 function [Dist2Top, Dist2Left, Dist2Bottom, Dist2Right] =
,! Dist Circle2MapEdge(Radius)
408 global Position
409 global Map
410
411 Map.xmin = -10000; Map.xmax = 10000;
412 Map.ymin = -10000; Map.ymax = 10000;
413
414 Dist2Top = abs(Map.ymax - Position.UAV 1(2));
415 Dist2Left = abs(Position.UAV 1(1) - Map.xmin);
416 Dist2Bottom = abs(Position.UAV 1(2)- Map.ymin);
417 Dist2Right = abs(Position.UAV 1(1) - Map.xmax);
418
419 end
420
421 function Erase()
422 close all
423 clear all
424 clc
425 end
426
427 function processResults(TimetoFind)
428 global Evolutions
96
429 global TimetoProveDNA
430 MeanTime = zeros(1,Evolutions);
431 for i = 1:Evolutions
432 MeanTime(:,i) = mean(TimetoFind(:,i));
433 end
434 x = 1:Evolutions;
435 figure('name','Mean Time','Visible','on','NumberTitle','off');
436 plot(x, MeanTime);
437 xlabel('Evolution Cycle');
438 ylabel('Time to Find lost object (iterations)');
439 legend('Mean time of to find lost agent from each Evolution');
440
441 figure('name','Time To Find Lost Agent','Visible','on','NumberTitle','
,! off');
442 Xscat = zeros(TimetoProveDNA, Evolutions);
443 for i = 1:Evolutions
444 Xscat(:,i) = i;
445 end
446 Xscat = Xscat(:)';
447 TimetoFind = TimetoFind(:)';
448 scatter(Xscat,TimetoFind);
449 xlabel('Evolution Cycle');
450 ylabel('Time to Find lost object (iterations)');
451 legend('Time of to find lost agent from each Evolution');
452
453 x = linspace(0,Evolutions);
454 figure('name','1st Order Polynomial fit','Visible','on','NumberTitle','
,! off');
455 p1 = polyfit(Xscat,TimetoFind,1);
97
456 y2 = polyval(p1,x);
457 plot(x,y2)
458 xlabel('Evolution Cycle');
459 ylabel('Time to Find lost object (iterations)');
460 legend('1st Order Polynomial');
461
462
463 x = linspace(0,Evolutions);
464 figure('name','2nd Order Polynomial fit','Visible','on','NumberTitle','
,! off');
465 p2 = polyfit(Xscat,TimetoFind,2);
466 y2 = polyval(p2,x);
467 plot(x,y2)
468 xlabel('Evolution Cycle');
469 ylabel('Time to Find lost object (iterations)');
470 legend('2nd Order Polynomial');
471
472 % figure(5);
473 % p3 = polyfit(Xscat,TimetoFind,3);
474 % y3 = polyval(p3,x);
475 % plot(x,y3)
476 %
477 % figure(6);
478 % p4 = polyfit(Xscat,TimetoFind,4);
479 % y4 = polyval(p4,x);
480 % plot(x,y4);
481 %
482 % figure(7);
483 % p5 = polyfit(Xscat,TimetoFind,5);
98
484 % y5 = polyval(p5,x);
485 % plot(x,y5);
486
487 % legend('Data', '2nd deg Fit', '3rd deg Fit', '4th deg Fit', '5th deg
,! Fit');
488
489
490 end
491
492 function Inputs()
493 global Evolutions
494 global TimetoProveDNA
495 global timeout Length
496
497
498 prompt={'Number of Evolutions:','Age of Drone sexual maturity','timeout
,! length'};
499 title='Evolution Simulation';
500
501 answer=inputdlg(prompt,title);
502
503 %Variables to be entered
504 Evolutions = str2num(answer{1});
505 TimetoProveDNA = str2num(answer{2});
506 timeout Length = str2num(answer{3});
507 end
508
509 %% Drone 1
510 function UAV1(index)
99
511 global MySearch
512 global Genetics
513 global Position
514 Drone Number = 1;
515 %Initial UAV Position entered as cartesian coordinates (X, Y,
,! Orientation(Deg)
516
517 % UAV Genetics
518 Speed = Genetics.Speed(1); %m/s % this will be fast or slow
519 Altitude = Genetics.Altitude(1); %m need to make it hight or low
520
521 Radius = SensorRadius(Altitude); % Runs a function that returns the
,! sensors search area
522 [xp, yp] = Circle(Radius);
523 Distance = UAV2Lost(Position.UAV 1); %returns the distance between the
,! UAV and lost object
524 Detected(Distance, Radius, Drone Number, Altitude, Speed);
525
526
527 if Genetics.Search Type(1) == 1
528 Movement UAV 1(Speed, index);
529 else if Genetics.Search Type(1) == 2
530 BoxSearch UAV 1(Speed, index, Radius);
531 end
532 end
533
534
535 set(MySearch.UAV1.Pos, 'xdata', Position.UAV 1(1), 'ydata', Position.
,! UAV 1(2));
100
536 set(MySearch.UAV1.Circle, 'xdata', Position.UAV 1(1) + xp, 'ydata',
,! Position.UAV 1(2) + yp);
537 end
538 function Movement UAV 1(Speed, index)
539 global LengthSearch
540 global Position
541 L = 1;
542 dt = 0.01;
543 Alpha = 0;
544
545 x2 = zeros(3, LengthSearch);
546 BouneOffEdges 1()
547 x2(:,index) = [Position.UAV 1(1); Position.UAV 1(2); Position.UAV 1(3)
,! ];
548
549 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index));
550 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index));
551 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha);
552
553 Position.UAV 1 = x2(:, index+1);
554 end
555 function BouneOffEdges 1()
556 global Position
557 global Map
558
559 if Position.UAV 1(1) <= Map.xmin % Reached Left
560 if rad2deg(Position.UAV 1(3)) <= 180
561 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1(3);
562 else
101
563 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1(3);
564 end
565
566 else if Position.UAV 1(2) >= Map.ymax; %Reached Top
567 if rad2deg(Position.UAV 1(3)) <= 180
568 Position.UAV 1(3) = deg2rad(360) - Position.UAV 1(3);
569 else
570 Position.UAV 1(3) = Position.UAV 1(3) + deg2rad(180);
571 end
572
573 else if Position.UAV 1(1) >= Map.xmax; %Reached Right
574 if rad2deg(Position.UAV 1(3)) <= 180
575 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1(3);
576 else
577 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1(3);
578 end
579
580 else if Position.UAV 1(2) <= Map.ymin; %Reached Bottom
581 if rad2deg(Position.UAV 1(3)) <= 180
582 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1
,! (3);
583 else
584 Position.UAV 1(3) = deg2rad(360) - Position.UAV 1
,! (3);
585 end
586 end
587
588 end
589
102
590 end
591 end
592 end
593
594 %% Drone 2
595 function UAV2(index)
596 global MySearch
597 global Genetics
598 global Position
599 Drone Number = 2;
600 %Initial UAV Position entered as cartesian coordinates (X, Y,
,! Orientation(Deg)
601
602 % UAV Genetics
603 Speed = Genetics.Speed(2); %m/s % this will be fast or slow
604 Altitude = Genetics.Altitude(2); %m need to make it hight or low
605 if Genetics.Search Type(2) == 1
606 Movement UAV 2(Speed, index);
607 end
608 Radius = SensorRadius(Altitude); % Runs a function that returns the
,! sensors search area
609 [xp, yp] = Circle(Radius);
610 Distance = UAV2Lost(Position.UAV 2); %returns the distance between the
,! UAV and lost object
611 Detected(Distance, Radius, Drone Number, Altitude, Speed);
612
613
614 set(MySearch.UAV2.Pos, 'xdata', Position.UAV 2(1), 'ydata', Position.
,! UAV 2(2));
103
615 set(MySearch.UAV2.Circle, 'xdata', Position.UAV 2(1) + xp, 'ydata',
,! Position.UAV 2(2) + yp);
616 end
617 function Movement UAV 2(Speed, index)
618 global LengthSearch
619 global Position
620 L = 1;
621 dt = 0.01;
622 Alpha = 0;
623
624 x2 = zeros(3, LengthSearch);
625 BouneOffEdges 2()
626 x2(:,index) = [Position.UAV 2(1); Position.UAV 2(2); Position.UAV 2(3)
,! ];
627
628 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index));
629 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index));
630 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha);
631
632 Position.UAV 2 = x2(:, index+1);
633 end
634 function BouneOffEdges 2()
635 global Position
636 global Map
637
638 if Position.UAV 2(1) <= Map.xmin % Reached Left
639 if rad2deg(Position.UAV 2(3)) <= 180
640 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2(3);
641 else
104
642 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2(3);
643 end
644
645 else if Position.UAV 2(2) >= Map.ymax; %Reached Top
646 if rad2deg(Position.UAV 2(3)) <= 180
647 Position.UAV 2(3) = deg2rad(360) - Position.UAV 2(3);
648 else
649 Position.UAV 2(3) = Position.UAV 2(3) + deg2rad(180);
650 end
651
652 else if Position.UAV 2(1) >= Map.xmax; %Reached Right
653 if rad2deg(Position.UAV 2(3)) <= 180
654 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2(3);
655 else
656 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2(3);
657 end
658
659 else if Position.UAV 2(2) <= Map.ymin; %Reached Bottom
660 if rad2deg(Position.UAV 2(3)) <= 180
661 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2
,! (3);
662 else
663 Position.UAV 2(3) = deg2rad(360) - Position.UAV 2
,! (3);
664 end
665 end
666
667 end
668
105
669 end
670 end
671 end
672
673 %% Drone 3
674 function UAV3(index)
675 global MySearch
676 global Genetics
677 global Position
678 Drone Number = 3;
679 %Initial UAV Position entered as cartesian coordinates (X, Y,
,! Orientation(Deg)
680
681 % UAV Genetics
682 Speed = Genetics.Speed(3); %m/s % this will be fast or slow
683 Altitude = Genetics.Altitude(3); %m need to make it hight or low
684 if Genetics.Search Type(3) == 1
685 Movement UAV 3(Speed, index);
686 end
687 Radius = SensorRadius(Altitude); % Runs a function that returns the
,! sensors search area
688 [xp, yp] = Circle(Radius);
689 Distance = UAV2Lost(Position.UAV 3); %returns the distance between the
,! UAV and lost object
690 Detected(Distance, Radius, Drone Number, Altitude, Speed);
691
692
693 set(MySearch.UAV3.Pos, 'xdata', Position.UAV 3(1), 'ydata', Position.
,! UAV 3(2));
106
694 set(MySearch.UAV3.Circle, 'xdata', Position.UAV 3(1) + xp, 'ydata',
,! Position.UAV 3(2) + yp);
695 end
696 function Movement UAV 3(Speed, index)
697 global LengthSearch
698 global Position
699 L = 1;
700 dt = 0.01;
701 Alpha = 0;
702
703 x2 = zeros(3, LengthSearch);
704 BouneOffEdges 3()
705 x2(:,index) = [Position.UAV 3(1); Position.UAV 3(2); Position.UAV 3(3)
,! ];
706
707 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index));
708 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index));
709 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha);
710
711 Position.UAV 3 = x2(:, index+1);
712 end
713 function BouneOffEdges 3()
714 global Position
715 global Map
716
717 if Position.UAV 3(1) <= Map.xmin % Reached Left
718 if rad2deg(Position.UAV 3(3)) <= 180
719 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3(3);
720 else
107
721 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3(3);
722 end
723
724 else if Position.UAV 3(2) >= Map.ymax; %Reached Top
725 if rad2deg(Position.UAV 3(3)) <= 180
726 Position.UAV 3(3) = deg2rad(360) - Position.UAV 3(3);
727 else
728 Position.UAV 3(3) = Position.UAV 3(3) + deg2rad(180);
729 end
730
731 else if Position.UAV 3(1) >= Map.xmax; %Reached Right
732 if rad2deg(Position.UAV 3(3)) <= 180
733 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3(3);
734 else
735 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3(3);
736 end
737
738 else if Position.UAV 3(2) <= Map.ymin; %Reached Bottom
739 if rad2deg(Position.UAV 3(3)) <= 180
740 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3
,! (3);
741 else
742 Position.UAV 3(3) = deg2rad(360) - Position.UAV 3
,! (3);
743 end
744 end
745
746 end
747
108
748 end
749 end
750 end
751
752 %% Drone 4
753 function UAV4(index)
754 global MySearch
755 global Genetics
756 global Position
757 Drone Number = 4;
758 %Initial UAV Position entered as cartesian coordinates (X, Y,
,! Orientation(Deg)
759
760 % UAV Genetics
761 Speed = Genetics.Speed(4); %m/s % this will be fast or slow
762 Altitude = Genetics.Altitude(4); %m need to make it hight or low
763 if Genetics.Search Type(4) == 1
764 Movement UAV 4(Speed, index);
765 end
766 Radius = SensorRadius(Altitude); % Runs a function that returns the
,! sensors search area
767 [xp, yp] = Circle(Radius);
768 Distance = UAV2Lost(Position.UAV 4); %returns the distance between the
,! UAV and lost object
769 Detected(Distance, Radius, Drone Number, Altitude, Speed);
770
771
772 set(MySearch.UAV4.Pos, 'xdata', Position.UAV 4(1), 'ydata', Position.
,! UAV 4(2));
109
773 set(MySearch.UAV4.Circle, 'xdata', Position.UAV 4(1) + xp, 'ydata',
,! Position.UAV 4(2) + yp);
774 end
775 function Movement UAV 4(Speed, index)
776 global LengthSearch
777 global Position
778 L = 1;
779 dt = 0.01;
780 Alpha = 0;
781
782 x2 = zeros(3, LengthSearch);
783 BouneOffEdges 4()
784 x2(:,index) = [Position.UAV 4(1); Position.UAV 4(2); Position.UAV 4(3)
,! ];
785
786 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index));
787 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index));
788 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha);
789
790 Position.UAV 4 = x2(:, index+1);
791 end
792 function BouneOffEdges 4()
793 global Position
794 global Map
795
796 if Position.UAV 4(1) <= Map.xmin % Reached Left
797 if rad2deg(Position.UAV 4(3)) <= 180
798 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4(3);
799 else
110
800 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4(3);
801 end
802
803 else if Position.UAV 4(2) >= Map.ymax; %Reached Top
804 if rad2deg(Position.UAV 4(3)) <= 180
805 Position.UAV 4(3) = deg2rad(360) - Position.UAV 4(3);
806 else
807 Position.UAV 4(3) = Position.UAV 4(3) + deg2rad(180);
808 end
809
810 else if Position.UAV 4(1) >= Map.xmax; %Reached Right
811 if rad2deg(Position.UAV 4(3)) <= 180
812 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4(3);
813 else
814 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4(3);
815 end
816
817 else if Position.UAV 4(2) <= Map.ymin; %Reached Bottom
818 if rad2deg(Position.UAV 4(3)) <= 180
819 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4
,! (3);
820 else
821 Position.UAV 4(3) = deg2rad(360) - Position.UAV 4
,! (3);
822 end
823 end
824
825 end
826
111
827 end
828 end
829 end
830
831 %% Drone 5
832 function UAV5(index)
833 global MySearch
834 global Genetics
835 global Position
836 Drone Number = 5;
837 %Initial UAV Position entered as cartesian coordinates (X, Y,
,! Orientation(Deg)
838
839 % UAV Genetics
840 Speed = Genetics.Speed(Drone Number); %m/s % this will be fast or slow
841 Altitude = Genetics.Altitude(Drone Number); %m need to make it hight
,! or low
842 if Genetics.Search Type(Drone Number) == 1
843 Movement UAV 5(Speed, index);
844 end
845 Radius = SensorRadius(Altitude); % Runs a function that returns the
,! sensors search area
846 [xp, yp] = Circle(Radius);
847 Distance = UAV2Lost(Position.UAV 5); %returns the distance between the
,! UAV and lost object
848 Detected(Distance, Radius, Drone Number, Altitude, Speed);
849
850
112
thesis
thesis
thesis
thesis
thesis
thesis
thesis
thesis
thesis
thesis
thesis
thesis

More Related Content

What's hot

Seismic Tomograhy for Concrete Investigation
Seismic Tomograhy for Concrete InvestigationSeismic Tomograhy for Concrete Investigation
Seismic Tomograhy for Concrete InvestigationAli Osman Öncel
 
Masters Thesis - Joshua Wilson
Masters Thesis - Joshua WilsonMasters Thesis - Joshua Wilson
Masters Thesis - Joshua WilsonJoshua Wilson
 
Final_project_watermarked
Final_project_watermarkedFinal_project_watermarked
Final_project_watermarkedNorbert Naskov
 
Virtual Environments as Driving Schools for Deep Learning Vision-Based Sensor...
Virtual Environments as Driving Schools for Deep Learning Vision-Based Sensor...Virtual Environments as Driving Schools for Deep Learning Vision-Based Sensor...
Virtual Environments as Driving Schools for Deep Learning Vision-Based Sensor...Artur Filipowicz
 
Etd 0712105 122345
Etd 0712105 122345Etd 0712105 122345
Etd 0712105 122345guest4a4122
 
Maxime Javaux - Automated spike analysis
Maxime Javaux - Automated spike analysisMaxime Javaux - Automated spike analysis
Maxime Javaux - Automated spike analysisMaxime Javaux
 
Dissertation - A Three Players Pursuit and Evasion Conflict
Dissertation - A Three Players Pursuit and Evasion ConflictDissertation - A Three Players Pursuit and Evasion Conflict
Dissertation - A Three Players Pursuit and Evasion ConflictSergey Rubinsky, Ph.D.
 
Etx 90 w-autostar man
Etx 90 w-autostar manEtx 90 w-autostar man
Etx 90 w-autostar manlarissasimao
 
Dragos Datcu_PhD_Thesis
Dragos Datcu_PhD_ThesisDragos Datcu_PhD_Thesis
Dragos Datcu_PhD_Thesisdragos80
 
Crypto notes
Crypto notesCrypto notes
Crypto notesvedshri
 

What's hot (17)

Seismic Tomograhy for Concrete Investigation
Seismic Tomograhy for Concrete InvestigationSeismic Tomograhy for Concrete Investigation
Seismic Tomograhy for Concrete Investigation
 
Masters Thesis - Joshua Wilson
Masters Thesis - Joshua WilsonMasters Thesis - Joshua Wilson
Masters Thesis - Joshua Wilson
 
BenThesis
BenThesisBenThesis
BenThesis
 
Earthing
Earthing Earthing
Earthing
 
Final_project_watermarked
Final_project_watermarkedFinal_project_watermarked
Final_project_watermarked
 
Virtual Environments as Driving Schools for Deep Learning Vision-Based Sensor...
Virtual Environments as Driving Schools for Deep Learning Vision-Based Sensor...Virtual Environments as Driving Schools for Deep Learning Vision-Based Sensor...
Virtual Environments as Driving Schools for Deep Learning Vision-Based Sensor...
 
Earth Resistance Testing
Earth Resistance TestingEarth Resistance Testing
Earth Resistance Testing
 
thesis
thesisthesis
thesis
 
Etd 0712105 122345
Etd 0712105 122345Etd 0712105 122345
Etd 0712105 122345
 
Phasor series operating_manual
Phasor series operating_manualPhasor series operating_manual
Phasor series operating_manual
 
feilner0201
feilner0201feilner0201
feilner0201
 
Jung.Rapport
Jung.RapportJung.Rapport
Jung.Rapport
 
Maxime Javaux - Automated spike analysis
Maxime Javaux - Automated spike analysisMaxime Javaux - Automated spike analysis
Maxime Javaux - Automated spike analysis
 
Dissertation - A Three Players Pursuit and Evasion Conflict
Dissertation - A Three Players Pursuit and Evasion ConflictDissertation - A Three Players Pursuit and Evasion Conflict
Dissertation - A Three Players Pursuit and Evasion Conflict
 
Etx 90 w-autostar man
Etx 90 w-autostar manEtx 90 w-autostar man
Etx 90 w-autostar man
 
Dragos Datcu_PhD_Thesis
Dragos Datcu_PhD_ThesisDragos Datcu_PhD_Thesis
Dragos Datcu_PhD_Thesis
 
Crypto notes
Crypto notesCrypto notes
Crypto notes
 

Similar to thesis

High Performance Traffic Sign Detection
High Performance Traffic Sign DetectionHigh Performance Traffic Sign Detection
High Performance Traffic Sign DetectionCraig Ferguson
 
Stochastic Processes and Simulations – A Machine Learning Perspective
Stochastic Processes and Simulations – A Machine Learning PerspectiveStochastic Processes and Simulations – A Machine Learning Perspective
Stochastic Processes and Simulations – A Machine Learning Perspectivee2wi67sy4816pahn
 
Optimization and prediction of a geofoam-filled trench in homogeneous and lay...
Optimization and prediction of a geofoam-filled trench in homogeneous and lay...Optimization and prediction of a geofoam-filled trench in homogeneous and lay...
Optimization and prediction of a geofoam-filled trench in homogeneous and lay...Mehran Naghizadeh
 
Bachelor Thesis .pdf (2010)
Bachelor Thesis .pdf (2010)Bachelor Thesis .pdf (2010)
Bachelor Thesis .pdf (2010)Dimitar Dimitrov
 
Ric walter (auth.) numerical methods and optimization a consumer guide-sprin...
Ric walter (auth.) numerical methods and optimization  a consumer guide-sprin...Ric walter (auth.) numerical methods and optimization  a consumer guide-sprin...
Ric walter (auth.) numerical methods and optimization a consumer guide-sprin...valentincivil
 
Lecture notes on planetary sciences and orbit determination
Lecture notes on planetary sciences and orbit determinationLecture notes on planetary sciences and orbit determination
Lecture notes on planetary sciences and orbit determinationErnst Schrama
 
Team Omni L2 Requirements Revised
Team Omni L2 Requirements RevisedTeam Omni L2 Requirements Revised
Team Omni L2 Requirements RevisedAndrew Daws
 
Towards Digital Twin of a Flexible manufacturing system with AGV
Towards Digital Twin of a Flexible manufacturing system with AGV Towards Digital Twin of a Flexible manufacturing system with AGV
Towards Digital Twin of a Flexible manufacturing system with AGV YasmineBelHajsalah
 
Efficient algorithms for sorting and synchronization
Efficient algorithms for sorting and synchronizationEfficient algorithms for sorting and synchronization
Efficient algorithms for sorting and synchronizationrmvvr143
 
Efficient algorithms for sorting and synchronization
Efficient algorithms for sorting and synchronizationEfficient algorithms for sorting and synchronization
Efficient algorithms for sorting and synchronizationrmvvr143
 
Fulltext02
Fulltext02Fulltext02
Fulltext02Al Mtdrs
 
TFG_Cristobal_Cuevas_Garcia_2018.pdf
TFG_Cristobal_Cuevas_Garcia_2018.pdfTFG_Cristobal_Cuevas_Garcia_2018.pdf
TFG_Cristobal_Cuevas_Garcia_2018.pdfGerard Labernia
 

Similar to thesis (20)

High Performance Traffic Sign Detection
High Performance Traffic Sign DetectionHigh Performance Traffic Sign Detection
High Performance Traffic Sign Detection
 
MS_Thesis
MS_ThesisMS_Thesis
MS_Thesis
 
Stochastic Processes and Simulations – A Machine Learning Perspective
Stochastic Processes and Simulations – A Machine Learning PerspectiveStochastic Processes and Simulations – A Machine Learning Perspective
Stochastic Processes and Simulations – A Machine Learning Perspective
 
Optimization and prediction of a geofoam-filled trench in homogeneous and lay...
Optimization and prediction of a geofoam-filled trench in homogeneous and lay...Optimization and prediction of a geofoam-filled trench in homogeneous and lay...
Optimization and prediction of a geofoam-filled trench in homogeneous and lay...
 
Jmetal4.5.user manual
Jmetal4.5.user manualJmetal4.5.user manual
Jmetal4.5.user manual
 
z_remy_spaan
z_remy_spaanz_remy_spaan
z_remy_spaan
 
Sunidhi_MSc_F2015
Sunidhi_MSc_F2015Sunidhi_MSc_F2015
Sunidhi_MSc_F2015
 
Bachelor Thesis .pdf (2010)
Bachelor Thesis .pdf (2010)Bachelor Thesis .pdf (2010)
Bachelor Thesis .pdf (2010)
 
Ric walter (auth.) numerical methods and optimization a consumer guide-sprin...
Ric walter (auth.) numerical methods and optimization  a consumer guide-sprin...Ric walter (auth.) numerical methods and optimization  a consumer guide-sprin...
Ric walter (auth.) numerical methods and optimization a consumer guide-sprin...
 
Lecture notes on planetary sciences and orbit determination
Lecture notes on planetary sciences and orbit determinationLecture notes on planetary sciences and orbit determination
Lecture notes on planetary sciences and orbit determination
 
Team Omni L2 Requirements Revised
Team Omni L2 Requirements RevisedTeam Omni L2 Requirements Revised
Team Omni L2 Requirements Revised
 
Towards Digital Twin of a Flexible manufacturing system with AGV
Towards Digital Twin of a Flexible manufacturing system with AGV Towards Digital Twin of a Flexible manufacturing system with AGV
Towards Digital Twin of a Flexible manufacturing system with AGV
 
Thats How We C
Thats How We CThats How We C
Thats How We C
 
Efficient algorithms for sorting and synchronization
Efficient algorithms for sorting and synchronizationEfficient algorithms for sorting and synchronization
Efficient algorithms for sorting and synchronization
 
Efficient algorithms for sorting and synchronization
Efficient algorithms for sorting and synchronizationEfficient algorithms for sorting and synchronization
Efficient algorithms for sorting and synchronization
 
Fulltext02
Fulltext02Fulltext02
Fulltext02
 
TFG_Cristobal_Cuevas_Garcia_2018.pdf
TFG_Cristobal_Cuevas_Garcia_2018.pdfTFG_Cristobal_Cuevas_Garcia_2018.pdf
TFG_Cristobal_Cuevas_Garcia_2018.pdf
 
Thesis
ThesisThesis
Thesis
 
Ns doc
Ns docNs doc
Ns doc
 
10.1.1.652.4894
10.1.1.652.489410.1.1.652.4894
10.1.1.652.4894
 

thesis

  • 1. SCHOOL OF MECHANICAL AND MANUFACTURING ENGINEERING Swarm learning techniques by Alexander Champion de Crespigny Bachelor of Engineering (Mechatronic Engineering) Submitted: June 1, 2015 Student ID: z3253261 Supervisor: John Page
  • 2. Abstract Current swarm systems require a predefined logic to be installed in the swarm. This logic is required to be changed for di↵erent locations and or situations. If swarm entities were to learn from previous experiences and from other entities within the swarm through sensor fusion then this external input would not be required. The swarm would adopt the most e cient technique over time through a process of evolution. By carrying out a process of evolution the system can dynamically change to its environment and improve. The concept of keeping good genes and expelling the weaker will ensures the success and or survival of the swarm. New genes need to be added to ensure evolution progresses and change can occur.
  • 3. Acknowledgements I would like to thank many people for all their support and assistance during my thesis research. Firstly I thank John Page who accepted me as his thesis student and guided me through the process. His guidance was pivotal in shaping my thesis topic. I thank Dr Suzy Oglesby for listening and helping me sound out my ideas on evolution, without her insight on the human brain and physiology I would not have arrived at the same conclusions. I thank my father Dr. Richard Champion de Crespigny for helping me sound out my ideas and coming to conclusions. His insights in to how the human brain work and how it has evolved over time have was fundamental to my understanding of evolution. Thank you to my family who was supported me through the stresses of the project.
  • 4. I, the undersigned, declare the following submission to be entirely of my own undertaking to the best of my knowledge, except where specific acknowledgement is made. Alexander Champion de Crespigny z3253261 June 2015 2
  • 5. Abbreviations BE Bachelor of Engineering EE&T School of Electrical Engineering and Telecommunication LATEX A document preparation computer program GA Genetic Algorithm NATO North Atlantic Treaty Organisation PSO Partical Swarm Optimisation UAV Unmanned Arial Vehicle ATC Air Tra c Control FL Flight Level 3
  • 6. Nomenclature d distance (km) g gravity (9.81 m/s) h height (m) hc UAV ceiling height (m) Tr turn rate (deg/s) s time (s) V velocity (m/s) Vg ground Speed (m/s) Vas air speed (m/s) Vmg UAV maximum ground speed (m/s Sas sensor accuracy speed (%) Sav sensor accuracy vertical (%) OA overall sensor accuracy (%) RA random chance the sensor detects the lost agent 4
  • 7. Rand1 random number generated from 0 to 1 ✓ angle (deg) 5
  • 8. Glossary Bingo Fuel An allocated amount of fuel for an aircraft that allows it to return to its destination without running out of fuel. Harem A group of same gendered animals sharing a single mate of the opposite sex. Link 16 Link 16 is a jam resistant high speed data link that can communicate between air, land and sea resources. It is utilised by the United States of America and it’s NATO allies. Sensor Fusion The accumulation of data received from an array of several sensors. The end result of the combined data is superior than a single sensor. Chinese Whispers When information is passed on in turn by a number of people, often becoming distorted in the process [8]. Flight Level An aviation term used to refer to an aircrafts altitude. It is usually referred to in feet however some jurisdictions enforce local ATC and flights to use meters. To limit time spoken over the radio the last two digits are removed for simplicity. For example 20,000 ft would be FL (Flight Level) 200ft. 6
  • 9. Contents 1 Background 14 2 Literature Review 17 2.1 Biomimicry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.2 Evolution and breeding techniques . . . . . . . . . . . . . . . . . . . 19 2.3 Fitness proportionate selection . . . . . . . . . . . . . . . . . . . . . . 20 2.4 Genetic algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.5 Particle Swarm Optimisation . . . . . . . . . . . . . . . . . . . . . . . 21 2.6 Wake Vortex Surfing . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.7 Minimum Breeding Age . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.8 Delaying Sexual Maturity . . . . . . . . . . . . . . . . . . . . . . . . 23 2.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3 Defining the Model 25 3.1 Computational Software . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.2 Search Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.3 Drones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.4 Lost Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.4.1 Random Lost Agent . . . . . . . . . . . . . . . . . . . . . . . 30 7
  • 10. 3.4.2 Semi Random Lost Agent . . . . . . . . . . . . . . . . . . . . 30 3.5 Drone Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.6 Drone Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.6.1 Sensor Speed Accuracy . . . . . . . . . . . . . . . . . . . . . . 32 3.6.2 Altitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.7 Overall Sensor Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . 33 3.8 Start Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3.8.1 Original start position . . . . . . . . . . . . . . . . . . . . . . 34 3.8.2 Continued moving . . . . . . . . . . . . . . . . . . . . . . . . 35 3.9 Evolution of the simulation . . . . . . . . . . . . . . . . . . . . . . . . 35 3.9.1 Breeding (Evolutions) . . . . . . . . . . . . . . . . . . . . . . 37 3.9.2 Sexual Maturity (Breeding age) . . . . . . . . . . . . . . . . . 38 3.9.3 Time to find lost object (Time Out) . . . . . . . . . . . . . . 38 3.9.4 Mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3.9.5 Example of a complete evolution cycle . . . . . . . . . . . . . 40 3.9.6 Turning the UAVs . . . . . . . . . . . . . . . . . . . . . . . . 43 4 Running the Model 44 4.1 Locate the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 4.2 Open and run with Matlab . . . . . . . . . . . . . . . . . . . . . . . . 45 4.2.1 Simulation Status . . . . . . . . . . . . . . . . . . . . . . . . . 47 4.3 Simulation Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 5 Future Work 50 5.1 Homogeneous Characteristics . . . . . . . . . . . . . . . . . . . . . . 50 5.1.1 Wake vortex surfing . . . . . . . . . . . . . . . . . . . . . . . . 50 8
  • 11. 5.1.2 Manoeuvring Speed . . . . . . . . . . . . . . . . . . . . . . . . 51 5.1.3 Flight pattern optimisation . . . . . . . . . . . . . . . . . . . 51 5.1.4 Distance between agents . . . . . . . . . . . . . . . . . . . . . 52 5.1.5 Breeding techniques . . . . . . . . . . . . . . . . . . . . . . . 52 5.2 Non Homogenous Physical Characteristics . . . . . . . . . . . . . . . 52 5.2.1 Drifting Ship . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 5.2.2 Impeding factors . . . . . . . . . . . . . . . . . . . . . . . . . 53 6 Real World Applications 54 6.1 New and Changing areas of interest . . . . . . . . . . . . . . . . . . . 54 6.2 Suspected Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 7 Results and Discussion 56 7.1 Resetting the Start location . . . . . . . . . . . . . . . . . . . . . . . 56 7.1.1 Random lost agent evolution . . . . . . . . . . . . . . . . . . . 56 7.1.2 Adding a disturbance . . . . . . . . . . . . . . . . . . . . . . . 60 7.2 Continuing on path . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 7.2.1 Random lost agent evolution . . . . . . . . . . . . . . . . . . . 62 7.2.2 Adding a disturbance . . . . . . . . . . . . . . . . . . . . . . . 65 7.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 7.3.1 Sexual maturity age . . . . . . . . . . . . . . . . . . . . . . . 68 7.3.2 Randomness and Repeatability . . . . . . . . . . . . . . . . . 68 7.3.3 Mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 7.3.4 Starting Position . . . . . . . . . . . . . . . . . . . . . . . . . 69 7.3.5 Semi Random Disturbance Fitting . . . . . . . . . . . . . . . 69 7.3.6 Unexplainable spike increase in search time . . . . . . . . . . . 69 9
  • 12. 8 Conclusion 71 9 Personal Remarks 73 9.1 The idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 9.2 Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . 74 9.2.1 AnyLogic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 9.2.2 Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Bibliography 77 Appendix 1 79 10
  • 13. List of Figures 2.1 Animals swarming . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.1 Search Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2 Drone Process model . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.3 A UAV search drone . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.4 Four UAV search drones . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.5 Random Lost Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.6 Semi Random Lost Agent . . . . . . . . . . . . . . . . . . . . . . . . 31 3.7 Sensor range with varying altitude [18] . . . . . . . . . . . . . . . . . 33 3.8 Resetting of drone location from finding the lost agent . . . . . . . . 34 3.9 Continuation of drone direction before and after detection of lost object 35 3.10 Pseudo Program Structure . . . . . . . . . . . . . . . . . . . . . . . . 37 4.1 Simulation program m-file . . . . . . . . . . . . . . . . . . . . . . . . 44 4.2 Opening Simulation program m-file . . . . . . . . . . . . . . . . . . . 45 4.3 Selecting simulation program m-file . . . . . . . . . . . . . . . . . . . 46 4.4 Run the Matlab program . . . . . . . . . . . . . . . . . . . . . . . . . 46 4.5 Change Folder Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 4.6 Input Evolution Variables . . . . . . . . . . . . . . . . . . . . . . . . 47 11
  • 14. 4.7 Status of the simulation . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.8 Simulation Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 5.1 Wake Vortex Surfing [1] . . . . . . . . . . . . . . . . . . . . . . . . . 51 7.1 Average time to find lost agent without a disturbance . . . . . . . . . 57 7.2 Linear line of best fit applied to the time to find the lost agent without a disturbance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 7.3 Average time to find lost agent with a disturbance added at evolution stage 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 7.4 Average time to find lost agent without a disturbance and continuing on the UAVs path without resetting its position . . . . . . . . . . . . 63 7.5 Linear line of best fit applied to the time to find the lost agent without a disturbance and continuing on the UAVs path with out resetting its position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 7.6 Average time to find lost agent with a disturbance and continuing on the UAVs path without resetting its position . . . . . . . . . . . . . . 66 7.7 Linear line of best fit applied to the time to find the lost agent with a disturbance and continuing on the UAVs path with out resetting its position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 7.8 Evolution Cycles: 10, Sexual Maturity age: 15, Timeout: 100,000 . . 70 12
  • 15. List of Tables 3.1 Process model values . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.2 Drone Characteristics and values . . . . . . . . . . . . . . . . . . . . 31 3.3 Drone Set Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 3.4 Example of Mutations . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.5 Initialised UAV characteristic values . . . . . . . . . . . . . . . . . . . 41 3.6 Initialised UAV characteristic values, * denotes the values changed due to mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.7 Initialised UAV characteristic values, * denotes the values changed due to mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 7.1 Results UAVs: 8, no disturbance . . . . . . . . . . . . . . . . . . . . 57 7.2 Results UAVs: 8, with sine wave disturbance . . . . . . . . . . . . . . 60 7.3 Results UAVs: 8, no disturbance . . . . . . . . . . . . . . . . . . . . 62 7.4 Results UAVs: 8, with wine wave disturbance . . . . . . . . . . . . . 65 13
  • 16. Chapter 1 Background Search and rescue is a high stake, high risk area of work for governments and organ- isations. For the people who are lost it may be a life or death situation. Developing new and improved strategies will ultimately decrease the risk to search operators and increase the chance of survival for displaced persons. Search and rescue is a very expensive activity, the main cost incurred in these operations is training, fuel, salaries and equipment. If training and salaries could be reduced then the cost involved would decrease dramatically. An example of an ongoing and very expensive search mission is the search for the wreckage of the Malaysian Airlines flight MH370 that disappeared en route from Kuala Lumpur to Beijing in early 2014. The aircraft is believed to have ditched into the Indian Ocean o↵ the western coast of Australia. In order to just begin the search aircraft fly for several hours to just reach the search zone, even flying from the closest airport in Australia. There are three main ways in which the wreckage was searched for. 14
  • 17. 1. Airborne surveillance Aircraft limitations meant that the aircraft could not remain in the area long be- fore it reached bingo fuel. By the time the crew reached the search area they were already fatigued. With the limited time they had, they searched the ocean with on- board sensors and eye-sight. This process is extremely costly and ine↵ective when the search area is remote to any airfields. 2. Seaborne surveillance Ships were used to search the area using a combination of surface radar, eyesight and sonar devices. The distance a person can see to the horizon is limited by the curvature of the earth. The distance to the horizon can be roughly calculated by equation 1.1. The greater the height above the sea level the further you can see, however the ability to see detail decreases with distance. Searching onboard a ship is ine↵ective as the searchers do not have enough height above sea level to cover a large search area. d = 3.57 ⇥ p h (1.1) 3. Low Earth Orbit surveillance Satellites were used to view the ocean surface. This however was limited by camera resolution as it was necessary to look for very small objects such as seat cushions or life jackets which are very hard to identify from space. Atmospheric interference also interfered as clouds blocked visual observation. Each image also had to be processed either by a person directly viewing or a computer program that was programmed to identify wreckage which may not accurately detect the wreckage. 15
  • 18. Each of the three search methods above have positive and negative characteristics however there are ways that the benefits from each aspect can be combined to create a better mechanism for search. Currently search and rescue operations are undertaken by government and civil- ian contractors. Many of these operators utilise unmanned surveillance options in the form of satellites and drones however they are all controlled externally by a human that is located somewhere around the world who manually has to input search parameters. These search and rescue techniques have been improved by hu- man reasoning and research however they are slow to adapt and often generic to all situations. This research thesis has developed a model to simulate a swarm of UAVs that are given a search area and then the swarm will deduce the best search pattern and strategy for recovery. As computers are able to process millions of cal- culations per second they can run algorithms to deduce the most e cient search method though a process of evolution. Humans do not have the ability to process this amount of data quickly as our brain cannot compare to the pure mathematical computation power of todays computer processors. There is no way to guarantee that the lost object will be found however the swarm of UAVs will adapt to the scenario and deduce the best characteristics that a UAV should possess to search the area. 16
  • 19. Chapter 2 Literature Review Swam intelligence systems focus the ability of a set of agents which will be referred to as UAVs to learn and adapt to its surroundings. To start my research I began with a generic Google search and read Wikipedia articles. Whilst Wikipedia is unreliable it gave me academic references to start with, I was then able to follow the references and find creditable academic articles which I then based my research for this thesis on. 2.1 Biomimicry Swarms are used extensively in nature, this can be easily seen in the way a flock of birds fly or a school of fish swim as seen in figure 2.1. Early concepts of modelling a swarm were based around the principles that each agent moved in the same direction as its neighbours, remained close to its neighbours and avoided colliding with its neighbour. This model is called the Boids computer program which was created by Craig Reynolds in 1986 [20]. Swarms have a very useful application in modern times. Animals in nature are 17
  • 20. (a) Birds flying in a V-Formation [10] (b) Fish Swarming [17] Figure 2.1: Animals swarming able to detect their surroundings and adapt to their environment, this adaptation has been ongoing for billions of years. If a man made swarm of UAVs could detect its surrounding environment it could adapt to the best way to search the area and it would ultimately be superior to human search tactics [21]. Insects are a excellent example of swarms at work, ant colonies use swarm organ- isational movement. When an ant walks it leaves a trail of pheromones like a trail of breadcrumbs other ants are draws to strong concentrations of these pheromones. When a food source is located the finding ant takes a bit of this food back to the ant colony and then returns for more food thus increasing the chemical concentration of the pheromone trail. It is likely that other ants will stumble across the same food source and they will also add to the concentration though the process of returning back to the ant colony. Other ants are then drawn to the concentrated pheromone trail and acts as a path for ants to get to food [5]. The ants model is a very basic simulation to run but it is an e↵ective way to search an area. 18
  • 21. 2.2 Evolution and breeding techniques Evolution is a continuing process that has been developing over millions of years, the current theory is that the strongest genes survive and are passed down to their children [6]. There are two types of breeding techniques that are seen in nature. The first is the group style where each agent has the ability to breed with any other agent in the swarm or group this allows for a mixing of all gene types. This mixing of all genes leads to characteristics that are suited for particular environments as mutations occur which are better suited for the environment. This process of mating promotes a large range of genetic diversity. Group breeding is well suited to swarms that are subjected to changing environments as there is a large range of genetic diversity which enables the species to adapt quickly. The second type of breeding is called prime breeding and is where a dominate male breeds with a harem of females. An example of prime breeding in nature can be seen in elephant seal colonies where a bull male controls a harem of females and he alone mates with them [19]. Prime breeding is not relegated only to elephant seals, it has been observed in animals such as grouse, peafowl, lions and mountain gorillas. It is also worth noting that in some animal species a dominate female mates with a harem of males. This can be observed in birds like the jacana, and phalarope, it has also been observed with the spotted hyena. Fighting is common between the sex that is vying to mate with the harem. The dominate breeder will maintain security over their harem and will fight o↵ any intruders or sexual competition. Sneaky males or females will try to sneak in and mate with the harem, this provides a very small amount of genetic diversity. Previous research on this topic has shown that this style of mating is not well suited to changing environments. If the environment 19
  • 22. changes too quickly the species may not be able to adapt to changes quickly enough and the population may become extinct. 2.3 Fitness proportionate selection Mathematical models are used to emulate real world evolutionary behaviour. The fitness proportionate selection model [16] can be analogised as a roulette wheel in a casino. Each section on the wheel is a type of gene. A stronger gene is given a higher fitness value and a weaker gene is given a smaller value. A larger fitness value correlates to a larger area on the roulette wheel and thus a higher chance that the ball will land there. With a normal distribution the genes that are strongest (large fitness value) will become dominate and still allow for a small amount of weaker genes to be added and cause mutations. This model emulates real world breeding well. 2.4 Genetic algorithm The Genetic Algorithm (GA) was developed by John Holland [14]. The GA is based on Charles Darwin’s theory of survival of the fittest. The model selects mating pairs based on their ability to adapt to their environment. The genes from the strongest mates are passed on to their children [7]. These children are then mixed into the population and the process is repeated. As mixing occurs a fitness forms and the strongest genes are passed down to each generation until a optimised solution is found. 20
  • 23. 2.5 Particle Swarm Optimisation Particle Swarm Optimisation (PSO) was developed by Kennedy and Eberhart [9]. PSO was developed by monitoring how swarms of ants, schools of fish and herds of animals were able to find water and food sources in areas they had never been to before, whilst avoiding dangerous predators [7]. This communication is made possible by each animal communicating to its neighbour and the flow on e↵ect just like Chinese whispers. By understanding how this information is transferred it can be adapted to a swarm of UAVs where the information discovered at one side of the swarm can be passed back to the rest of the swarm so a decision can be made on how to proceed. 2.6 Wake Vortex Surfing Birds have been saving energy by flying in V formations for millions of years. Aircraft are also able to benefit from the updraft of the wake vortex generated by the leading aircraft. Recent US Airforce trials have seen a decrease of up to 20% in fuel flow when surfing the wake vortex of a leading aircraft [4]. To take advantage of this e ciency aircraft must fly in tight formations, the benefits are reduced fuel consumption which leads to less fuel needed for a given leg or an increase in range. Significant risks are involved as wake vortex turbulence is very dangerous. Several fatal incidents have occurred when an aircraft passed into a wake vortex. If the trailing aircraft is not able to position itself correctly the forces from the vortex could tear the aircraft apart. The formation requires the aircraft to fly in very close proximity and the risk of a mid air collision is greatly increased. However with advanced autopilots and 21
  • 24. Link-16 communication systems the aircraft are able to safely position themselves in the correct part of the wake vortex and avoid collisions. 2.7 Minimum Breeding Age Evolution by definition is constantly changing, researchers have applied simulated computer models to mimic natures evolution. An interesting aspect of evolution is the need for animals to have a minimum breeding age. When humans reach their minimum breeding age they undergo a physical, psychological and physiological change. This change is so significant that human cultures have created a name for the change called ’puberty’. In boys changes are noticeable in the their voice, body hair, genitals and breasts [11]. In girls changes are noticed in their breasts, widening of the hips, body hair, genitals and menstruation [12]. The changes an animal undergoes during sexual maturity are vital to successful evolution. In order to reproduce animals must reach an age of sexual maturity, this time gap from birth to sexual maturity is key to the success of evolution. This initial time gap allows for each individual to prove that their genetics are worthy to be passed on to another generation. If the individual is born with weak genes then they will most likely die within the time before they reach the age of sexual maturity. The timing of the sexual maturity is vitally important, if the age is set to low weaker animals are able to spread their weaker genes, this will cause a weaker progeny to be produced and an ever increasing spiral of bad genes may occur. However if the timing is left to long the same e↵ect occurs where the species dies out due to weaker genes being passed on [3]. There is a convergence in age at which a species sexually matures and the expected life span of its progeny [3]. This process has been evolved 22
  • 25. over time to the ages of 18-20 years old for human beings [15]. 2.8 Delaying Sexual Maturity There is a correlation between the age of sexual maturity and a the expected life span of that species. Homo Sapiens (humans) are closely related to hominoids, these animals can be seen as steps in our own human evolution over time. Gorillas sexually mature at an age of 8 - 9 years old and they have a average life expectancy of around 40 years old [15]. Humans reach sexual maturity at an age of 18-20 years old and have a average life expectancy of 80 years old [15]. A trend can be observed by going back through our ancestors and examining the age at which they reach sexual maturity and their expected life span. Earlier on our ancestors reached sexual maturity at a younger age and had shorter life expectancies. The age at which we reach sexual maturity over millions of years has increased. This age in increased sexual maturity also correlates to a longer average expected life span [15]. An interesting comparison would be to compare the humans sexual maturity age with those of pygmy humans who only have life expectancies of 20-24 years old. I was not able to find any data on this and I expect that they are an exception to the above theory. Evolution may make them extinct over time as they do not have the correct ratio of reproductive age to life expectancy. Therefore it can be observed that as a species successfully evolves its life span increases and along with this its sexual maturity age also increases. 23
  • 26. 2.9 Summary The basis of this research is to reduce the human input needed in robotic swarm tasks such as search and rescue operations. The research is poised to develop smart breeding algorithms for swarms to come up with strategies that are better than cur- rent human methods. Robots have the ability to process information and therefore can compute more permutations per second. The end result is to come up with lean methods in a very fast time drawing on the swarms previous experiences and taking advantage of high speed computations. 24
  • 27. Chapter 3 Defining the Model 3.1 Computational Software Matlab was used to program the evolution simulation, this choice was made as Matlab provided the most diversity. Anylogic was explored however the use of a GUI to program the interface presented limitations, this was a hard decision as Anylogic is design made agent based modelling software. 3.2 Search Area The search area was designed to be a very simple 3D cartesian layout as seen in figure 3.1 25
  • 28. Figure 3.1: Search Area 3.3 Drones Each UAV was modelled as a di↵erent entity. Each drone was isolated and there was no communication between them except when breeding. Each drones motion was governed by a process model. This model was taken from the motion of a car see the equation 3.3 [13]. This model of movement allowed for a very simple two dimensional cartesian movement based upon a changing speed and steering angle. The values used in the simulation can be seen in table 3.1. Altitude is set as a constant in each simulation and there are no height changes within one evolution cycle. 26
  • 29. ˙x (t) = v (t) · cos (✓ (t)) ˙y (t) = v (t) · sin (✓ (t)) ˙✓ (t) = tan (↵ (t)) · v (t) L Figure 3.2: Drone Process model Variable Value Unit Description v Evolves m/s Speed ✓ Evolves deg Current Heading t 0.01 sec Time Step ↵ 0 deg Desired Heading L 1 m m Vehicle Length Table 3.1: Process model values The drone is represented in a Matlab figure plot seen in figure 3.3. The drone is represented by a coloured asterix inside a green circle. The green circle represents the perimeter of the sensor search area cone projected onto the ground. Anything within this area is able to be detected by the drone. Figure 3.4 shows four drones stationary in the search area. 27
  • 30. Figure 3.3: A UAV search drone 28
  • 31. Figure 3.4: Four UAV search drones 3.4 Lost Agent A lost agent was placed within the search area, this random agent was placed in two poses the first was a completely random pose and the second was a semi random pose. It is denoted in the model by a small red diamond. This can be seen in figures 3.5 for the completely random lost agent and 3.6. for the semi random lost agent. 29
  • 32. 3.4.1 Random Lost Agent The random lost agent is placed at a random position in the search area, this can ben seen in figure 3.5. The random values were generated by a random number generator with limits of the boundaries of the search area. Figure 3.5: Random Lost Agent 3.4.2 Semi Random Lost Agent The semi random lost agent was placed in a semi random position. A sine wave was generated with an amplitude that matched the height of the search area. The lost agent was then randomly placed at a point along that curve which can be seen in figure 3.6. This curve could be any shape however a sine wave is simple and very easy to implement. The random number was generated by a random number generator between the ranges of search area x-axis. 30
  • 33. Figure 3.6: Semi Random Lost Agent 3.5 Drone Characteristics Each drone had unique characteristics, these characteristics can be referred to as genes in evolutionary terms, the range of characteristics that the UAVs could adopt are specified in table 3.2. A speed of 50,000 m/s is not a realistic speed this speed was allowed in order to allow for a faster simulation. A scaling factor needs to be applied. Allowable range values Characteristic Minimum Maximum Speed 0 m/s 50,000* m/s Altitutude 0 m 2,000 m Initial Angle -180 deg 180 deg Table 3.2: Drone Characteristics and values 31
  • 34. 3.6 Drone Sensors The simulation changes three behavioural characteristics in the swarm of drones. The drones are homogeneous in nature and only the software is able to be changed section 5.2 delves in to non homogenous physical variations in the drones. 3.6.1 Sensor Speed Accuracy In reality sensors do not have 100% accuracy. When moving slower the sensor has more time to analyse the area being searched than if it was flying faster. In the simulation the sensor accuracy varies according the equation 3.1. For simplicity the UAV will have a maximum ground speed of 50000 m/s (This value is allowed to be very large to speed up the simulation, it also has a very low chance of detecting the lost agent). Sas = 1 Vg Vmg (3.1) 3.6.2 Altitude The higher the UAV flies the more area the sensor is able to cover due to the cone e↵ect shown in figure 3.7. This however decreases the accuracy of detection. The sensor accuracy will vary depending on its altitude which is shown in equation 3.2. The UAV will have a service ceiling of 2,000m. Sav = 1 h Hc (3.2) 32
  • 35. Figure 3.7: Sensor range with varying altitude [18] 3.7 Overall Sensor Accuracy The total accuracy of the sensor is calculated in equation 3.3. OA = Sav ⇥ Sas (3.3) As in reality the chance of detecting an object is not guaranteed, a random number generator is used to determine if the sensor is able to detect the lost agent as seen in equation 3.4. RA = OA + Rand1 (3.4) 3.8 Start Position The simulation had two options. Once the UAV had detected the lost agent the UAVs could return to their original starting positions or they could continue moving 33
  • 36. along their path. 3.8.1 Original start position When the UAV detects the lost agent they reset to their original start location. This can be seen in figure 3.8. (a) Before Find of Lost agent (b) After find of lost agent Figure 3.8: Resetting of drone location from finding the lost agent 34
  • 37. 3.8.2 Continued moving When the UAV detects the lost agent it continues on its path that it was originally on. When the system undergoes evolution the UAVs return to their starting position this is shown in figure 3.9. Figure 3.9: Continuation of drone direction before and after detection of lost object 3.9 Evolution of the simulation The simulation starts with each drone set with an initial Speed, Altitude and Ini- tial angle the set points that are used in the simulation can be seen in table 3.3. Random denotes that the point is set from a random number generator that ranges between the maximum and minimum of variable which can be seen in table 3.2. These variables are designed to change throughout the simulation as it evolves. 35
  • 38. Initial Characteristic Values Drone Speed Altitude Angle x-pos y-pos 1 Random Random Random -4000 79,999 2 Random Random Random -3000 79,999 3 Random Random Random -2000 79,999 4 Random Random Random -1000 79,999 5 Random Random Random 1000 79,999 6 Random Random Random 2000 79,999 7 Random Random Random 3000 79,999 8 Random Random Random 4000 79,999 Table 3.3: Drone Set Points The simulation is broken into three stages, Evolutions, Sexual Maturity and Time out. A graphical representation of the looping code can be seen in figure 3.10 36
  • 39. Figure 3.10: Pseudo Program Structure 3.9.1 Breeding (Evolutions) The term evolution that is referred to in this thesis is similar to the natural process of prime breeding. In the simulation the number of times the system evolves means how many times the ’alpha’ UAV mates with the other drones and passes down its characteristics. 37
  • 40. 3.9.2 Sexual Maturity (Breeding age) Sexual maturity denotes the number of times the system tries to find the lost agent (The number of times the lost agent is found). The drone characteristics do not evolve during this time. There is a strong link with the sexual maturity age and the ability for the system to successfully evolve. For example if the sexual maturity is set to 10 cycles the system will try to find the object 10 times. If the system finds the lost agent it will reset and go on to cycle 2 of 10, then 3 of 10, etc... When this cycle runs 10 times the UAV that has found the lost object the most amount of times is designated the ’alpha’ UAV. Each of the other remaining drones will then choose to take one of the alpha drones characteristics. This selection of a random characteristic is done randomly so a drone will only take one of the characteristics shown in table 3.2. 3.9.3 Time to find lost object (Time Out) The length of one iteration of the maturity cycle is limited. This limit is to ensure that if none of the UAVs detect the lost agent they do not get stuck in an infinite loop and never evolve. The limit was set to 100,000 iterations. An example of when the system could get stuck in an infinite loop and never detect the lost agent is if all the drones altitude or speed were set to zero, another circumstance where this could occur is if the search angeles were set to be perpendicular to the x or y axis. The Drone usually finds the lost agent within 10,000 iterations. The longest iteration time until the lost object was detected that I observed was 45,000 iterations. The time out function is a safety measure to ensure that change occurs mutations should always get the system out of an infinite loop. 38
  • 41. 3.9.4 Mutations As stated in subsection 3.9.3 the drones can be caught in a state where they do not detect the lost agent. If the system is allowed to continue in this manner the system will not ever evolve as no one of them detects the lost object and thus none of them would pass on genes that will lead to a successful find of the lost agent. In nature these groups of animals would go extinct. Thus it is very important to ensure that mutations occur within the drones characteristics. This is done by adding random values for each characteristic during each time the system evolves. Mutation was was achieved by by selecting three random numbers within the range of 1 to the number of drones. For instance if there were 15 drones a random number was generated between 1 and 15. Mutation Example: The simulation comprises of 15 drones. Each drone is assigned random characteris- tics and has gone through one set of evolution. The other 14 UAVs have taken one of the alpha drones strongest characteristics at random. For the mutation to occur a set of three random numbers are generated in the range of 1 through to 15. The random numbers generated are 4, 11 and 9. These numbers correspond to UAVs 4, 11 and 9. • Drone 4 will assign a random angle to its angle gene. 39
  • 42. • Drone 11 will assign a random speed to its speed gene. • Drone 9 will take assign a random altitude to its altitude gene. This example of the mutations being added to the drones can be seen in table 3.4 All the ’mutated’ genes that have been entered are generated by a random number generator that has limits that can be seen from table 3.2 Characteristics Drone Speed Altitude (m) Angle (deg) 1 Unchanged Unchanged Unchanged 2 Unchanged Unchanged Unchanged 3 Unchanged Unchanged Unchanged 4 Unchanged Unchanged New Random Angle 5 Unchanged Unchanged Unchanged 6 Unchanged Unchanged Unchanged 7 Unchanged Unchanged Unchanged 8 Unchanged Unchanged Unchanged 9 Unchanged New Random Altitude Unchanged 10 Unchanged Unchanged Unchanged 11 New Random Speed Unchanged Unchanged 12 Unchanged Unchanged Unchanged 13 Unchanged Unchanged Unchanged 14 Unchanged Unchanged Unchanged 15 Unchanged Unchanged Unchanged Table 3.4: Example of Mutations 3.9.5 Example of a complete evolution cycle The system has 4 UAVs The simulation is initialised with the following values: • Evolutions: 2 loop iterations • Sexual Maturity Age: 4 loop iterations. • Time Out: 100,000 loop iterations Table 3.5 shows the values of the UAVs characteristics upon initialisation before any search has begun. 40
  • 43. During the search the program will loop through the third nested loop until a UAV is reached. This will repeat four times, once this has completed then alpha drone will be identified. • UAV 1 : 0 Detects. • UAV 2 : 1 Detects. • UAV 3 : 0 Detects. • UAV 4 : 3 Detects. (Alpha UAV) • UAV 5 : 0 Detects. UAV 4 has detected the lost agent the most times and is designated the alpha UAV. UAV 1, 2, 3 and 5 will now take a characteristic at random from UAV 4. At the sam time a mutation will occur where UAVs 1, 3 and 5 will take a random variable from within the allowable characteristic values. Table 3.6 shows the changed values. Characteristics Drone Speed Altitude (m) Angle (deg) 1 450 600 -125 2 250 400 -150 3 300 200 30 4 350 800 39 5 400 1000 179 Table 3.5: Initialised UAV characteristic values 41
  • 44. Characteristics Drone Speed Altitude (m) Angle (deg) 1 350 600 12* 2 350 400 -150 3 350 1000* 30 4 350 800 39 5 10* 800 179 Table 3.6: Initialised UAV characteristic values, * denotes the values changed due to mutations The above process is repeated and this time UAV 2 is found to be the alpha UAV. UAVs 1,2 and 5 have been randomly selected for mutations 3.7 shows the changed characteristic UAV values. Characteristics Drone Speed Altitude (m) Angle (deg) 1 1234* 400 12 2 350 600* -150 3 350 400 30 4 350 800 12 5 350 800 *-178 Table 3.7: Initialised UAV characteristic values, * denotes the values changed due to mutations 42
  • 45. 3.9.6 Turning the UAVs In the search area the UAVs fly around looking for the lost agent. In order to stay in the search area they turn once they reach the edge of the perimeter. Collisions between UAVs are ignored. When a drone reaches the perimeter the angle at which it is currently flying is reflected o↵ the boundary. The angle of incidence is equal to the angle of reflection. 43
  • 46. Chapter 4 Running the Model This chapter provides a detailed overview of how to run the program, the simulation has been designed to be user friendly. Matlab can be run on Windows, Mac and linux based operating systems. 4.1 Locate the program Locate the program the file can be seen in figure 4.1. Every function that is needed is included within the m-file. There is no need for any other functions or add-ins. Figure 4.1: Simulation program m-file 44
  • 47. 4.2 Open and run with Matlab Ensure that the version of Matlab you are running is 2015a or older. If the program is run with an earlier version some of the included functions may not exist and it will result in an error. Open the Matlab program Select the open button. Figure 4.2: Opening Simulation program m-file 45
  • 48. Open the simulation m-file see figures Open the ”DroneEvolutionSimulation.m” file. Figure 4.3: Selecting simulation program m-file Begin the Simulation Select run to start the simulation Figure 4.4: Run the Matlab program 46
  • 49. Change file path Change the file path to the program Figure 4.5: Change Folder Path Input Evolution Variables Input the Evolution variables for this example I have set the values to the corre- sponding values in figure 4.6. Once ”Ok” is selected the program will start and run until completion. Figure 4.6: Input Evolution Variables 4.2.1 Simulation Status The status of the simulation can be seen in the Matlab command line an example is provided in 4.7. 47
  • 50. Figure 4.7: Status of the simulation 4.3 Simulation Outputs The program will run until completion where a series of results will automatically be generated. Once the simulation has finished it will output plots, these plots are listed in the list below with a link to an example figure. • Scatter plot of the time to find the lost object in each evolution cycle 4.8a. • The mean time to find the lost object in each evolution cycle 4.8b. • A first order polynomial line of fit in each evolution cycle 4.8c. • A second order polynomial line of fit in each evolution cycle 4.8d. The program run time can take several hours and result in very high GPU and CPU processing power. If running on a laptop or battery power computer ensure that it is connected to a power supply and has ventilation to ensure the computer cooling systems can function at their maximum potential. 48
  • 51. (a) Iterations to find per evolution cycle (b) Mean iterations to find per evolution cy- cle (c) First Order Polynomial Fit (d) Second Order Polynomial Fit Figure 4.8: Simulation Outputs 49
  • 52. Chapter 5 Future Work 5.1 Homogeneous Characteristics The simulation only included drones with three behavioural characteristics that evolved. Future work could add to these characteristics. Future work could include adding behavioural characteristics listed in the subsections below 5.1.1 Wake vortex surfing Like a flock of birds flying in a V-formation if an aircraft positions itself in the updraft of the wake vortex of the aircraft in front an aerodynamic advantage can be achieved. Greater aerodynamic e ciency is achieved and flight endurance can be increased. Figure 5.1 shows the positioning of an aircraft that is wake vortex surfing. As this is a very complex aerodynamic process a simplification could be to place an extending cone behind the aircraft and the aircraft will be said to be surfing if it is within that cone. Future work could go even further and model the aerodynamic forces generated from each aircraft so an exact position could be 50
  • 53. generated and optimised. Figure 5.1: Wake Vortex Surfing [1] 5.1.2 Manoeuvring Speed As the UAV flies faster its turn radius is increased due to G-loading limitations on the aircraft. If the UAV flies slower the turn radius is decreased. The UAV could be programmed to fly to curvatures of turns and optimised. 5.1.3 Flight pattern optimisation Each UAV could communicate to a central database and update its position. This database will record a breadcrumb trail so other UAVs know that the area has already been covered. Each UAV will be responsible for plotting its own routes and will take into consideration the breadcrumb trails on a one by one basis. The UAVs will assess how much virgin airspace is around and how to best fly to that area and the most e cient way to cover the most ground without flying over excessive amounts of bread trails. I had attempted to implement this into my simulation at the beginning however the path planning required was an enormous amount of work and required extreme 51
  • 54. amounts of CPU cycles. It was abandoned due to time constraints. Communication strategies How often the UAVs communicates with the central database updating its bread- crumb trails. Some UAVs will update the central database every second whilst others will update at a much slower rate. 5.1.4 Distance between agents The distance between the UAVs at the start will be varied. It may be beneficial to have a large dispersion to begin with rather than all the drone clumped together. This will include vertical separation. 5.1.5 Breeding techniques Prime vs. group style mating will be included. Some UAVs would prefer to mate with the UAV that has the most lost ship finds. Whilst others would mate with the closest UAV available. This will be varied with individual genes. The UAV life span could be varied. Some UAVs will live for a one mating iterations whilst others could live from one to 10 mating iterations. 5.2 Non Homogenous Physical Characteristics Physical characteristics could be altered. Physical characteristics are features that cannot be altered by software as they are hardware changes and need physical labour to be performed on each UAV. 52
  • 55. 5.2.1 Drifting Ship The lost agent could be programmed to move in a random direction and speed and see if the swarm can optimise the search for the moving agent. 5.2.2 Impeding factors Factors such as wind, physical obstacles or whether phenomenon could be included in the model. The UAVs would have to deal with sensor shadow and obscuration. 53
  • 56. Chapter 6 Real World Applications There are numerous applications of genetic algorithms in the real world. My research has a narrow focus on search pattern optimisation. However these methods can be used to optimise an almost infinite number of solutions. 6.1 New and Changing areas of interest When searching for an object the search patterns change depending on the landscape the search is taking place on and what you are searching for. For example if a plane had crashed in the desert the type of search methods used to find the downed plane would di↵er to those used if the plane had crashed in a mountainous jungle region. In a traditional hot desert (one with sand dunes, as opposed to the arctic and subarctic deserts). the area has sparse vegetation and the ground is not obstructed from view. The only impediment to visual or sensor detection ability is where sand dunes create a shadow or black spot behind itself. An optimal search method that yielded the most number of detections is likely to have the search drones flying at a high altitude to take advantage of the open unobstructed ground and minimise the 54
  • 57. black spots caused by high sand dunes. However in the mountainous jungle region flying high will not yield many de- tections of the lost agent. This is due to a dense tree canopy obscuring the ground from view and very large regions of mountains that block the drones sensors from being able to see what lies on the other side. I am not able to say what the optimised solution for searching in these areas would be but if the parameters were programmed into the simulator it would be able to optimise the characteristics. These characteristics could then be saved into a repository, when a new swarm of drones is searching an area it could look up previous search types and program its search drones to use the best characteristics from last time. As the situation will never be exactly the same the system will continue to adapt and evolve to become more and more optimised. 6.2 Suspected Routes By knowing a route an object may have taken or moves in a search area can be deduced. For example if a lost agent was known to be moving along in a sinusoidal pattern the location would be unknown but the possible path is defined. In the UAV evolution simulation the lost object is placed randomly on a sine wave. This concept is explained in section 3.4.2. An example where the could be applied would be if an aeroplane crashed and its pattern of movement was known. The suspected movement pattern could be applied into the simulation and the drones would optimise their search pattern to the suspected pattern of movement. These parameters could be entered into the real search drones. 55
  • 58. Chapter 7 Results and Discussion 7.1 Resetting the Start location The simulation was set such that every time the lost agent was found the UAVs would return to the initial start location, this is explained in more detail in section 3.8.1. 7.1.1 Random lost agent evolution The simulation was set to run for 10 evolutions and the age of sexual maturity was varied. The lost agent position was set randomly for every evolution cycle. Every time the UAVs found the lost agent they return to the original start location. 8 UAVs were used, table 7.1 show the input values for the simulation. The results are shown in figures 7.1 and 7.2. 56
  • 59. 8 UAV agents No Distrubance Evolutions Age of Sexual Maturity Timeout Figures 10 1 100,000 7.1a & 7.2b 10 5 100,000 7.1b & 7.2b 10 10 100,000 7.1c & 7.2c 10 20 100,000 7.1d & 7.2d Table 7.1: Results UAVs: 8, no disturbance (a) Evolution is not occurring, Sexual Matu- rity Age: 1 (b) Evolution is not occurring, Sexual Matu- rity Age: 5 (c) Evolution is occurring, Sexual Maturity Age: 10 (d) Evolution is occurring, Sexual Maturity Age: 20 Figure 7.1: Average time to find lost agent without a disturbance 57
  • 60. (a) Evolution is aparently occurring, Sexual Maturity Age: 1 (b) Evolution is not occurring, Sexual Matu- rity Age: 5 (c) Evolution is occurring, Sexual Maturity Age: 1 (d) Evolution is not occurring, Sexual Matu- rity Age: 1 Figure 7.2: Linear line of best fit applied to the time to find the lost agent without a disturbance Discussion Figures 7.1a and 7.2b show simulations that have been run for 10 evolution cycles and have sexual maturity ages of 1 and 5 respectively. The graphs show the systems are not evolving as the time taken to find the lost agent are increasing. figure 7.2a is distorted by an outlier in the data set shown in 7.1a as the system gets slower in finding the lost agent, the system returns to the norm however this is not an improvement on the UAV characteristics. 7.2b shows that the trend is for the system to find the lost agent slowes each time. Once the Sexual maturity age passes 58
  • 61. 10 iterations the simulation shows that the UAVs start to evolve and find the lost agent faster. figures 7.2c and 7.2d show a trend for finding the lost agent faster each time. Mutations have caused the search time to increase in some instances however the system recovers and the trend is to find the trend line suggests the lost agent is found faster each time. 59
  • 62. 7.1.2 Adding a disturbance The simulation was set to run for 10 evolutions and the age of sexual maturity varied. Every time the UAVs find the lost agent they return to the original start location. The simulation is set to evolve to find the lost agent which is placed randomly for the first 5 evolutions. From evolution 6 through to 10 the lost agent was placed randomly on a sine wave the implementation of this is shown in section 3.4.2. Eight UAVs were used, tables 7.2 show the input values. The results are shown in figure 7.3. 8 UAV agents Sine Disturbance Added at 5 Evolutions Evolutions Age of Sexual Maturity Timeout Figure 10 1 100,000 7.3a 10 5 100,000 7.3b 10 10 100,000 7.3c 10 50 100,000 7.3d Table 7.2: Results UAVs: 8, with sine wave disturbance 60
  • 63. (a) Evolution is not occurring, Sexual Matu- rity Age: 1 (b) Evolution is unclear if it is occurring, Sex- ual Maturity Age: 5 (c) Evolution is occurring, Sexual Maturity Age: 10 (d) Evolution is occurring with an outlier at evolution cycle 9, Sexual Maturity Age: 50 Figure 7.3: Average time to find lost agent with a disturbance added at evolution stage 6 Discussion Figure shows simulations that have been run for 10 evolution cycles and have sexual maturity ages of 1 and 5 respectively. A disturbance was added at evolution cycle 6. The graphs show that simulations 7.3a and 7.3b are not evolving to find the lost agent faster. Once the Sexual maturity age passes 10 iterations the simulation shows that the UAVs start to evolve and find the lost agent faster. Mutations have caused the search time to increase in some instances and cause outliers however the the system recovers and the trend is to find the lost agent faster each time. 61
  • 64. 7.2 Continuing on path When the UAV finds the lost agent it continues on its path and the drones location does not reset, this is explained in more detail in section 3.8.2 7.2.1 Random lost agent evolution The simulation was set to run for 10 evolutions and the age of sexual maturity was varied. The lost agent was set randomly for every evolution. Every time the UAVs fine the lost agent they continue on their path. The UAVs reset to the home location after every evolution. Eight UAVs were used, table 7.3 show the input values. The results are shown in figures 7.4 and 7.5. 8 UAV agents No Distrubance Evolutions Age of Sexual Maturity Timeout Figures 10 1 100,000 7.4a & 7.5a 10 5 100,000 7.4b & 7.5b 10 10 100,000 7.4c & 7.5c 10 20 100,000 7.4d & 7.5d Table 7.3: Results UAVs: 8, no disturbance 62
  • 65. (a) Evolution is not occurring, Sexual Matu- rity Age: 1 (b) Evolution is not occurring, Sexual Matu- rity Age: 5 (c) Evolution is starting to occure, Sexual Maturity Age: 10 (d) Evolution is occurring, Sexual Maturity Age: 20 Figure 7.4: Average time to find lost agent without a disturbance and continuing on the UAVs path without resetting its position 63
  • 66. (a) Evolution is not occurring, Sexual Matu- rity Age: 1 (b) Evolution is not occurring, Sexual Matu- rity Age: 5 (c) Evolution is occurring, Sexual Maturity Age: 10 (d) Evolution is occurring, Sexual Maturity Age: 20 Figure 7.5: Linear line of best fit applied to the time to find the lost agent without a disturbance and continuing on the UAVs path with out resetting its position Discussion The graphs above in section 7.2.1 show that evolution is not occurring to optimise the simulation in simulations where the minimum breeding age is set below 10 iteration cycles. Once the system reaches a sexual maturity age of 10 cycles then evolution starts to optimise the time to find the lost agent. 64
  • 67. 7.2.2 Adding a disturbance The simulation was set to run for 10 evolutions and the age of sexual maturity varied. Every time the UAVs fine the lost agent they continue on their path the reset every evolution cycle. The simulation is set to evolve to find the lost agent which is placed randomly for the first 5 evolutions. From evolution 6 through to 10 the lost agent was placed randomly on a sine wave the implementation of this is shown in section 3.4.2. 8 UAVs were used, tables 7.4 show the input values. The results are shown in figures 7.6 and 7.7. 8 UAV agents Sine Disturbance Added at 5 Evolutions Evolutions Age of Sexual Maturity Timeout Figures 10 1 100,000 7.6a & 7.7a 10 5 100,000 7.6b & 7.7b 10 10 100,000 7.6c & 7.7c 10 20 100,000 7.6d & 7.7d Table 7.4: Results UAVs: 8, with wine wave disturbance 65
  • 68. (a) Evolution is not occurring, Sexual Matu- rity Age: 1 (b) Evolution is not occurring, Sexual Matu- rity Age: 5 (c) Evolution is occurring, Sexual Maturity Age: 10 (d) Evolution is occurring, Sexual Maturity Age: 20 Figure 7.6: Average time to find lost agent with a disturbance and continuing on the UAVs path without resetting its position 66
  • 69. (a) Evolution is aparently occurring, Sexual Maturity Age: 1 (b) Evolution is not occurring, Sexual Matu- rity Age: 5 (c) Evolution is occurring, Sexual Maturity Age: 10 (d) Evolution is apparently occurring but it is not acutally, Sexual Maturity Age: 20 Figure 7.7: Linear line of best fit applied to the time to find the lost agent with a disturbance and continuing on the UAVs path with out resetting its position Discussion Again for simulations where the sexual maturity age is set below 10 iteration cycles the system does not optimise. 7.3 Discussion The results above have yielded interesting outcomes. The results that I encoun- tered were as I had expected but required further analysis to fully understand their implications. 67
  • 70. 7.3.1 Sexual maturity age The age at which drone is allowed to breed is vitally important for the swarm to optimise its characteristics. 7.3a is an excellent example where the age at which the drones were allowed to breed did not improve the search time for the lost agent. The search times oscillate and do not improve. When compared to simulations where the sexual age of maturity is greater than or equal 10 iteration cycles such as in 7.3c it is clear that the swarm needs time to prove a particular UAVs genes are superior. The reason the age needs to be set is because a UAV may have a lucky find by chance and not have the best genes for the scenario. 7.3.2 Randomness and Repeatability Every simulation run was di↵erent, the plots above do not run o↵ a common data set rather they are ’online versions’. The nature of random generators means that each simulation is unique and di↵erent to the next. Using trend lines and averages the overall picture of each simulation was able to be extrapolated. 7.3.3 Mutations Mutations are critical in allowing the simulation to adapt to changing environments. If the simulation is allowed to only take the characteristics of the most successful drone then if all the drones may get stuck in an infinite loop as all their characteristics could be the same and none of them would ever find the lost object. The mutations are vital as they will upset the balance and inject a new characteristic that can pull the swarm out of an infinite loop. 68
  • 71. 7.3.4 Starting Position The a comparison of the plots in sections 7.1 and 7.2 show that the swarm is able to adapt to the system if it is allowed to remain on its trajectory and not reset its position every time the lost agent is found. This reduces the chance of a lucky find by a UAV as they make themselves more and more unique by not resetting their start position. 7.3.5 Semi Random Disturbance Fitting The removal of complete uncertainty of the lost agents position by placing it ran- domly on a sine curve does not upset the system to a point where it can be further optimised. The plots above do not show an decrease in time to find the lost agent, rather the simulation times to find the lost agent decrease at a expected rate as before the disturbance was added. 7.3.6 Unexplainable spike increase in search time There is an interesting feature that I am not able to explain in the results. For around 50% of simulations an increase in time taken to find the lost agent on the second, third or fourth evolutionary step is recorded. This can be seen in figure 7.8a. When the scatter plot is analysed in figure 7.8b it is clear that the average time to detect the lost agent is longer. 69
  • 72. (a) Average time taken to find lost agent (b) scatter plot of time taken to find lost agent Figure 7.8: Evolution Cycles: 10, Sexual Maturity age: 15, Timeout: 100,000 70
  • 73. Chapter 8 Conclusion Through the use of a genetic algorithm the search characteristics of a swarm of UAVs was able to be optimised to find a lost agent faster. A homogenous swarm of search drones was able to evolve their characteristics to find a randomly placed lost object. Their speeds of detection increased as their genetics changed and adapted to the environment. A vital part of evolution that was identified was the need to delay the age of sexual maturity. If the age of sexual maturity was set to young the system stayed in its current state and a improvement of detection times was not noticed. However if the age of sexual maturity was delayed then the UAVs with the strongest charac- teristics was able to prove that it was the ’alpha’ UAV and passed down its superior genes to the other drones. The reason the system did not evolve if the age of sexual maturity was set to young is that some of the UAVs would have a lucky find of the lost agent. It is an interesting comparison to reality in nature where if animals or humans mate to early they may pass down defective genes. A semi random lost path was used to place the lost agent randomly on a sine 71
  • 74. wave. From the simulations there was not a noticeable change in the time to taken to find the lost agent when the lost agent was placed on the sine wave. The system was not able to adapt to find a semi random lost agent faster than a fully random lost agent. An unexplainable scenario readily occurs on the second, third or fourth step of evolution where the time to find the lost agent increases and then decreases. This increase in search time was not able to be explained and was evident in around 50% of simulations. The thesis was a success, the aim of achieving a system that is able to modify itself in order to find a lost agent faster was accomplished. There is more scope for research and fine tuning and further applications. 72
  • 75. Chapter 9 Personal Remarks 9.1 The idea I grappled with my thesis topic for many months. The topic morphed and grew like a tree root searching for water. I took some paths that I thought were good but turned out to be dead ends until eventually like a process of evolution I found water (my final idea). I had just returned to Australia and UNSW from probably the most exciting time of my life. I was working and living in France working for Airbus in their Re- search and Development team. I was brimming with ideas on the aviation industry and found a new passion that I wanted to move my life in. I had worked next to people who were developing revolutionary software and hardware that will be imple- mented in the aviation industry in the next 20 years. One of my colleagues at lunch mentioned the idea of surfing the wake vortex of another aircraft in order to reduce fuel consumption. I was bright eyed and thought this was the best idea since sliced bread. I instantly became interested. I wanted to extend the endurance of aircraft 73
  • 76. flying so that they could fly further distances or use less fuel when flying. I wanted to implement this with drones as any lift producing surface will produce a vortex, meaning even helicopters can ride the vortex. Much work is being conducted with the USAF (United States Airforce) in the fuel saving e↵ects this can have. I came into my first meeting with my supervisor and he said that this idea had merit but as I came from a mechatronics background that this would be a bit over my head. I had not been exposed to the aerodynamics required to calculate the optimum points for aircraft positioning. He instead said that I could mimic this e↵ect by placing a cone wake e↵ect o↵ the end of the rotor and place each vehicle in this and say that they were surfing the vortex. I was happy to do this but it left me with the worlds shortest thesis topic. He realised my dilemma and suggested that this could be a characteristic that aircraft exploit. He suggested a research area looking in the fact that aircraft could learn from their surroundings. For instance an Aircraft flying over the dessert searching for a lost person would need to utilise di↵erent search tactics to aircraft flying over the sea or a mountainous area. I thought that this was an incredibly interesting area and was hooked. Their existed almost endless permutations that I could research, I chose to simplify my model and have a lost ship at sea with aircraft searching for it. This was a simple 3D model that I could build upon. 9.2 Programming Languages Initially my thesis supervisor suggested that I run the simulation in a program called ”AnyLogic” I ran into licensing issues and I was unfamiliar with the way the program ran. I was told that I was able to select any program of my choice, I began a search 74
  • 77. and comparison of languages that I could use. During my university career I have programmed in C, C++, C#, and Matlab. As I learnt the fundamentals of C first the rest of the programming languages were a natural progression as they were all derived from C. The adage is if you can program in C you can program in anything. 9.2.1 AnyLogic Initially I was told that ”Anylogic” could be used to simulate processes and that this would be a suitable software package to run my simulation on. I spent about a few hours a week for six weeks in my supervisors o ce running through tutorials and learning how the software worked. There was a steep learning curve, Anylogic is a proven platform that is can be used to model Discrete Event, Agent Based and System Dynamics Simulation [2]. I knew that Anylogic was a industry proven method that would work. It provided a large database of predefined variables and an excellent GUI (Graphical User Interface). However for my thesis I required greater functionality. This meant that I needed to learn ”Java”. I contacted Anylogic head quarters in the USA and looked into undertaking one of their programming courses. They did not have any courses in Australia. If I was to take one of these courses I would need to travel to the USA. I was willing to spend the money on an airfare and undertake the course but in the end I was not able to take the time o↵ from university. I understood that Java is a industry standard however I was not willing to take the leap of faith to learn a completely new programming language. I needed an alternative way to run my simulation. 75
  • 78. 9.2.2 Matlab My next thought was to use Matlab, my supervisor was very flexible and would have let me use smoke signals if I could make them into a working model. The UNSW courses that I have done so far have a great reliance on Matlab for the bulk of their course work. I had used it in many subjects and had even started using it in place of other programs like Microsoft Excel to complete assignments for other subjects. I conducted an internship with Airbus in France for six months. The bulk of my work there utilised Excel and Matlab. I was familiar with Matlab prior to working at Airbus but at the end of my employment I was a very capable programmer. Programming in Matlab would mean that I would have to create everything from scratch and that there would not be an existing programming environment that I could just put parameters into and make it work. This was a large leap of faith as my supervisor told me that the success of my thesis rested on my ability to get the simulation working. I didn’t know if I had the computing knowledge and programming experience to do this. Needless to say I was very nervous, I knew that there were a vast amount of resources at UNSW if I ran into trouble with Matlab. I decided in the end that Matlab was the best approach as it would allow the most flexibility, the only limitation that I would have with Matlab was my programming ability. At the end of my thesis now I am very glad I used Matlab to run my simulations. 76
  • 79. Bibliography [1] Aerospace and defense. 2014. [2] Anylogic, May 2015. [3] K. Bo´nkowska S. Cebrat A. Laszkiewicz, P.Biecek. From Genetics to Mathe- matics, volume 79 of Series on Advances in Matematics for Applied Sciences. World Scientific Publishing Company, 2009. [4] Stefan R.Flanzer Tristan C. Blake, William Bieniawski. Surfing aircraft vorti- cies for energy. The Journal of Defense Modeling and Simulation: Applications, Methodology, Technology, 2013. [5] Sharkey; AmandaJ C. Robots, insects and swarm intelligence. Artificial Intel- ligence Review, 26(4):255–268, December 2006. [6] Charles Darwin. The Origin of Species by Means of Natural Selection. 1859. [7] Rania Hassan; Babak Cohanim; Olivier de Weck. A comparison of particle swarm optimization and the genetic algorithm. American Institute of Aeronat- ics and Astronautics, pages 1 – 13. [8] The Free Dictionary. The free dictionary, April 2015. 77
  • 80. [9] James Kennedy; Russell Eberhart. Particle swarm optimization, neural net- works. IEEE, 4:1942 – 1948, Nov/Dec 1995. [10] Frauke Feind. Geese. pixabay right free, 2014. [11] Western Australian State Government. Boys and puberty. Booklet online. [12] Western Australian State Government. Girls and puberty. Online Booklet. [13] Jose Guivant. Advanced autonomous systems - task 0. Technical report, 2015. [14] John Holland. Genetic algorithms, computer programs that ”evolve” in ways that resemble natural selection can solve complex problems even their creators do not fully understand. Scientific American, July 1992. [15] Cadell Last. Current Aging Science, volume 7. Bentham Science, 2014. [16] Adam Lipowski; Dorota Lipowska. Roulette-wheel selection via stochastic ac- cptance. Physica A, 391(6):2193 – 2196, March 2012. [17] PixelAnarchy. Fish. Pixabay right free, June 2006. [18] Jonathan Price. Determining altitude agl using optical flow. 2014. [19] J. Harwood; J.J Prime. Some factors a↵ecitng the size of british grey seal populations. Journal of Applied Ecology, 15:401–411, August 1978. [20] Craig W. Reynolds. Flocks, herds and schools: A distributed behavioral model. SIGGRAPH Comput. Graph., 21(4):25–34, 1987. [21] M ; Rash J.L ; Xukai Zou Yuan-Shun Dai; Hinchey, M; Madhusoodan. A pro- totype model for self-healing and self-reproduction in swarm robotics system. 78
  • 81. pages 3–10, Indianapolis, IN, 2006. Dependable, Autonomic and Secure Com- puting, 2nd IEEE International Symposium, IEEE. 79
  • 82. Matlab Code 1 %Author: Alexander Champion de Crespigny 2 %Date Last Edit: 31 May 2015 3 %Program: My theis simulation file that optimises the characteristics ,! of a drone simulation searching for a ship at sea. 4 5 function DroneEvolutionSimulation() 6 Erase() 7 8 global MySearch 9 global Genetics 10 global Map 11 global LengthSearch 12 global Position 13 global Breeding Stats 14 global DNA2USE 15 global Results 16 global Evolutions 17 global TimetoProveDNA 18 global currentEvolution 19 global AngleHistory 80
  • 83. 20 global timeout Length 21 global ResultsPlot 22 23 %50 50 100 took 14431 seconds = 4 hours 24 25 MySearch.NumberOfDrones = 8; 26 27 % Map Size 28 Map.xmin = -80000; Map.xmax = 80000; 29 Map.ymin = -80000; Map.ymax = 80000; 30 31 Inputs(); 32 33 34 % Evolutions = 2; 35 % TimetoProveDNA = 1; 36 % timeout Length = 100000; 37 38 39 Genetics.Min Alt = 0; 40 Genetics.Max Alt = 2000; 41 Genetics.Min Speed = 0; 42 Genetics.Max Speed = 50000; 43 Genetics.Min Angle = -180; 44 Genetics.Max Angle = 180; 45 46 Genetics.RandomAngle = (Genetics.Min Angle:1:Genetics.Max Angle); % ,! creates a matrix of random angles that can be entered to cause ,! mutations 81
  • 84. 47 48 %Each new column is a different drone 49 50 51 Genetics.Altitude = randi([Genetics.Min Alt, Genetics.Max Alt],[1,8]); 52 Genetics.Speed = randi([Genetics.Min Speed, Genetics.Max Speed ,! ],[1,8]); 53 Genetics.Angle = randi([Genetics.Min Angle, Genetics.Max Angle ,! ],[1,8]); 54 55 56 % Genetics.Altitude = [100 ; 400 ; 600 ; 800 ; 1200 ; 1400 ; 1600 ; ,! 1800 ]; 57 % Genetics.Speed = [100 ; 500 ; 800 ; 1000 ; 1500 ; 2000 ; 2500 ; ,! 3000 ]; 58 % Genetics.Angle = [1 , 46 , 90 , 136 , 179 , -44 , -90 , ,! -134 ]; %90 is straight up anything else bounces off walls 59 % Genetics.Angle = 60 %Search Type 61 % 1 = Linear 62 % 2 = Box 63 % 3 = Circular 64 % 4 = random 65 Genetics.Search Type = [1; 1; 1; 1; 1; 1; 1; 1]; %1 = 66 AngleHistory = zeros(MySearch.NumberOfDrones, Evolutions); 67 tic 68 TimetoFind = zeros(TimetoProveDNA, Evolutions); 69 for k = 1:Evolutions 70 currentEvolution = k; 82
  • 85. 71 if k ~= 1 72 Breed(); 73 end 74 Simulation = 1; 75 76 AngleUsageoverBreeding() 77 78 Position.UAV 1 = [0-4000,Map.ymin+1,deg2rad(Genetics.Angle(1)) ,! ]; %Startx, Starty, Start Angle 79 Position.UAV 2 = [0-3000,Map.ymin+1,deg2rad(Genetics.Angle(2)) ,! ]; 80 Position.UAV 3 = [0-2000,Map.ymin+1,deg2rad(Genetics.Angle(3)) ,! ]; 81 Position.UAV 4 = [0-1000,Map.ymin+1,deg2rad(Genetics.Angle(4)) ,! ]; 82 Position.UAV 5 = [0+1000,Map.ymin+1,deg2rad(Genetics.Angle(5)) ,! ]; 83 Position.UAV 6 = [0+2000,Map.ymin+1,deg2rad(Genetics.Angle(6)) ,! ]; 84 Position.UAV 7 = [0+3000,Map.ymin+1,deg2rad(Genetics.Angle(7)) ,! ]; 85 Position.UAV 8 = [0+4000,Map.ymin+1,deg2rad(Genetics.Angle(8)) ,! ]; 86 for i = 1:TimetoProveDNA 87 88 89 90 MySearch.Detected = 0; 91 83
  • 86. 92 LengthSearch = 10; 93 index = 1; 94 95 figure(1); clf; 96 % figure('name','Drone Evolution Simulation','Visible','on ,! ','NumberTitle','off'); 97 hold on 98 zoom on 99 MySearch.Map = plot(0,0) ; % Defines the map 100 MySearch.Wave = plot(0,0); 101 axis([Map.xmin,Map.xmax,Map.ymin,Map.ymax]); % Makes the graph ,! a certain size 102 xlabel('Distance (m)') 103 ylabel('Distance (m)') 104 105 106 %%Plot the Drones 107 MySearch.UAV1.Pos = plot(Position.UAV 1(1),Position.UAV 1(2),'y ,! *') ; %UAV 1 108 MySearch.UAV2.Pos = plot(Position.UAV 2(1),Position.UAV 2(2),'m ,! *') ; %UAV 2 109 MySearch.UAV3.Pos = plot(Position.UAV 3(1),Position.UAV 3(2),'c ,! *') ; %UAV 3 110 MySearch.UAV4.Pos = plot(Position.UAV 4(1),Position.UAV 4(2),'r ,! *') ; %UAV 4 111 MySearch.UAV5.Pos = plot(Position.UAV 5(1),Position.UAV 5(2),'g ,! *') ; %UAV 5 112 MySearch.UAV6.Pos = plot(Position.UAV 6(1),Position.UAV 6(2),'b ,! *') ; %UAV 6 84
  • 87. 113 MySearch.UAV7.Pos = plot(Position.UAV 7(1),Position.UAV 7(2),'r ,! +') ; %UAV 7 114 MySearch.UAV8.Pos = plot(Position.UAV 8(1),Position.UAV 8(2),'k ,! *') ; %UAV 8 115 116 MySearch.UAV1.Circle = plot(Position.UAV 1(1),Position.UAV 1(2) ,! ,'g') ; %UAV 1 117 legend(' ' ,'Sine Wave', 'Drone 1','Drone 2','Drone 3', 'Drone ,! 4','Drone 5','Drone 6','Drone 7', 'Drone 8','Sensor Area ,! ', 'Location','southoutside','Orientation','horizontal') ,! ; 118 119 MySearch.UAV2.Circle = plot(Position.UAV 2(1),Position.UAV 2(2) ,! ,'g') ; %UAV 2 120 MySearch.UAV3.Circle = plot(Position.UAV 3(1),Position.UAV 3(2) ,! ,'g') ; %UAV 3 121 MySearch.UAV4.Circle = plot(Position.UAV 4(1),Position.UAV 4(2) ,! ,'g') ; %UAV 4 122 123 MySearch.UAV5.Circle = plot(Position.UAV 5(1),Position.UAV 5(2) ,! ,'g') ; %UAV 5 124 MySearch.UAV6.Circle = plot(Position.UAV 6(1),Position.UAV 6(2) ,! ,'g') ; %UAV 6 125 MySearch.UAV7.Circle = plot(Position.UAV 7(1),Position.UAV 7(2) ,! ,'g') ; %UAV 7 126 MySearch.UAV8.Circle = plot(Position.UAV 8(1),Position.UAV 8(2) ,! ,'g') ; %UAV 8 127 %% 128 85
  • 88. 129 MySearch.Lost = plot(0,0,'rd') ; %lost agent 130 % zoom on % I don't know what this does. 131 box on % makes a continous box around the graph 132 % set(gca,'xtick',[],'ytick',[]) % removes the tick marks ,! off the graph 133 title('Search Area'); %Adds the title to the graph 134 if k <= Evolutions/2 135 RandOrSin = 1; 136 else 137 RandOrSin = 2; %turn back on for sine wave 138 end 139 Lost Agent(RandOrSin); 140 141 while MySearch.Detected == 0; 142 143 if index <= timeout Length 144 printSatus(index,timeout Length, i, k, Evolutions, ,! TimetoProveDNA); 145 146 UAV1(index); 147 UAV2(index); 148 UAV3(index); 149 UAV4(index); 150 UAV5(index); 151 UAV6(index); 152 UAV7(index); 153 UAV8(index); 154 pause(.0001); 155 index = index + 1; 86
  • 89. 156 if MySearch.Detected == 1 157 Breeding Stats(Simulation, 1) = MySearch. ,! SucessuflDrone; % what drone detected the ,! object 158 % Breeding Stats(Simulation, 2) = ,! MySearch.SucessfulSpeed; 159 % Breeding Stats(Simulation, 3) = ,! MySearch.SucessfulAltitude; 160 161 162 163 164 end 165 else 166 MySearch.Detected = 1; 167 end 168 end 169 170 TimetoFind(i,k) = index; 171 Results = TimetoFind; 172 save('Results'); 173 Simulation = Simulation + 1; 174 175 176 pause(0.0001); 177 end 178 % pause(0.0001); 179 180 save('Breeding Stats') 87
  • 90. 181 BestDrone() 182 end 183 toc 184 185 processResults(TimetoFind) 186 end 187 188 function printSatus(index,timeout Length, i, k, Evolutions, ,! TimetoProveDNA) 189 clc 190 fprintf('Evolution cycle %d of %dn', k, Evolutions); 191 fprintf('Run cycle %d of %dn', i, TimetoProveDNA); 192 fprintf('Iterations until time out %dn', (timeout Length-index)); 193 end 194 195 function BestDrone() 196 global Breeding Stats 197 global MySearch 198 global Genetics 199 global DNA2USE 200 201 BestestDrone = zeros(MySearch.NumberOfDrones, 1); 202 if isempty(Breeding Stats) ~= 1 203 for i = 1: MySearch.NumberOfDrones 204 BestestDrone(i,1) = sum(Breeding Stats(:, 1) == i); 205 end 206 end 207 [~, Bestest1Drone] = max(BestestDrone); 208 88
  • 91. 209 %Strongest Characteristics 210 % DroneID, Speed, Altitude, Search Type 211 DNA2USE = [Bestest1Drone, Genetics.Altitude(Bestest1Drone), Genetics. ,! Speed(Bestest1Drone), Genetics.Angle(Bestest1Drone)]; 212 end 213 214 function Breed() 215 % Breed % I want the other drones to take 1/3 of the sucessful drones ,! DNA(persay) 216 global Breeding Stats 217 global Genetics 218 global DNA2USE 219 global MySearch 220 221 %Genetic to take at a random 222 for i = 1:MySearch.NumberOfDrones 223 Gene2take = randi([2,4],[1,1]); 224 if Gene2take == 2 225 Genetics.Altitude(i) = DNA2USE(Gene2take); 226 else if Gene2take == 3 227 Genetics.Speed(i) = DNA2USE(Gene2take); 228 else if Gene2take == 4 229 Genetics.Angle(i) = DNA2USE(Gene2take); 230 end 231 end 232 end 233 end 234 235 89
  • 92. 236 % Mutations also need to occur and this can be seen as recessant genes, 237 % lets take genes from the origional sample and implement them. 238 239 RandDrone = randi([1,MySearch.NumberOfDrones], [1,3]); % Choose a ,! random drone 240 RandAngle = randi([-180,180],[1,1]); % Choose a random angle 241 RandSpeed = randi([Genetics.Min Speed,Genetics.Max Speed],[1,1]); 242 RandAlt = randi([Genetics.Min Alt,Genetics.Max Alt],[1,1]); 243 244 Genetics.Angle(RandDrone(1)) = RandAngle; %assign random angle to ,! random 245 Genetics.Speed(RandDrone(2)) = RandSpeed; 246 Genetics.Altitude(RandDrone(3)) = RandAlt; 247 248 end 249 250 function AngleUsageoverBreeding() 251 global Genetics 252 global currentEvolution 253 global MySearch 254 global Evolutions 255 global AngleHistory 256 257 for l = 1:MySearch.NumberOfDrones 258 AngleHistory(l,currentEvolution) = Genetics.Angle(l); 259 end 260 save('AngleHistory'); 261 end 262 90
  • 93. 263 function [xp, yp] = Circle(r) 264 %x and y are the coordinates of the center of the circle 265 %r is the radius of the circle 266 %0.01 is the angle step, bigger values will draw the circle faster but 267 %you might notice imperfections (not very smooth) 268 ang=0:0.01:2*pi; 269 xp=r*cos(ang); 270 yp=r*sin(ang); 271 272 end 273 274 function Detected(Distance, Radius, Drone Number, Altitude, Speed) 275 global MySearch 276 global Genetics 277 278 %Speed Accuracy 279 Speed Accuracy = 1 - (Speed/Genetics.Max Speed); 280 281 %Altitude Accuracy 282 Altitude Accuracy = 1 - (Altitude/Genetics.Max Alt); 283 284 %Total Accuracy 285 Total Accuracy = Speed Accuracy * Altitude Accuracy; 286 287 Random Number = rand(1); 288 Total Accuracy = (Total Accuracy + Random Number); 289 290 if Distance <= Radius 291 if Total Accuracy >= 1 91
  • 94. 292 MySearch.Detected = 1; 293 Sucessful Drone(Drone Number, Altitude, Speed); 294 else 295 end 296 end 297 end 298 299 function Sucessful Drone(Drone Number, Altitude, Speed) 300 global MySearch 301 fprintf('The Object was detected by Drone: %dn', Drone Number); 302 MySearch.SucessuflDrone = Drone Number; 303 MySearch.SucessfulSpeed = Speed; 304 MySearch.SucessfulAltitude = Altitude; 305 end 306 307 function Distance = UAV2Lost(UAVPos) 308 global MySearch 309 Distance = sqrt(((UAVPos(1) - MySearch.Lost Pos(1))ˆ2) + ((UAVPos(2) - ,! MySearch.Lost Pos(2))ˆ2)); 310 end 311 312 function Lost Agent(RandOrSin) 313 global MySearch 314 global Map 315 % Position of the lost agent 316 % Plots a random position 317 if RandOrSin == 1 318 XLostPos = randi([Map.xmin,Map.xmax],[1,1]); % This generates a X & ,! Y coordiante randomly within the map region 92
  • 95. 319 YLostPos = randi([Map.ymin,Map.ymax],[1,1]); 320 321 %Plots a random position on a sine curve 322 else if RandOrSin == 2 323 Amplitude = (abs(Map.ymin) + abs(Map.ymax))/2; 324 x = randi([Map.xmin, Map.xmax],[1,1]); 325 t = (Map.xmin:1:Map.xmax); 326 a = Amplitude*sin(t/3000); 327 x = abs(x*2); 328 XLostPos = t(x); 329 YLostPos = a(x); 330 set(MySearch.Wave, 'xdata', t, 'ydata', a); 331 end 332 end 333 334 Position = [XLostPos, YLostPos]; % This is an (X, Y) coordinate that is ,! generated randomly 335 set(MySearch.Lost, 'xdata', Position(1), 'ydata', Position(2)); 336 MySearch.Lost Pos = [Position(1), Position(2)]; 337 end 338 339 function Radius = SensorRadius(Altitude) 340 %This funcion takes in the UAVS altitude and then return a searchable ,! area 341 %for the sensor based on its altitude 342 343 Sensor Angle = 90; %deg total sweep so from the vertical it is 15deg 344 345 if Altitude < 0 93
  • 96. 346 fprintf('Drones cannot fly so low it had crashed'); 347 else 348 Sensor Angle = deg2rad(Sensor Angle/2); 349 Half Radius = Altitude * tan(Sensor Angle); 350 Radius = 2*Half Radius; 351 end 352 end 353 354 function BoxSearch UAV 1(Speed, index, Radius) 355 global LengthSearch 356 global Position 357 L = 1; 358 dt = 0.01; 359 Alpha = 0; 360 361 [Dist2Top, Dist2Left, Dist2Bottom, Dist2Right] = Dist Circle2MapEdge( ,! Radius); 362 363 for i = 1:100 364 if Dist2Top <= i*Radius 365 Position.UAV 1(3) = deg2rad(180); % Turns left 366 end 367 368 if Dist2Left <= i*Radius 369 Position.UAV 1(3) = deg2rad(270); % Turns Down 370 end 371 372 if Dist2Bottom <= i*Radius 373 Position.UAV 1(3) = deg2rad(0); % Turns Right 94
  • 97. 374 end 375 376 if Dist2Right <= i*Radius 377 Position.UAV 1(3) = deg2rad(90); % Turns up 378 end 379 380 end 381 382 % if Dist2Left <= 2*Radius 383 % Position.UAV 1(3) = deg2rad(270); % Turns Down 384 % end 385 % 386 % if Dist2Bottom <= 2*Radius 387 % Position.UAV 1(3) = deg2rad(0); % Turns Right 388 % end 389 % 390 % if Dist2Right <= 2*Radius 391 % Position.UAV 1(3) = deg2rad(90); % Turns up 392 % % iteration = iteration + 1 393 % end 394 395 % needs to work out size of search are then adapt to search area ,! size 396 x2 = zeros(3, LengthSearch); 397 398 x2(:,index) = [Position.UAV 1(1); Position.UAV 1(2); Position.UAV 1(3) ,! ]; 399 400 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index)); 95
  • 98. 401 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index)); 402 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha); 403 404 Position.UAV 1 = x2(:, index+1); 405 end 406 407 function [Dist2Top, Dist2Left, Dist2Bottom, Dist2Right] = ,! Dist Circle2MapEdge(Radius) 408 global Position 409 global Map 410 411 Map.xmin = -10000; Map.xmax = 10000; 412 Map.ymin = -10000; Map.ymax = 10000; 413 414 Dist2Top = abs(Map.ymax - Position.UAV 1(2)); 415 Dist2Left = abs(Position.UAV 1(1) - Map.xmin); 416 Dist2Bottom = abs(Position.UAV 1(2)- Map.ymin); 417 Dist2Right = abs(Position.UAV 1(1) - Map.xmax); 418 419 end 420 421 function Erase() 422 close all 423 clear all 424 clc 425 end 426 427 function processResults(TimetoFind) 428 global Evolutions 96
  • 99. 429 global TimetoProveDNA 430 MeanTime = zeros(1,Evolutions); 431 for i = 1:Evolutions 432 MeanTime(:,i) = mean(TimetoFind(:,i)); 433 end 434 x = 1:Evolutions; 435 figure('name','Mean Time','Visible','on','NumberTitle','off'); 436 plot(x, MeanTime); 437 xlabel('Evolution Cycle'); 438 ylabel('Time to Find lost object (iterations)'); 439 legend('Mean time of to find lost agent from each Evolution'); 440 441 figure('name','Time To Find Lost Agent','Visible','on','NumberTitle',' ,! off'); 442 Xscat = zeros(TimetoProveDNA, Evolutions); 443 for i = 1:Evolutions 444 Xscat(:,i) = i; 445 end 446 Xscat = Xscat(:)'; 447 TimetoFind = TimetoFind(:)'; 448 scatter(Xscat,TimetoFind); 449 xlabel('Evolution Cycle'); 450 ylabel('Time to Find lost object (iterations)'); 451 legend('Time of to find lost agent from each Evolution'); 452 453 x = linspace(0,Evolutions); 454 figure('name','1st Order Polynomial fit','Visible','on','NumberTitle',' ,! off'); 455 p1 = polyfit(Xscat,TimetoFind,1); 97
  • 100. 456 y2 = polyval(p1,x); 457 plot(x,y2) 458 xlabel('Evolution Cycle'); 459 ylabel('Time to Find lost object (iterations)'); 460 legend('1st Order Polynomial'); 461 462 463 x = linspace(0,Evolutions); 464 figure('name','2nd Order Polynomial fit','Visible','on','NumberTitle',' ,! off'); 465 p2 = polyfit(Xscat,TimetoFind,2); 466 y2 = polyval(p2,x); 467 plot(x,y2) 468 xlabel('Evolution Cycle'); 469 ylabel('Time to Find lost object (iterations)'); 470 legend('2nd Order Polynomial'); 471 472 % figure(5); 473 % p3 = polyfit(Xscat,TimetoFind,3); 474 % y3 = polyval(p3,x); 475 % plot(x,y3) 476 % 477 % figure(6); 478 % p4 = polyfit(Xscat,TimetoFind,4); 479 % y4 = polyval(p4,x); 480 % plot(x,y4); 481 % 482 % figure(7); 483 % p5 = polyfit(Xscat,TimetoFind,5); 98
  • 101. 484 % y5 = polyval(p5,x); 485 % plot(x,y5); 486 487 % legend('Data', '2nd deg Fit', '3rd deg Fit', '4th deg Fit', '5th deg ,! Fit'); 488 489 490 end 491 492 function Inputs() 493 global Evolutions 494 global TimetoProveDNA 495 global timeout Length 496 497 498 prompt={'Number of Evolutions:','Age of Drone sexual maturity','timeout ,! length'}; 499 title='Evolution Simulation'; 500 501 answer=inputdlg(prompt,title); 502 503 %Variables to be entered 504 Evolutions = str2num(answer{1}); 505 TimetoProveDNA = str2num(answer{2}); 506 timeout Length = str2num(answer{3}); 507 end 508 509 %% Drone 1 510 function UAV1(index) 99
  • 102. 511 global MySearch 512 global Genetics 513 global Position 514 Drone Number = 1; 515 %Initial UAV Position entered as cartesian coordinates (X, Y, ,! Orientation(Deg) 516 517 % UAV Genetics 518 Speed = Genetics.Speed(1); %m/s % this will be fast or slow 519 Altitude = Genetics.Altitude(1); %m need to make it hight or low 520 521 Radius = SensorRadius(Altitude); % Runs a function that returns the ,! sensors search area 522 [xp, yp] = Circle(Radius); 523 Distance = UAV2Lost(Position.UAV 1); %returns the distance between the ,! UAV and lost object 524 Detected(Distance, Radius, Drone Number, Altitude, Speed); 525 526 527 if Genetics.Search Type(1) == 1 528 Movement UAV 1(Speed, index); 529 else if Genetics.Search Type(1) == 2 530 BoxSearch UAV 1(Speed, index, Radius); 531 end 532 end 533 534 535 set(MySearch.UAV1.Pos, 'xdata', Position.UAV 1(1), 'ydata', Position. ,! UAV 1(2)); 100
  • 103. 536 set(MySearch.UAV1.Circle, 'xdata', Position.UAV 1(1) + xp, 'ydata', ,! Position.UAV 1(2) + yp); 537 end 538 function Movement UAV 1(Speed, index) 539 global LengthSearch 540 global Position 541 L = 1; 542 dt = 0.01; 543 Alpha = 0; 544 545 x2 = zeros(3, LengthSearch); 546 BouneOffEdges 1() 547 x2(:,index) = [Position.UAV 1(1); Position.UAV 1(2); Position.UAV 1(3) ,! ]; 548 549 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index)); 550 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index)); 551 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha); 552 553 Position.UAV 1 = x2(:, index+1); 554 end 555 function BouneOffEdges 1() 556 global Position 557 global Map 558 559 if Position.UAV 1(1) <= Map.xmin % Reached Left 560 if rad2deg(Position.UAV 1(3)) <= 180 561 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1(3); 562 else 101
  • 104. 563 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1(3); 564 end 565 566 else if Position.UAV 1(2) >= Map.ymax; %Reached Top 567 if rad2deg(Position.UAV 1(3)) <= 180 568 Position.UAV 1(3) = deg2rad(360) - Position.UAV 1(3); 569 else 570 Position.UAV 1(3) = Position.UAV 1(3) + deg2rad(180); 571 end 572 573 else if Position.UAV 1(1) >= Map.xmax; %Reached Right 574 if rad2deg(Position.UAV 1(3)) <= 180 575 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1(3); 576 else 577 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1(3); 578 end 579 580 else if Position.UAV 1(2) <= Map.ymin; %Reached Bottom 581 if rad2deg(Position.UAV 1(3)) <= 180 582 Position.UAV 1(3) = deg2rad(180) - Position.UAV 1 ,! (3); 583 else 584 Position.UAV 1(3) = deg2rad(360) - Position.UAV 1 ,! (3); 585 end 586 end 587 588 end 589 102
  • 105. 590 end 591 end 592 end 593 594 %% Drone 2 595 function UAV2(index) 596 global MySearch 597 global Genetics 598 global Position 599 Drone Number = 2; 600 %Initial UAV Position entered as cartesian coordinates (X, Y, ,! Orientation(Deg) 601 602 % UAV Genetics 603 Speed = Genetics.Speed(2); %m/s % this will be fast or slow 604 Altitude = Genetics.Altitude(2); %m need to make it hight or low 605 if Genetics.Search Type(2) == 1 606 Movement UAV 2(Speed, index); 607 end 608 Radius = SensorRadius(Altitude); % Runs a function that returns the ,! sensors search area 609 [xp, yp] = Circle(Radius); 610 Distance = UAV2Lost(Position.UAV 2); %returns the distance between the ,! UAV and lost object 611 Detected(Distance, Radius, Drone Number, Altitude, Speed); 612 613 614 set(MySearch.UAV2.Pos, 'xdata', Position.UAV 2(1), 'ydata', Position. ,! UAV 2(2)); 103
  • 106. 615 set(MySearch.UAV2.Circle, 'xdata', Position.UAV 2(1) + xp, 'ydata', ,! Position.UAV 2(2) + yp); 616 end 617 function Movement UAV 2(Speed, index) 618 global LengthSearch 619 global Position 620 L = 1; 621 dt = 0.01; 622 Alpha = 0; 623 624 x2 = zeros(3, LengthSearch); 625 BouneOffEdges 2() 626 x2(:,index) = [Position.UAV 2(1); Position.UAV 2(2); Position.UAV 2(3) ,! ]; 627 628 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index)); 629 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index)); 630 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha); 631 632 Position.UAV 2 = x2(:, index+1); 633 end 634 function BouneOffEdges 2() 635 global Position 636 global Map 637 638 if Position.UAV 2(1) <= Map.xmin % Reached Left 639 if rad2deg(Position.UAV 2(3)) <= 180 640 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2(3); 641 else 104
  • 107. 642 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2(3); 643 end 644 645 else if Position.UAV 2(2) >= Map.ymax; %Reached Top 646 if rad2deg(Position.UAV 2(3)) <= 180 647 Position.UAV 2(3) = deg2rad(360) - Position.UAV 2(3); 648 else 649 Position.UAV 2(3) = Position.UAV 2(3) + deg2rad(180); 650 end 651 652 else if Position.UAV 2(1) >= Map.xmax; %Reached Right 653 if rad2deg(Position.UAV 2(3)) <= 180 654 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2(3); 655 else 656 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2(3); 657 end 658 659 else if Position.UAV 2(2) <= Map.ymin; %Reached Bottom 660 if rad2deg(Position.UAV 2(3)) <= 180 661 Position.UAV 2(3) = deg2rad(180) - Position.UAV 2 ,! (3); 662 else 663 Position.UAV 2(3) = deg2rad(360) - Position.UAV 2 ,! (3); 664 end 665 end 666 667 end 668 105
  • 108. 669 end 670 end 671 end 672 673 %% Drone 3 674 function UAV3(index) 675 global MySearch 676 global Genetics 677 global Position 678 Drone Number = 3; 679 %Initial UAV Position entered as cartesian coordinates (X, Y, ,! Orientation(Deg) 680 681 % UAV Genetics 682 Speed = Genetics.Speed(3); %m/s % this will be fast or slow 683 Altitude = Genetics.Altitude(3); %m need to make it hight or low 684 if Genetics.Search Type(3) == 1 685 Movement UAV 3(Speed, index); 686 end 687 Radius = SensorRadius(Altitude); % Runs a function that returns the ,! sensors search area 688 [xp, yp] = Circle(Radius); 689 Distance = UAV2Lost(Position.UAV 3); %returns the distance between the ,! UAV and lost object 690 Detected(Distance, Radius, Drone Number, Altitude, Speed); 691 692 693 set(MySearch.UAV3.Pos, 'xdata', Position.UAV 3(1), 'ydata', Position. ,! UAV 3(2)); 106
  • 109. 694 set(MySearch.UAV3.Circle, 'xdata', Position.UAV 3(1) + xp, 'ydata', ,! Position.UAV 3(2) + yp); 695 end 696 function Movement UAV 3(Speed, index) 697 global LengthSearch 698 global Position 699 L = 1; 700 dt = 0.01; 701 Alpha = 0; 702 703 x2 = zeros(3, LengthSearch); 704 BouneOffEdges 3() 705 x2(:,index) = [Position.UAV 3(1); Position.UAV 3(2); Position.UAV 3(3) ,! ]; 706 707 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index)); 708 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index)); 709 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha); 710 711 Position.UAV 3 = x2(:, index+1); 712 end 713 function BouneOffEdges 3() 714 global Position 715 global Map 716 717 if Position.UAV 3(1) <= Map.xmin % Reached Left 718 if rad2deg(Position.UAV 3(3)) <= 180 719 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3(3); 720 else 107
  • 110. 721 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3(3); 722 end 723 724 else if Position.UAV 3(2) >= Map.ymax; %Reached Top 725 if rad2deg(Position.UAV 3(3)) <= 180 726 Position.UAV 3(3) = deg2rad(360) - Position.UAV 3(3); 727 else 728 Position.UAV 3(3) = Position.UAV 3(3) + deg2rad(180); 729 end 730 731 else if Position.UAV 3(1) >= Map.xmax; %Reached Right 732 if rad2deg(Position.UAV 3(3)) <= 180 733 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3(3); 734 else 735 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3(3); 736 end 737 738 else if Position.UAV 3(2) <= Map.ymin; %Reached Bottom 739 if rad2deg(Position.UAV 3(3)) <= 180 740 Position.UAV 3(3) = deg2rad(180) - Position.UAV 3 ,! (3); 741 else 742 Position.UAV 3(3) = deg2rad(360) - Position.UAV 3 ,! (3); 743 end 744 end 745 746 end 747 108
  • 111. 748 end 749 end 750 end 751 752 %% Drone 4 753 function UAV4(index) 754 global MySearch 755 global Genetics 756 global Position 757 Drone Number = 4; 758 %Initial UAV Position entered as cartesian coordinates (X, Y, ,! Orientation(Deg) 759 760 % UAV Genetics 761 Speed = Genetics.Speed(4); %m/s % this will be fast or slow 762 Altitude = Genetics.Altitude(4); %m need to make it hight or low 763 if Genetics.Search Type(4) == 1 764 Movement UAV 4(Speed, index); 765 end 766 Radius = SensorRadius(Altitude); % Runs a function that returns the ,! sensors search area 767 [xp, yp] = Circle(Radius); 768 Distance = UAV2Lost(Position.UAV 4); %returns the distance between the ,! UAV and lost object 769 Detected(Distance, Radius, Drone Number, Altitude, Speed); 770 771 772 set(MySearch.UAV4.Pos, 'xdata', Position.UAV 4(1), 'ydata', Position. ,! UAV 4(2)); 109
  • 112. 773 set(MySearch.UAV4.Circle, 'xdata', Position.UAV 4(1) + xp, 'ydata', ,! Position.UAV 4(2) + yp); 774 end 775 function Movement UAV 4(Speed, index) 776 global LengthSearch 777 global Position 778 L = 1; 779 dt = 0.01; 780 Alpha = 0; 781 782 x2 = zeros(3, LengthSearch); 783 BouneOffEdges 4() 784 x2(:,index) = [Position.UAV 4(1); Position.UAV 4(2); Position.UAV 4(3) ,! ]; 785 786 x2(1,index +1) = x2(1, index) + dt * Speed * cos(x2(3, index)); 787 x2(2,index +1) = x2(2, index) + dt * Speed * sin(x2(3, index)); 788 x2(3,index +1) = x2(3, index) + dt * (Speed/L) * tan(Alpha); 789 790 Position.UAV 4 = x2(:, index+1); 791 end 792 function BouneOffEdges 4() 793 global Position 794 global Map 795 796 if Position.UAV 4(1) <= Map.xmin % Reached Left 797 if rad2deg(Position.UAV 4(3)) <= 180 798 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4(3); 799 else 110
  • 113. 800 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4(3); 801 end 802 803 else if Position.UAV 4(2) >= Map.ymax; %Reached Top 804 if rad2deg(Position.UAV 4(3)) <= 180 805 Position.UAV 4(3) = deg2rad(360) - Position.UAV 4(3); 806 else 807 Position.UAV 4(3) = Position.UAV 4(3) + deg2rad(180); 808 end 809 810 else if Position.UAV 4(1) >= Map.xmax; %Reached Right 811 if rad2deg(Position.UAV 4(3)) <= 180 812 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4(3); 813 else 814 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4(3); 815 end 816 817 else if Position.UAV 4(2) <= Map.ymin; %Reached Bottom 818 if rad2deg(Position.UAV 4(3)) <= 180 819 Position.UAV 4(3) = deg2rad(180) - Position.UAV 4 ,! (3); 820 else 821 Position.UAV 4(3) = deg2rad(360) - Position.UAV 4 ,! (3); 822 end 823 end 824 825 end 826 111
  • 114. 827 end 828 end 829 end 830 831 %% Drone 5 832 function UAV5(index) 833 global MySearch 834 global Genetics 835 global Position 836 Drone Number = 5; 837 %Initial UAV Position entered as cartesian coordinates (X, Y, ,! Orientation(Deg) 838 839 % UAV Genetics 840 Speed = Genetics.Speed(Drone Number); %m/s % this will be fast or slow 841 Altitude = Genetics.Altitude(Drone Number); %m need to make it hight ,! or low 842 if Genetics.Search Type(Drone Number) == 1 843 Movement UAV 5(Speed, index); 844 end 845 Radius = SensorRadius(Altitude); % Runs a function that returns the ,! sensors search area 846 [xp, yp] = Circle(Radius); 847 Distance = UAV2Lost(Position.UAV 5); %returns the distance between the ,! UAV and lost object 848 Detected(Distance, Radius, Drone Number, Altitude, Speed); 849 850 112