Monday, March 28, 2011

Thoughts - Bottom Up AI

Overview

The field of artificial intelligence in computer science focuses on many
different areas of computing from computer vision to natural language
processing. These top-down approaches typically concentrate on human behavior
or other animal functions. In this article we look at a bottom-up approach to
artificial life and how emergent cell behavior can produce interesting results.
With this bottom-up alife approach, we are not interested in solving any
particular task, but we are interested in observing the adaptive nature of the
entities in our simulation. We also wanted to introduce those more familiar with
software engineering to biological systems and evolutionary theory concepts.

Life is all around us. Even with inorganic material it is possible that
microscopic organisms are covering that surface. Moving forward if we want to
study, analyze and work with artificial agents, we might consider systems that
have evolved behavior over a series of steps. We should not necessarily build a
specific tool with a specific purpose but the creature that is built from the
system may produce interesting properties which are unlike the clean-room
created software that we create today. Most software and hardware today is
written to specification, line for line, most code written for today's systems
are created by man. That software is designed, coded and tested. It would be
interesting if we could start a biological like system and interesting behavior
from the system evolves over time.

When studying life, it also makes sense to go all the back to pre-life on earth
and the creation of this planet. When you look across the globe, there are
millions of species, a lot of life out there. All of that life occurred from
mutations, replications, chaotic collisions with other organisms. What is
organic life? compared to inorganic life? Life evolves, minute after minute,
day after day, year after year for millions of years across a vast planet.
Inorganic matter interacts with organic matter and from within that very complex
system, complex behavior emerges. When you look at computing systems, every
piece of software, most software was created by some person. Every line of
code, every machine instruction is mostly known to the developer or the hardware
manufacturers. The intelligent designer in this case are teams of intelligent
software and computer engineer building complex machines to act as a tool for
some purpose. Some application.

Human beings and other animals have complex machinery embedded in them. Animals
have eyes, ears. Human beings have the neocortex that allows us to predict
events that may occur in the future based on past memories. But all of these
tools that animals use to survive evolved over time. Iteration after iteration
of successes and failures. The human brain has a purpose in the context of
human survival just like the eyes and ears have a purpose. But do human beings
have a purpose? Computers have a purpose. Smart phones are tools that have a
purpose.

With software, we add all of that complex behavior. Human beings posses amazing
skills and we use our brains to adapt to the environment. All of that behavior
and response to the world around us was created by millions of years of
mammalian evolution. We are autonomous beings. All of that behavior created by
seemingly random events over time. The machinery that makes up the human being
just happen to have happened. That is a powerful thought. If we can understand
parts of that evolutionary process, maybe we can model some of of those events
through computer simulations and also generate complex behavior. Imagine if we
could instantly absolute control over the evolutionary process. Imagine if we
could remove an animals brain or ears or eyes so that future generations don't
have those functions. That animal would be helpless and couldn't function but
it just happens that they do have those capabilities and can survive as long as
their abilities allow them to. Imagine if this force could remove your brain so
that future generations of humans didn't have a brain. Or we removed the
ability to walk, see or hear. Once again, we would be helpless and human
progress would halt that instance. The evolutionary process is a complex one but
all of the creatures of the earth that have survived up to this point all posses
skills that allow them to survive. The tools given them given them through that
process.

Basic Biology Concepts

Human beings may have 100 trillion cells. There are several hundred distinct
human cell types.

The most basic cells may have a cell wall, chromosomes, plasma membrane,
fibrils, ribosomes.

DNA is the blue print for life of a cell. It mostly static, mutations may be
introduced. DNA contains the instructions for a cell's structure and function.
It is the blueprint for how the cell runs, reproduces, builds and repairs
itself, and every other function necessary for cell life. Metabolism is a
chemical reaction

A protein is a generic term for anything that is made of amino acids. Proteins
are considered the "cellular machinery"; they are constantly being synthesized,
and play many essential structural and enzymatic roles within the cell. How
does a cell die? Proteisn sythensis may be interrupted. Protein synthesis uses
about 75 percent of a cell'ss energy. Protein is a macromolceule Macromolecules
that make up cell material

