Bioinspired Computing BEAST Overview

Download Report

Transcript Bioinspired Computing BEAST Overview

Bioinspired Computing
BEAST & Bacteria Overview
David Gordon
[email protected]
Excuses first
• ‘Work in progress’ – loose ends, e.g. easy to
crash the interface
• Some features are untested (none of them
necessary for coursework)
• Documentation is a first draft
• (Almost) never been used by
students (other than me)
Technologies,
concepts & paradigms
• C++
• Object-Oriented Programming (OOP)
– Encapsulation
– Multiple inheritance
– Polymorphism
•
•
•
•
•
Event-driven architectures
Templates (generic programming)
Standard Template Library (STL)
Ironically, the aim of all this is to make it easy…
You don’t need to know about the above (except
C++) but if you do it’ll help
How beast is organised
World
Simulation
2D arena where
assessments go on
WorldObject
MiceSimulation,
ShrewSimulation
Animat
Group
Braitenbergs
Puts WorldObjects and
Animats into Simulation
Evolver
(Evo)FFNAnimat,
(Evo)DNNAnimat
Population
FeedForwardNet,
DynamicalNet
Shrews,
Mice…
Cheeses, Dots,
Targets…
As Group, but uses a
GA on its contents
GeneticAlgorithm
B
A is used
by B
A
A inherits
from B
A
B
Built-in classes
Built-in classes you
may never see
Custom classes
The Simulation class
• Simulations are set up by inheriting from Simulation, adding
Groups of WorldObjects (i.e. Cheeses), Populations of
Animats (i.e. Mice), and one or more GAs.
• Initialisation – persistent objects are set up, parameters for the
GA, the number of Animats, the objects in the World etc.
• Simulation is responsible for
– Putting objects (Mice, Cheeses) into World
– Letting them buzz around (e.g. collecting cheese) for a number of
timesteps
– Taking them out again and putting them through the GA
– Repeating for a number of generations
• The Simulation object is like a lab technician, who sets up the
simulation, then sits up all night repositioning robots and rerunning
assessments until the simulation is complete.
Developing with beast
• Documentation at
http://www.comp.leeds.ac.uk/ar23/BEAST/doc/
• Tutorials, example code
• Ask in newsgroups
• C++ problems – use http://groups.google.com
• Problems: executables large, compile times slow
– AR23 students now have extra space
– Remove –O3 from Makefile until you’re ready to run
– Compile on cslin-gps (don’t run on it though!)
• CPU limit
– limit cputime unlimited – add to .cshrc
The bacteria model
• The bacteria are
based on a complex
mathematical model
• The BEAST
implementation is a
faithful reproduction
of the mathematical
model (sort of…)
• To use it, you don’t
need to know the
details of either
Getting started
• New stuff is now available – download
BEAST_project.tar.gz as before
• ‘baccyexamples’ – demonstrate how
bacteria move, swarm, use repellents,
reproduce and use attractants
• ‘bacteria’ – source code for Q3 of
coursework
Two new classes
• Distribution
– 2D grid which covers the World
– Models nutrients, chemoattractants and
chemorepellents in a solution
– Implements diffusion, so distribution ‘dissolves’
over time
WorldObject
Distribution
• Bacterium
– Models groups of bacteria
– Direction of movement depends on gradients
detected in nutrient, attractant and repellent
distributions
– Can reproduce, swarm, sporulate and die
– Properties are controlled by a big list of
variables
– Full description in bacteria.h or look in
documentation
Animat
Bacterium
EvoBacterium
What Bacterium does 1
• Eact timestep, each
Bacterium absorbs
some nutrient (if
available) from its
surroundings, and
converts it into energy
• Then takes a look
around:
– Looks at the nutrient
distribution and the
repellent/attractant
distributions (if available)
– Looks at the other bacteria
around it (depending on its
swarmRadius)
What Bacterium does 2
• Moves a little in a direction
determined by the above
information and a bunch of
variables set within
Bacterium
• When bacteria move or die,
they leave a dot on another
distribution object, called
trail
• If the Bacterium is in a
place with plenty of nutrient,
it might release attractant
• If there is not enough
nutrient, it might release
repellent
What Bacterium does 3
• Reproduces
• Dies
What Distribution does
• Every frame, everything becomes a little more
blurred/diffuse
• Diffusion speed can be changed in two ways –
see code for details
Working with EvoBacterium
• Same as Bacterium, but with additional
GetGenotype, SetGenotype and
GetFitness functions for the GA
• Most stuff is commented out, so it
basically doesn’t work
How to do the coursework
• Disable/enable
features (detailed in
comments)
• Muck about with
variables (speed,
amount of nutrient,
reproduction rate)
• Use a Genetic
Algorithm…
How to create a fitness function
• GetFitness()
• Examples are in the code
• Possible metrics:
–
–
–
–
–
Number of offspring
Area covered
Distance from start
Amount of food eaten
Fractal dimension?
• Fitness function does not
have to match real bacteria
– Could an ‘artificial’ fitness function
produce better results than a realistic
one?
Note: two sorts of reproduction
• Bacteria reproduce during the assessment
– Offspring are identical, no mutation goes on
• A Genetic Algorithm will work on a
population of bacteria between
assessments
– Reproduction and evolution quite different to
actual bacterial evolution – e.g. crossover not
present in asexual species
– Fitness function can be anything you like
Pretty pictures
• World can be any colour (also in comments)
• Nutrient,
attractant,
repellent and
trail
distributions
can be any
colour (in
comments)
• Save using import <filename.jpg>
Later this week…
• Demonstration session Wednesday 1pm
• Instructions for batch (coming up in
newsgroup)
• Arrangements for computer availability
over Easter (also coming up in
newsgroup)