Friday, February 26, 2010

Speciation and the evolution simulation...

I've been recoding the evolution simulation which Bahar and Nate developed in Matlab.  I have never programmed something so complicated.  I have also never really TRULY programmed anything in C++, ie used classes and the standard library and other pre-made classes effectively.  It has taken me several weeks to get to the point of piecing my various classes together and writing out a speciation algorithm.  I have also had a tough time dealing with the standard library class, vectors.  I think I have gotten to the point where I can use them efficiently.  Here's the break down of what I need this program to do:
I need to initialize some parameters in order to create the simulation.  Those parameters first help build a fitness landscape which represents locations where an environment benefits some phenotypes more than others.  The landscape axes represent a continuous scale of phenotypes; the area then represents a phenospace which the landscape then corresponds to.  Think of a flat map as being the phenospace; your latitude and longitude determine your location in that phenospace.  Mountainous regions represent areas which the environment would be most beneficial and the ocean trenches would be regions of poor fitness.  
The next part of the simulation is to build an initial population.  The population is a set of indivs which are initialized with some default data characteristics.  Now the main part of the program is ready.  
The primary section of the program is a for loop which iterates the generations.   Within each generation, several events occur.  The first is to find and record the identities of the two nearest indivs in phenospace for each indiv in the population.  The next step is to determine, based on each of indiv's neighbors, which indiv's are in the same species.  The speciation algorithm is based partly on a reproductive isolation model which states (in real life) that if no offspring can be conceived by two possible varieties of an organism, then those two possible varieties are actually different species.  However, our model extends this to include the second nearest neighbor as well - an assumption "dreamt" up by Nate to avoid numerous two indiv sized species.  This also indicates that different organisms don't necessarily be "close" to each other phenotypically.  Other speciation algorithms are certainly possible to implement; it would just require my time to write out such algorithms.
The next section of the program then records the information about the species and the indiv's.  One important aspect of the indiv's is their mutation rate.  The mutation rate determines how much variability their children may have about some range determined by the distance between the two mates.  This parameter is the primary value which we tweak or distribute differently among the indiv's.  As each indiv mates with their nearest neighbor, the "choosing" indiv then passes on it's mutation rate to the babies it makes.  The number of babies depends on the fitness of the "choosing" indiv parent.
The mating portion takes place after recording the population and species information.  The baby indiv's make up a new population for the next generation iteration.
Once the baby population is made, the parents are no longer needed, so their population is deleted.  Now the baby indiv population is weeded out by several death functions.  There are three ways in which the new indiv's are killed off.  One method is by an overpopulation limit.  This models organisms niche in their environment.  Particular organisms occupy important niches and tend not to share a niche with other organisms.  Therefore no indiv's may exist within a certain distance of each other in the phenospace.  We refer to this distance as the overpopulation limit.  The next killing method is random death.  This simply kills off indivs at random by determining what percentage (up to a small percentage) of the population will "win" a lottery.  The final killing that takes place is of those indivs which have sprung up outside of the phenospace limits.  This simply models a limit to our phenospace.
After the destruction of the selected indivs, the resulting population then cycles back to the beginning of the generation loop.  And the circle of life continues until either the population dies out or the program reaches the maximum number of generations that we have defined at the beginning in the parameters.
Adam D Scott

Thursday, January 28, 2010

post script

I passed my doctorate qualifier earlier this month. I'm official.

Ubiquity Ch 1-3