Bacterial cells can change patterns of enzymes, in order to adapt them to their
specific environment.

With traits, in order to show-up, a dominant trait needs only one trait unit
from one of the parents, and the recessive one needs two, from both parents, in
order to prevail, that is the reason why the ratio between occurrences of
dominant traits and recessive traits is. The same explanation applies to the
shape traits.

keywords: earth, biosphere, inorganic vs organic material, water, DNA,
mutations, replication, simple organisms, more complex organisms, animals, human
beings, life, death, mutations, evolution, blind watchmaker, mitochrondria,
flagella, pili, cell walls, cytoplasmic membranes, ribosomes, cytoplasm.

Introduction to Artificial Life

Conway's Game of Life cellular automaton is one of the most prominent examples
of cellular automata theory. The one dimensional program consists of a cell grid
typically with several dozen or more rows and similar number of columns. Each
cell on the grid has an on or off Boolean state. Every cell on the grid survives
or dies to the next generation depending on the game of life rules. If there are
too many neighbors surrounding a cell then the cell dies due to overcrowding. If
there is only one neighbor cell, the base cell dies due to under-population.
Activity on a particular cell is not interesting but when you run the entire
system for many generations, a group of patterns begin to form.

You may notice some common patterns in the figure. After so many iterations
through the game of life rules, only a few cells tend to stay alive. We started
with a large random number of alive cells and over time those cells died off. In
a controlled environment you may begin with carefully placed live cells and
monitor the patterns that emerge to model some other natural phenomena.

The name Stephan Wolfram has been mentioned several times in this post. He is
the founder of Wolfram|Research, his company is known for the popular
Mathematica software suite and Wolfram|Alpha knowledge engine. He did not
initially discover cellular automata but recently he has been a prominent figure
in its advocacy. He spent 10 years working on his book, A New Kind of Science.
In the 1300 page tome, he discusses how cellular automata can be applied to
every field of science from biology to physics. NKA is a detailed study of
cellular automata programs.

The diagram above depicts the rule 30 program (or rule 30 elementary cellular
automaton). There are 8 input states (2 ^ 3) and an output state of one or zero.
If you look at the diagram from left to right. The first sequence of blocks on
the left depict an input state of { 1 1 1 } with an output of 0. Given input of
cells { 1 1 1}, the output will be set to 0. Subsequently, the next set of
blocks consist of an input state of { 1 1 0 } with an output of 0.

Artificial Life Object Model

Here is a basic model for simulating basic cell life using a bottom-up
approach. I will look at modeling basic cells. Adding DNA. The cells survive and die in a
primordial pool of water, sun. Even with this basic demo, emergent behavior
forms. I hope have made a case that organic life is interesting. The machinery
has already been created but we don't have a easy blueprint to recreate such complex
life, we can only use knowledge base to model as much as we can.

Here is a model for DNA. Game of Life, Cell Grid. 2D visual simulation, cells,
grid, iterations or cell game cycles, cell entities, bacteria.

The most basic units in the life simulation consist of Chemical Life Elements.
This enumeration contain the element types. The element types are closely tied
to the proteins on the grid but in reality they are synonymous with chemical
life elements like Carbon, Oxygen, etc.

Each grid in the life simulation consists of a chemical element unit. The
element unit contains an element level or weight. The elements react with other
elements.

The DNA represents the CODE in this simulation. We will decode the DNA code for
protein synthesis.

For the bacteria cell, DNA can effect:

Size, weight, energy level, color, reproduction rate, food consumption rate,
ability to handle water, sunlight/temperatures.

All forms of algae are composed of eukaryotic cells but for our demo, we are
treating Food/Algae as a type of non organic entity. But the cells in our
system feed on this non organic form of algae.

When constructing the object model for this DNA simulation, I wanted to focus
three key components, the DNA, mutations, cell properties or traits. But also,
there is some validation given to the water and the sunlight. These attributes
don't effect the system as much but are part of the environment.

import org.berlin2.bottomuplife.ui.BaseUIComponents._
import BaseLifeComponents._
import java.awt.{ Image, Color, Dimension, Graphics, Graphics2D, Point, geom }
import LifeSimulation._

