19
Bioinspired Computing BEAST & Bacteria Overview David Gordon [email protected]

Bioinspired Computing BEAST & Bacteria Overview David Gordon [email protected]

Embed Size (px)

Citation preview

Page 1: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

Bioinspired Computing

BEAST & Bacteria Overview

David Gordon

[email protected]

Page 2: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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)

Page 3: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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

Page 4: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

How beast is organisedWorld

2D arena where assessments go on

Simulation

PopulationAs Group, but uses a

GA on its contents

GroupPuts WorldObjects and Animats into Simulation

GeneticAlgorithm

MiceSimulation,ShrewSimulation

WorldObject

Animat

Cheeses, Dots,Targets…

Shrews, Mice…

(Evo)FFNAnimat,(Evo)DNNAnimat

Braitenbergs

Evolver

FeedForwardNet, DynamicalNet

Built-in classes

Custom classes

Built-in classes you may never see

AB

A is used by B

A

BA inherits from B

Page 5: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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.

Page 6: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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

Page 7: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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

Page 8: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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

Page 9: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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• 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

Distribution

EvoBacterium

Animat

WorldObject

Bacterium

Page 10: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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)

Page 11: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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

Page 12: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

What Bacterium does 3

• Reproduces

• Dies

Page 13: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

What Distribution does• Every frame, everything becomes a little more

blurred/diffuse• Diffusion speed can be changed in two ways –

see code for details

Page 14: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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

Page 15: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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…

Page 16: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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?

Page 17: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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

Page 18: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

Pretty pictures

• Nutrient, attractant, repellent and trail distributions can be any colour (in comments)

• World can be any colour (also in comments)

• Save using import <filename.jpg>

Page 19: Bioinspired Computing BEAST & Bacteria Overview David Gordon aixdg@comp.leeds.ac.uk

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)