I began reading Ubiquity by Mark Buchanan.  My advisor suggested it to me Tuesday when we had our weekly meeting.  I've read through the third chapter and am completely entranced by it.  I tend to fall asleep reading most books or articles, but this book has engaged me greatly.
The book has covered two simple games thus far.  The first is the sand pile game.  Set a rate to drop granules of sand in a pile.  As the sand falls, avalanches of various sizes will occur.  The avalanches occur only if a threshold of instability is introduced by a single new grain.  These regions where this instability exists are called fingers of instability.  The resulting distribution of avalanches follows a power law (log(# of avalanches) v log(size of avalanche) gives a linear distribution...the slope of which determines the power).  The power law suggests there is no typical size of avalanche as would a bell/normal/Gaussian distribution suggests, for example.  This game was introduced by Per Bak, Chao Tang, and Kurt Weisenfeld, although it seems Bak delved much deeper into this than the others from what I gather from Buchanan.
The other game discussed is a game modeling earthquakes.  The game was originally introduced in 1967 by Burridge and Knopoff.  They used a physical model with a setup in one dimension, but didn't find what they were probably hoping for.  Bak and Tang rekindled the idea in 1989 but used a computer simulation in two dimensions.  The game is set up with a ceiling that is allowed to drift.  Connected to the ceiling are rods which are also connected to blocks on a floor.  Between the blocks are springs to connect one block with four neighbors.  The game is then set in motion by drifting the ceiling, as the ceiling moves, the rods bend.  When a rod reaches its limit, the connected block moves one unit.  The springs connected to that block then shift the neighboring blocks by one fourth a unit.  Bak and Tang found this to follow a power law, suggested it described earthquake sizes as being unpredictable, and were excited to show that this game was identical in nature to the sand pile game.  However, others pointed out their model was conservative, unlike real earthquakes which do not transfer all energy into motion.  Instead, some energy is lost in heating the rocks, not moving them.  In 1992 a few other scientists, Olami, Feder, and Christensen redid the Bak and Tang model, but allowed for dissipation of energy.  Their game resulted in matching data from a 1950's study by Gutenburg and Richter in which they found that real earthquakes follow a power law distribution.  Earthquakes have no typical scale since the distribution of earthquake intensity and number of those earthquakes follow a power law distribution, and this is matched by both games.
The next chapters should go into financial markets, wars, and other awesome world events.  I can't wait.
Adam D Scott

Tuesday, November 3, 2009

Sand Dollar Success!

I apparently wrote this back at the end of May, but never uploaded it here...
 
I figured out what was wrong with my program.  There were two things:
1.  I needed to use the output as the new input, instead of sending a set of predetermined points through the function to generate output.
2.  I was taking the square root of a number that shouldn't

Thursday, October 29, 2009

Morphospace

Consider a space in which two traits are mapped in a plane.  These two traits could be any description of an organism.  In an environment certain combinations of the traits will allow an organism to make better use of the environments resources.  Now consider a resource landscape mapped onto the same plane as the trait space.  Trait coordinates on areas of higher points in the resource landscape correspond to the ability of those organisms in the area being better able to reproduce, because they are better at using the resources given by the environment.  These areas may allow the organisms to have more offspring.  Lower areas in the landscape mean that the trait coordinates over the area are less apt to reproduce, because the resources in the environment are not as well suited for those organisms.  These areas reduce the chance the organisms have to reproduce, thus birth rates can be lower.
Each organism has associated with them, a mutation parameter we call 'birth noise'.  The birth noise of an organism determines an area around it and it's mate (mates are chosen as the nearest neighbor in trait space) in the trait space in which their offspring may appear.  This is to model the variation in traits of offspring from their parents.  The birth noise of the choosing parent then passes it's birth noise on to the offspring, modeling the inheritance of genetic information.
 
There's more about death and other details, but I needed to attempt to describe these two topics.
--
Adam D Scott

Thursday, July 23, 2009

Student Answers Exp 5 1012

Q:  Explain how the earth's magnetic field could affect your results when measuring magnetic field directions around a DC wire.  Based only on your data, can you tell what side of the laboratory is facing (magnetic) north?
 
"The earth's magnetic field could possibly interfere with the needle of the compose by detecting the magnetic field produced from the current in the wire to the magnetic field that indicates north on earth.
The direction of the compass and the magnetic field of the earth is pointing to the back of the lab toward the door by the magnetic field earth actin on the  force this is the result of the sum of the vectors from the earth."

--
Adam D Scott

Wednesday, July 22, 2009

Student answers: Exp 6 1012

"Since the equation ... decreases as the capacitor increases, we know that the current will be less for the larger capacitor."
First of all, equations don't change; values in them may.  Capacitors don't change in the experiment they did; the charge stored on the capacitor is what changes.  The current only decreases at a slower rate for a larger capacitor; it's initial and final value has no bearing on what capacitor one uses, though.

"Another error is due to the fact that the timer is pretty quick and we are either getting the measurement a bit too early or a bit too late..."
Makes timers counting off seconds are too fast...but they count seconds, so seconds must be too fast...so life is too short?

--
Adam D Scott