import org.berlin2.bottomuplife.ui.RenderSimulation
import BaseLifeComponents._
import org.berlin2.bottomuplife.code.DNATranslationParser
import org.berlin2.bottomuplife.life.TraitToSystem._
/**
* Living bacteria cell, single celled organism.
*/
class Bacteria(size:Int, pos:GridPos) extends BaseLifeComponents.LifeEntity(size, pos) with BaseLifeComponents.SingleCellLivingEntity {
def deadSize = 6
private val dna = initDNA
private var bactericaAliveState = true
private var mutableSize = size
/**
* Process chemical reactions with water.
* @param water
*/
def chemicalReactionWithWater(water:Water) : Unit = {
chanceMutationForBlue = chanceMutationForBlue * 1.0007
for (element <- elementUnits) {
element.elementWeightLevel = element.elementWeightLevel * (1.0 - decayFactorForBacteriaFromWater)
}
}
}
/**
* Base Life simulation classes and objects.
*/
object BaseLifeComponents {
/**
* The most basic units in the life simulation consist of
* Chemical Life Elements. This enumeration contain the element types.
* The element types are closely tied to the proteins on the grid
* but in reality they are synonymous with chemical life elements like Carbon, Oxygen, etc.
*/
object Element extends Enumeration {
type Element = Value
val BacteriaWallProteinElement, WaterElement, SunLightEnergy, AlgaeFoodElement = Value
} // End of object
import Element._
type ElementType = Element

/**
* Interface living and non-living types.
*/
trait NonLivingEntity
trait LivingEntityCell {
def getName : String
def getDNA : DNA
def alive : Boolean
def processDNA() : Unit
def produceProteins() : Unit
def onStepSimulationProcessCell() : Unit
def getMutableSize : Int
def setImmutableSystemTraits : Unit
def onStepSetSystemTraits : Unit
/**
* Metabolic reaction and process to convert energy.
* In our system, amount of energy for this cell.
*/
def getCellularRespirationEnergyLevel : Double
def hasConsumeForReplication : Boolean
/**
* If child available, consume and add to core list.
*/
def consumeChildCellReplication : LivingEntityCell
def onInitializeReplicate(cell:LivingEntityCell) : Unit
def mutateDNAOnReplication(targetCell:LivingEntityCell) : DNA
}
trait SingleCellLivingEntity extends LivingEntityCell
trait MultiCellLivingEntity extends LivingEntityCell

/**
* Basic properties for a life agent.
* All entities for the life simulation are life agent entities.
*/
trait LifeAgent {
def setElementPositions : Unit
def sizeElements : Int
def onInitialize : Unit
def chemicalReactionWithSun(sun:SunLight) : Unit
def chemicalReactionWithWater(water:Water) : Unit
def chemicalReactions(sim:SimulationObjects) : Unit
}

/**
* Each grid in the life simulation consists of a chemical element unit.
* The element unit contains an element level or weight. The elements
* react with other elements.
*/
class ChemicalElementUnit(val initElementLevel:Double, val elementType:ElementType, val gridPos:GridPos) {
var elementWeightLevel = initElementLevel
var color:java.awt.Color = java.awt.Color.gray
}
/**
* Model DNA bases, Adenine, Cytosine, Guanine, Thymine.
*/
object DNABase1 {
def A = 1
def G = 2
def C = 3
def T = 4
def a = 1
def g = 2
def c = 3
def t = 4
}
type DNABase = Int
/**
* The DNA Word tuple consists of 4 ints/digits.
* The highest value of the left most outer digit could be represented by: 4 * pow(4, 3) or 4 * (4 ^ 3).
*/
type DNAWord = (DNABase, DNABase, DNABase, DNABase)
type Gene4 = DNAWord
} // End of Object


Summary

Moving forward if we want to study, analyze and work with artificial agents, we
might consider systems that have evolved behavior over a series of steps. We
might not build a specific tool with a specific purpose but the creature that is
built from the system may produce interesting properties which are unlike the
clean-room created software that we create today.

With this artificial life approach, but we also want to study the simple life
forms first before moving too fast forward like human behavior.

No comments:

Post a Comment