Genetic Programming: An Introduction

Slides:



Advertisements
Similar presentations
MATH 224 – Discrete Mathematics
Advertisements

Biologically Inspired AI (mostly GAs). Some Examples of Biologically Inspired Computation Neural networks Evolutionary computation (e.g., genetic algorithms)
Genetic Programming 김용덕 Page 2 Contents What is Genetic Programming? Difference between GP and GA Flowchart for GP Structures in GP.
A new crossover technique in Genetic Programming Janet Clegg Intelligent Systems Group Electronics Department.
Doug Downey, adapted from Bryan Pardo, Machine Learning EECS 349 Machine Learning Genetic Programming.
Intro to AI Genetic Algorithm Ruth Bergman Fall 2002.
16 November, 2005 Statistics in HEP, Manchester 1.
Genetic Programming. Agenda What is Genetic Programming? Background/History. Why Genetic Programming? How Genetic Principles are Applied. Examples of.
Khaled Rasheed Computer Science Dept. University of Georgia
Genetic Algorithms Overview Genetic Algorithms: a gentle introduction –What are GAs –How do they work/ Why? –Critical issues Use in Data Mining –GAs.
Genetic Programming.
Slides are based on Negnevitsky, Pearson Education, Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming n Evolution.
Genetic Programming Chapter 6. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing Genetic Programming GP quick overview Developed: USA.
Genetic Algorithm.
Neural and Evolutionary Computing - Lecture 7 1 Evolutionary Programming The origins: L. Fogel (1960) – development of methods which generate automatically.
Genetic Algorithms and Ant Colony Optimisation
Slides are based on Negnevitsky, Pearson Education, Lecture 12 Hybrid intelligent systems: Evolutionary neural networks and fuzzy evolutionary systems.
Evolution Strategies Evolutionary Programming Genetic Programming Michael J. Watts
© Negnevitsky, Pearson Education, Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming Evolution strategies Evolution.
1 Genetic Programming: An Introduction. 2 The Lunacy of Evolving Computer Programs Before we start, consider the general evolutionary algorithm : Randomly.
What is Genetic Programming? Genetic programming is a model of programming which uses the ideas (and some of the terminology) of biological evolution to.
RMIT UNIVERSITY CEC2004Experiments with Explicit For-Loops in GP1 Experiments With Explicit For-Loops in Genetic Programming Vic Ciesielski, Xiang Li {vc,
Introduction to Evolutionary Algorithms Session 4 Jim Smith University of the West of England, UK May/June 2012.
Evolutionary Computation Dean F. Hougen w/ contributions from Pedro Diaz-Gomez & Brent Eskridge Robotics, Evolution, Adaptation, and Learning Laboratory.
G ENETIC P ROGRAMMING Ranga Rodrigo March 17,
1 Genetic Algorithms and Ant Colony Optimisation.
Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis
Chapter 9 Genetic Algorithms.  Based upon biological evolution  Generate successor hypothesis based upon repeated mutations  Acts as a randomized parallel.
Genetic Programming. GP quick overview Developed: USA in the 1990’s Early names: J. Koza Typically applied to: machine learning tasks (prediction, classification…)
Genetic Programming A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing Chapter 6.
Genetic Algorithms. The Basic Genetic Algorithm 1.[Start] Generate random population of n chromosomes (suitable solutions for the problem) 2.[Fitness]
GENETIC PROGRAMMING. THE CHALLENGE "How can computers learn to solve problems without being explicitly programmed? In other words, how can computers be.
Automated discovery in math Machine learning techniques (GP, ILP, etc.) have been successfully applied in science Machine learning techniques (GP, ILP,
Introduction Genetic programming falls into the category of evolutionary algorithms. Genetic algorithms vs. genetic programming. Concept developed by John.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Genetic Programming COSC Ch. F. Eick, Introduction to Genetic Programming GP quick overview Developed: USA in the 1990’s Early names: J. Koza Typically.
John R. Koza [Edited by J. Wiebe] 1. GENETIC PROGRAMMING 2.
John R. Koza [Edited by J. Wiebe] 1. GENETIC PROGRAMMING 2.
Genetic Programming Using Simulated Natural Selection to Automatically Write Programs.
Genetic Programming. What is Genetic Programming? GP for Symbolic Regression Other Representations for GP Example of GP for Knowledge Discovery Outline.
Genetic Algorithms And other approaches for similar applications Optimization Techniques.
March 1, 2016Introduction to Artificial Intelligence Lecture 11: Machine Evolution 1 Let’s look at… Machine Evolution.
 Negnevitsky, Pearson Education, Lecture 12 Hybrid intelligent systems: Evolutionary neural networks and fuzzy evolutionary systems n Introduction.
GP FOR ADAPTIVE MARKETS Jake Pacheco 6/11/2010. The Goal  Produce a system that can create novel quantitative trading strategies for the stock market.
Genetic Programming.
Introduction to Genetic Algorithms
Chapter 14 Genetic Algorithms.
Selected Topics in CI I Genetic Programming Dr. Widodo Budiharto 2014.
Genetic Algorithms.
Evolutionary Algorithms Jim Whitehead
Introduction Genetic programming falls into the category of evolutionary algorithms. Genetic algorithms vs. genetic programming. Concept developed by John.
Evolution Strategies Evolutionary Programming
Evolution strategies and genetic programming
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Machine Learning Evolutionary Algorithm (2)
GENETIC PROGRAMMING BBB4003.
Artificial Intelligence Chapter 4. Machine Evolution
Introduction to Artificial Intelligence Lecture 11: Machine Evolution
Basics of Genetic Algorithms
Artificial Intelligence Chapter 4. Machine Evolution
EE368 Soft Computing Genetic Algorithms.
Boltzmann Machine (BM) (§6.4)
Genetic Programming Chapter 6.
Genetic Programming.
Genetic Programming Chapter 6.
Genetic Programming Chapter 6.
GENETIC PROGRAMMING BBB4003.
Beyond Classical Search
Population Based Metaheuristics
Coevolutionary Automated Software Correction
Presentation transcript:

Genetic Programming: An Introduction

The Lunacy of Evolving Computer Programs Before we start, consider the lunacy of evolving programs. The general evolutionary algorithm goes something like this: Randomly create a population of solutions. Evaluate each solution, giving each a score. Pick the best and reproduce, mutate or crossover with other fit solutions to produce new solutions for the next generation.

The Lunacy of Evolving Computer Programs Now consider what this means in the context of genetic programming: Randomly create a population of programs. Evaluate each program, giving each a score. Pick the best and reproduce, mutate or crossover with other fit programs to produce new programs for the next generation.

The Lunacy of Evolving Computer Programs A randomly generated C program #bjsieldi <dkjsldkfj.?+ nit anim(tin x, rach*vrag[)} { nit x; rof (x = 10; : ) { touch ,? *wha”ts g01nG 0n?@; : ]

The Lunacy of Evolving Computer Programs The argument against evolving programs Randomly created programs have an infinitesimal chance of compiling, let alone doing what you want them to do.. Running a randomly created program will most likely give array out-of bounds errors, data-casting, core-dumps and division by zero errors, and is ultimately prone to the halting problem Mutating and mixing segments of randomly created programs is as senseless as randomly creating them in the first place. (How) does genetic programming get around this?

What makes GP different Variable In general by LISP S-expressions GP Fixed-length strings Coded strings of numbers GA(conventional) Individual Size (complexity) Individual Representation

GP algorithm Create random population Evaluate fitness function Apply evolution genetic operators probabilistically to obtain a new computer program Reproduction/Crossover/Mutation Insert new computer program into new population

The Genetic Programming Representation The trick is to choose an underlying representation for programs such that:the random creation, mutation and crossover of programs always yields a syntactically correct program. The representation employed in genetic-programming is a tree: this representation is natural for LISP programs and leads to elegant algorithms for creation, mutation and crossover.

Genetic Structure Functions: Can be conditional(if, then,etc.), sequentual(+,-,etc.), iterative (whileDo etc.) Terminals: No arguments, just return a value

Evolving Trees In fact the representation is useful for the evolution of more than just LISP programs! The tree structures in a genetic programming population can be used to determine layouts for analogue electric circuits, create neural networks, paralellise computer programs and much much more. It’s a great representation because it can produce solutions of arbitrary size and complexity, as opposed to, for example, fixed-length genetic algorithms. As we’ll be applying an evolutionary algorithm to this representation, we need to define creation, crossover and mutation operators.

Creation, Crossover and Mutation The following gifs by Scott Brave show how tree structures can be created, crossed and mutated. Creation: randomly generate a tree using the functions and terminals provided Crossover: pick crossover points in both parents and swap the subtrees. If the parents are same, the offsprings will often be different. Mutation: pick a mutation point in one parent and replace its sub-tree with a randomly generated tree.

Crossover

Mutation

Population Creation When creating a population, it’d be nice to begin with many trees of different shapes sizes. We can generate trees using the full or the grow method: full - every path in the tree is the maximum length grow - path lengths will vary up to the maximum length. Typically, when a population is created, the “Ramp half-and-half” technique is used.Trees of varying depths from the minimum to maximum depth are created, and for each depth half are created using the full method and the other half are created using the grow method.

Preparatory steps for GP You’ve decided you want to use GP to solve a problem. To set up your GP runs, you need to do the following: Determine the set of terminals (the leaves of your trees). In the programming context, these are usually variables, input values or action commands Determine the set of functions (the nodes of your trees). The fitness measure The parameters for controlling the run: Population size, Maximum number of generations, Mutation, Crossover and Reproduction rates (1%, 90%, 9%) The method for terminating a run and designating a result.

Sufficiency & Closure Function and terminal sets must satisfy the principles of closure and sufficiency: Closure: every function f must be capable of accepting the values of every terminal t from the terminal set and every function f from the function set. Sufficiency: A solution to the problem at hand must exist in the space of programs created from the function set and terminal set. One way to get around closure is to use make all terminals and functions return the same type (for example, integer) or use strongly typed genetic programming to ensure that all expressions are type-safe.

Example: Symbolic Regression Problem: Can GP evolve the function to fit the following data:: x f(x) 0 0 1 4 2 30 3 120 4 340 5 780 6 1554 7 2800 8 4680

GP Symbolic Regression Function Set: +, - *, / Terminal Set: X Fitness Measure: use the absolute difference of the error. Best normalized fitness is 0. Parameters: Population Size = 500, Max Generations = 10, Crossover = 90%, Mutation = 1%, Reproduction = 9%. Selection is by Tournament Selection (size 5), Creation is performed using RAMP_HALF_AND_HALF. Termination Condition: Program with fitness 0 found.

Results The following zero-fitness individual was found after two generations (add (add (mul (mul X X) (mul X X)) (mul (mul X X) (- X))) (sub X (sub (sub (sub X X) (mul X X)) (mul (add X X) (mul X X))))) which correctly captures the function: f(x) = x4 + x3 + x2 + x

Santa Fe Trail In the Santa Fe Trail, an ant must eat all the items of food in a trail. The ant can only move left, right or forward, and can only sense what is directly in front of him.

GP Santa Fe Function Set: Prog2, Prog3, IfFoodAhead Terminal Set: TurnLeft, TurnRight, MoveForward Fitness Measure: count the number of items food eaten after a fixed number of moves, and subtract from 89. Bad fitness = 89, Good fitness = 0. Parameters: Population Size = 500, Max Generations = 50, Crossover = 90%, Mutation = 1%, Reproduction = 9%. Selection is by Tournament Selection (size 5), Creation is performed using RAMP_HALF_AND_HALF. Termination Condition: Program with fitness 0 found.

Some programs Prog2(TurnRight)(TurnLeft) Prog2(MoveForward)(MoveForward)

Result Here’s how one agent fared:

Agent (Prog3 (IfFoodAhead (IfFoodAhead (IfFoodAhead (IfFoodAhead (Prog2 MoveForward MoveForward) TurnLeft) TurnLeft) TurnLeft) (IfFoodAhead MoveForward (IfFoodAhead MoveForward (IfFoodAhead (IfFoodAhead (Prog2 MoveForward MoveForward) TurnLeft) TurnLeft)))) TurnLeft (Prog3 (IfFoodAhead (IfFoodAhead MoveForward TurnLeft) TurnRight) MoveForward TurnRight)) Smaller agents can be found!

Robot Wall-Following with GP (Koza, 1993) Given: Odd-shaped room with robot in center. Find: A control strategy for the robot that makes it move along the periphery. GP Primitives: Terminals: S0, S1..S11 (12 sensor readings, distance to wall), Functions: IFLTE (if less than or equal), PROGN2, MF, MB (move forward/back), TL, TR (turn left/right). Fitness Function: Fitness = peripheral cells visited. Sample Individual/Strategy: (IFLTE S3 S7 (MF) (PROG2 MB (IFLTE S4 S9 (TL) (PROG2 (MB) (TL)))))

Wall-Following Evolution

Fitness function The fitness function is based on executing the evolved programs on one or more prescribed test suites. The test suites can be devised in the same way as those used when testing traditional manually produced programs. Program size as part of fitness

Fitness function Fitness Functions Error-based – Fitness inversely proportional to total error on the test data. – E.g. symbolic regression, classification, image compression, multiplexer design.. Cost-based – Fitness inversely proportional to use of resources (e.g. time, space, money, materials, tree nodes) – E.g. truck-backing, broom-balancing, energy network design…

Fitness function Benefit-based – Fitness proportional to accrued resources or other benefits. – E.g. foraging, investment strategies Parsimony-base – Fitness partly proportional to the simplicity of the phenotypes. – E.g. sorting algorithms, data compression… Entropy-based – Fitness directly or inversely proportional to the statistical entropy of a set of collections – E.g. Random sequence generators, clustering algorithms, decision trees.

So what next It would appear that the evolution of programs can be done safely and with some success. But consider the way humans program: they use Storage (variables, arrays, stacks, queues) Functions (subroutines, procedures) Recursion Loops … can GP handle these constructs?

Storage Because GP is concerned directly with the evolution of programs, it is not a problem to introduce the kind of storage that programmers use. Variables X, (set X <value>) Indexed Memory (write <position> <value>) (read <position>) Directed Graphs Stacks (push <value>) (pop) Queues (head) (tail <value>) … So you can use storage whatever way you like. Whether the storage is a help to your problem depends on the problem domain itself.

Automatically Functions In GP, you can specify automatically defined functions. In such programs, each individual has a main result producing branch and a number of other branches to define functions ADF0 ADF1 and so on. Each function can take a number of formal parameters, and the ADFs can be called by the main program. ADFs have been shown to improve the scalability of GP to some problems and provide quicker convergence on optimal solutions.

Architecture Altering Operations Deciding on the number of automatically defined functions can be left up to the evolutionary practitioner as a design task. However, its possible to define architecture-altering operations that will automatically add or remove automatically defined functions and their parameters. See the animated gifs for subroutine creation subroutine deletion subroutine duplication argument duplication argument deletion These are used with low probability in GPPS - the Genetic Programming Problem Solver.

Other ways to evolve programs There are other ways to evolve programs… Nordin’s machine-code genetic programming, where individuals are chunks of memory cast as a function pointer and executed. Ryan & O’Neill’s grammatical evolution, where individuals encode ordered lists of productions in a grammar that when evaluated produce a syntactically correct C program Fogel’s finite state machines (1966), where state machines were evolved to perform such tasks as prime-number prediction In fact, if we consider a program to an and input-output device, there are any number of representations that can be used. Traditionally though genetic programming is characterised by tree-structures.

… Designer GP In recent times, the tree-representation employed by GP has been used for automatic design of electrical circuits. The tree is no longer a “program”, but should be considered a “program that builds circuits”. The idea of building graph structures using commands embedded in a tree was developed by Frederic Gruau. He used it to evolve neural networks: Koza et al now use it to evolve electric circuits. Functions of node are Par (P) and Seq (S), that change the topology of the graph. Other functions and terminals modify the values at the nodes. Everything begins with one embryonic cell with a pointer to the head of the tree.

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

Cellular Encoding

So you want to use GP... Genetic programming, at its heart, is the evolution of tree structures that can be interpreted as programs. Use GP to solve problems where the solutions are naturally expressed as tree structures. evolve LISP programs to solve a problem evolve solutions in an indirect manner, by using the GP trees to build solutions to problems. Your approach will be to to determine the functions & terminals that constitute your trees, and how to interpret the resulting trees as solutions to your problem.