Your SlideShare is downloading. ×
  • Like
Devnology Workshop Genpro 2 feb 2011
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Devnology Workshop Genpro 2 feb 2011

  • 736 views
Published

 

Published in Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
736
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
7
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • User feedback: “ Grrr ”
  • all methods have a way of representing logic
  • input output operationcells constants pairs of testcases
  • build list of class/object-method combination build list of parameter values

Transcript

  • 1. GenPro Genetic Programming made simple Rob van der Veer Bluevoid
  • 2. Bio Java Development (Web, OSGi, Android, Swing) Project Leader (o.a. Scrum) [email_address]
  • 3. Genpro preamble
  • 4. Automated help: “Grrr”
  • 5. Settings vs re-programmable logic
  • 6. AI to the rescue! Genetic Programming Genetic Algorithm Neural networks Fuzzy logic Self learning machines Emergent behavior Reinforcement learning Automated logic Simulated annealing Bayesian networks “ computer programs are the best representation of computer programs” - John R. Koza -
  • 7. Representations outside GP
    • if-then production rules
    • Horn clauses
    • decision trees
    • Bayesian networks
    • propositional logic
    • formal grammars
    • binary decision diagrams
    • frames
    • conceptual clusters
    • concept sets
    • numerical weight vectors (for neural nets)
    • vectors of numerical coefficients for polynomials or other fixed expressions (for adaptive systems)
    • genetic classifier system rules
    • fixed tables of values (as in reinforcement learning)
    • linear chromosome strings (as in the conventional genetic algorithm)
  • 8. Genetic algorithm / programming
    • Generate random solutions
    • Evaluate & score (cumulative error => lower is better)
    • Cross and mutate to generate offspring
    • Repeat step 2 and 3 till score is sufficient
    generation x generation x+1 generate evaluate evaluate 41 32 92 71 80 35 23 78 15 42 99 12 37 29 76 57 45 34 21 12 45 8 98 46 cross and mutate cross and mutate
  • 9. Program representations in GP
    • bits
    • numerical weight vectors
    • machine / byte code
    • constructs
    • concepts?
    Which granularity is better?
  • 10. Genpro birth
  • 11. One year later: Spreadsheet Inspiration
    • Every cell has a value and a type
    3 = A2 + B1 2 1 41
    • Every cell might have a formula
    • Changing the references (mutation!) changes the outcome
  • 12. One (call)cell, one method call
    • A GenPro cell holds:
    • Type
    • Value
    • Target-object (or class)
    • Target method
    • Parameters
    Integer cc1 = Math.max(a, b)
  • 13. One (call)cell, one method call Integer cc1 = Math.max(a, b)
    • cc1
    • Integer
    • Value: 56
    Math max (a, b) int 56 int 32 param a param b
  • 14. A grid of cells i1 37 17.4 Input values 1: 113 2: 212 3: 392 4: 752 Expected Output values 1: 45 2: 100 3: 200 4: 400 O1 x +
  • 15. Working with GenPro
  • 16. Using GenPro: extending Trainer
    • public abstract class Trainer {
    • public abstract Setup createSetup();
    • public abstract TestSetSolutionEvaluator createEvaluator();
    • }
    • TrainerVisual extends Trainer
    • -> autostart of Swing UI
  • 17. Setup
    • Defines: how to create programs and run generations of programs
    • Parts of Setup:
    • Input and output cells
    • Type and maximum nr of cells
    • Elements (constants, libraries)
    • Generation size
    • When to stop
    • When to store solutions
  • 18. GridSolutionEvaluator extends TestSetSolutionEvaluator
    • Defines how to evaluate and select programs.
    • public TestSet createTestSet();
    • public double scoreOutput(ReferenceCell outputCell, Object calculated, Object expected);
    • public double scoreGrid(Grid g);
    • public double scoreGridException(Throwable t);
  • 19. TestSet
    • Defines the inputs and outputs values to evaluate a program.
    • Is actually a list of cellnames with sets of values.
    • public TestSet(Setup setup, String... cellNames)
    • public void addCellValues( final Object... objects)
  • 20. First testcase: exact formula
    • Convert Fahrenheit to Celsius
    • input: Fahrenheit
    • output: Celsius
    • generates exact formula (score goes to 0)
  • 21. GenPro inner working
  • 22. Creating a random solution Lib1 Math input1 Integer output1 Integer Integer c1 = Math.abs(input1); Integer c2 = Math.round(c1); Integer c3 = c2.compareTo(c1); return c2; } import java.lang.Math; public Integer calc(Integer input1) { Math.cos(…) Math.abs(…) … input1 Call targets Param values Math.cos(…) Math.abs(…) c1.compareTo … input1 c1 input1 c1 c2 input1 c1 c2 c3 c3 Integer compareTo(Integer) abs(int) c1 Integer c2 Integer round(double) junk DNA, aka intron ineffective DNA
  • 23. The heart of the machine: Method.invoke()
    • public void calc() {
    • // fetch parameter values
    • Object[] paramObjects = new Object[ paramCells.length ];
      • for (int i = 0; i < paramCells.length; i++) {
      • paramObjects[i] = paramCells[i].getValue();
      • }
      • // execute method on target object/class
      • Object val = t argetMethod.invoke(targetCell.getValue(), paramObjects);
      • // store value
      • setValue(val);
    • }
  • 24. Why reflection?
    • Strong typed connecting
    • No compile time ( = faster @ small testsets )
    • Easy extension, just add POJO’s
    • Use existing libraries
    • Reduces learning curve for user
    • Convertible to working Java code
  • 25. Operators / libraries
    • public class NumberOperations {
    • public static double multiply( double a, double b) {
    • return a * b;
    • }
    • public static double divide( double a, double b) {
    • return a / b;
    • }
    • }
    Lib
  • 26. Back to reality ;)
  • 27. Egg Boiling!
  • 28. Second testcase: non-exact formula
    • Eggweight
    • input: width & height of egg
    • output: weight of egg
    • added lib: formula for volume of Egg
    • public class Egg {
    • public static double volume( double l, double b) {
    • return (0.6057 - 0.0018 * b) * l * b * b;
    • }
    • }
  • 29. Search Space size
    • Nr of cells
    • Nr of operators/methods
    • Nr of parameters
    • Nr of data types
  • 30. Third Test case: search space
    • Exact formula (score=0)
    • F(y)=x4+x3+x2-x
  • 31. Forth Test case: Roman Figures
    • Exact formula (score=0)
    • Strings to Integers
    • Does not give a correct solution yet.
  • 32. Genpro current state
  • 33. Program representations
    • Tree based GP (TGP)
    • Linear based GP (LGP)
    • Graph based GP (GGP)
    • OO based GP (OOGP)
    • Reflection based GP
    // 4 registers in r double lgp ( double[] r ) { r[0] = r[3] + 43 r[2] = r[1] + r[0] if( [r2] > 2) r[3] = sin ( r [2] ) r[0] = r[2] + r[3] return r[0]; } Linear example Tree example
  • 34. Runtime Requirements
    • GenPro Core: Java 1.5 or Android 1.0
    • GenPro Examples: Java 1.5 (Swing)
    • GenPro Android Example: Android 1.5
    • Generated programs: Java 1.0, Android 1.0 or J2ME (CLDC 1.0)
  • 35. Features
    • Supported cell types: Integer, Double, Boolean, String
    • Operators:
      • all numeric (+,-,/,*,%),
      • boolean (&, ||, !),
      • logic operators: none
    • Constructs: if, switch (Integer & Double)
  • 36. Wanted Features
    • Cell type mutation (keep the if-cells!)
    • Runtime compiling of programs
    • Support for void ( state-full objects! ), enumerations and arrays
    • enumeration switch
    • for (and while?) loop
    • support for tournaments (eg: Tic tact toe, Robocode)
  • 37. GenPro challenges you!
    • Real world application of GenPro
    • 2 days of free help getting your problem solved.
    • More developers!
    • Join the architecture meeting!
    • Solve the multithreading bug!
  • 38. Links
    • GenPro code: code.google.com/p/genpro
    • GenPro on twitter: @bluevoid
    • Groups: groups.google.com/group/genpro-gp
    • A scientists view on reflective GP: algoval.essex.ac.uk/rep/oogp/ReflectionBasedGP.pdf
    • Koza’s view on GP:
    • www.genetic-programming.com/sevendiffs.html
    • Contact Rob: [email_address]
  • 39. Genpro, the origin of species (not covered on feb 2!)
  • 40. Example Solution structure cc2 Integer cc3 Integer Lib1 Math Input1 Integer abs(int) round(double) compareTo(Integer) Output1 Integer cc1 Integer parameters Method calls
  • 41. Crossing of solutions cross over point Int Int Math Int Int Int Solution A Int Int Math Int Int Int Solution B
  • 42. Creating children of A & B Int Int Int Int Parent A Int Int Int Int Parent B Child A~B Child B~A cross over point Int Int Int Int Int Int Int Int
  • 43. Crossover Reconnecting A2 B1 B2 A1 Int Int Math Int Int Int Child A~B Int Int Math Int Int Int Child B~A
  • 44. Example Solution structure 2 in code: setup.setCallCells(3, &quot;cc&quot;, Double .class, Integer.class , Boolean .class ); cc2 Integer cc3 Boolean Lib1 Math Input1 Integer abs(int) Output1 Integer cc1 Double
  • 45. Crossover on mixed value types A2 B1 Int Int Math Int Int Dbl Child B~A compareTo(Integer) Mismatch in param type! Potential mismatch in return type and method call
  • 46. Crossover in nature: the origin of species Heart Lung “ DNA” of Horse Heart Lung Brain “ DNA” of Dog cross over points do not match!
  • 47. Solving the species problem
    • prevent mismatch by pre-typing the solution template - specie-fy
    • use converters - Heart-brain bypass?
    • on misconnect: no child - allow specie groups as in nature
    • random reconnect - create new species
  • 48. Crossover on mixed value types: random reconnect A2 B1 Int Int Math Int Int Dbl Child B~A compareTo(Integer) Moved connection
  • 49. Here be dragons