evolving unrestricted java software with finch
play

Evolving unrestricted Java software with FINCH Michael Orlov and - PowerPoint PPT Presentation

Evolving unrestricted Java software with FINCH Michael Orlov and Moshe Sipper orlovm , sipper@cs.bgu.ac.il Department of Computer Science Ben-Gurion University, Israel Dynamic Adaptive SBSE The 26 th CREST Open Workshop April 2013, UCL GP:


  1. Evolving unrestricted Java software with FINCH Michael Orlov and Moshe Sipper orlovm , sipper@cs.bgu.ac.il Department of Computer Science Ben-Gurion University, Israel Dynamic Adaptive SBSE The 26 th CREST Open Workshop April 2013, UCL

  2. GP: Programs or Representations? Evolving unrestricted “While it is common to describe GP as evolving programs , Java software with FINCH GP is not typically used to evolve programs in the familiar Michael Orlov Turing-complete languages humans normally use for software Moshe Sipper development.” Introduction Programs? Goals Evolution Crossover Experiments In the Wild Conclusions References A Field Guide to Genetic Programming [Poli, Langdon, and McPhee, 2008] 2 / 54

  3. GP: Programs or Representations? Evolving unrestricted “While it is common to describe GP as evolving programs , Java software with FINCH GP is not typically used to evolve programs in the familiar Michael Orlov Turing-complete languages humans normally use for software Moshe Sipper development.” Introduction Programs? Goals Evolution “It is instead more common to evolve programs Crossover (or expressions or formulae) Experiments in a more constrained and often domain-specific language .” In the Wild Conclusions References A Field Guide to Genetic Programming [Poli, Langdon, and McPhee, 2008] 3 / 54

  4. Our Goals Evolving From programs. . . unrestricted Java software with FINCH Evolve actual programs Michael Orlov written in Java Moshe Sipper Introduction Programs? . . . to software! Goals Evolution Improve (existing) software Crossover written in unrestricted Java Experiments In the Wild Conclusions References 4 / 54

  5. Our Goals Evolving From programs. . . unrestricted Java software with FINCH Evolve actual programs Michael Orlov written in Java Moshe Sipper Introduction Programs? . . . to software! Goals Evolution Improve (existing) software Crossover written in unrestricted Java Experiments In the Wild Conclusions Extending prior work References Existing work uses restricted subsets of Java bytecode as representation language for GP individuals We evolve unrestricted bytecode 5 / 54

  6. Let’s Evolve Java Source Code Evolving • Rely on the building blocks in the initial population unrestricted Java software • Defining genetic operators is problematic with FINCH Michael Orlov • How do we define good source-code crossover? Moshe Sipper Introduction Factorial (recursive) Factorial (iterative) Evolution class F { class F { Source code Parse trees int fact(int n) { int fact(int n) { Bytecode int ans = 1; int ans = 1; Crossover Experiments if (n > 0) ⇐ for (; n > 0; n--) In the Wild ans = n * ans = ans * n; Conclusions fact( n-1); References return ans; return ans; } } } } 6 / 54

  7. Oops Evolving unrestricted Java software • Source-level crossover typically produces garbage with FINCH Michael Orlov Factorial (recursive ← − Moshe Sipper × iterative) Introduction class F { Evolution int fact(int n) { Source code int ans = 1; Parse trees Bytecode Crossover if (n > = 1; Experiments for (; n > 0; n--) In the Wild ans = ans * n; n-1); Conclusions References return ans; } } 7 / 54

  8. Oops Evolving unrestricted Java software • Source-level crossover typically produces garbage with FINCH Michael Orlov Factorial (recursive ← − Moshe Sipper × iterative) Introduction class F { Evolution int fact(int n) { Source code int ans = 1; Parse trees Bytecode Crossover if (n > = 1; Experiments for (; n > 0; n--) In the Wild ans = ans * n; n-1); Conclusions References return ans; } } 8 / 54

  9. Parse Trees Evolving unrestricted • Maybe we can design better genetic operators? Java software with FINCH Michael Orlov Moshe Sipper Introduction Evolution Source code Parse trees Bytecode Crossover Experiments In the Wild Conclusions References 9 / 54

  10. Parse Trees Evolving unrestricted • Maybe we can design better genetic operators? Java software with FINCH • Maybe. . . but too much harsh syntax Michael Orlov Moshe Sipper Possibly use parse tree ? Introduction Evolution Source code Parse trees Bytecode Crossover Experiments In the Wild Conclusions References 10 / 54

  11. Parse Trees Evolving unrestricted • Maybe we can design better genetic operators? Java software with FINCH • Maybe. . . but too much harsh syntax Michael Orlov Moshe Sipper Possibly use parse tree ? Introduction Just one BNF rule (of many) Evolution Source code method_declaration ::= ⇒ Parse trees modifier ∗ type identifier Bytecode Crossover “(” parameter_list ? “)” “[ ]” ∗ Experiments � statement_block | “;” � In the Wild Conclusions References method_declaration type identifier ( parameter_list ) statement_block modifier ] [ ; 11 / 54

  12. Bytecode Evolving unrestricted Java software Better than parse trees: with FINCH Let’s use bytecode ! Michael Orlov Moshe Sipper Introduction Java Virtual Machine (JVM) Evolution Source code • Source code is compiled to platform-neutral bytecode Parse trees Bytecode • Bytecode is executed with fast just-in-time compiler Crossover • High-order, simple yet powerful architecture Experiments In the Wild • Stack-based , supports hierarchical object types Conclusions • Not limited to Java! References (Scala, Groovy, Jython, Kawa, Clojure, . . . ) 12 / 54

  13. Bytecode (cont’d) Some basic bytecode instructions Evolving unrestricted Stack ↔ Local variables Java software with FINCH iconst 1 pushes int 1 onto operand stack Michael Orlov Moshe Sipper aload 5 pushes object in local variable 5 onto stack (object type is deduced when class is loaded) Introduction dstore 6 pops two-word double to local variables 6 – 7 Evolution Source code Parse trees Bytecode Crossover Experiments In the Wild Conclusions References 13 / 54

  14. Bytecode (cont’d) Some basic bytecode instructions Evolving unrestricted Stack ↔ Local variables Java software with FINCH iconst 1 pushes int 1 onto operand stack Michael Orlov Moshe Sipper aload 5 pushes object in local variable 5 onto stack (object type is deduced when class is loaded) Introduction dstore 6 pops two-word double to local variables 6 – 7 Evolution Source code Parse trees Bytecode Arithmetic instructions (affect operand stack) Crossover imul pops two int s from stack, pushes multiplication result Experiments In the Wild Conclusions References 14 / 54

  15. Bytecode (cont’d) Some basic bytecode instructions Evolving unrestricted Stack ↔ Local variables Java software with FINCH iconst 1 pushes int 1 onto operand stack Michael Orlov Moshe Sipper aload 5 pushes object in local variable 5 onto stack (object type is deduced when class is loaded) Introduction dstore 6 pops two-word double to local variables 6 – 7 Evolution Source code Parse trees Bytecode Arithmetic instructions (affect operand stack) Crossover imul pops two int s from stack, pushes multiplication result Experiments In the Wild Conclusions Control flow (uses operand stack) References ifle +13 pops int , jumps +13 bytes if value � 0 lreturn pops two-word long , returns to caller’s stack 15 / 54

  16. Bytecode (cont’d) Evolutionary operators Evolving unrestricted • Java bytecode is less fragile than source code Java software with FINCH Michael Orlov Moshe Sipper Introduction Evolution Source code Parse trees Bytecode Crossover Experiments In the Wild Conclusions References 16 / 54

  17. Bytecode (cont’d) Evolutionary operators Evolving unrestricted • Java bytecode is less fragile than source code Java software with FINCH • But, bytecode must be correct in order to run correctly Michael Orlov Moshe Sipper Correct bytecode requirements Introduction Stack use is type-consistent Evolution (e.g., can’t multiply an int by an Object ) Source code Parse trees Local variables use is type-consistent Bytecode Crossover (e.g., can’t read an int after storing an Object ) Experiments No stack underflow In the Wild No reading from uninitialized variables Conclusions References 17 / 54

  18. Bytecode (cont’d) Evolutionary operators Evolving unrestricted • Java bytecode is less fragile than source code Java software with FINCH • But, bytecode must be correct in order to run correctly Michael Orlov Moshe Sipper Correct bytecode requirements Introduction Stack use is type-consistent Evolution (e.g., can’t multiply an int by an Object ) Source code Parse trees Local variables use is type-consistent Bytecode Crossover (e.g., can’t read an int after storing an Object ) Experiments No stack underflow In the Wild No reading from uninitialized variables Conclusions • So, genetic operators are still delicate References 18 / 54

  19. Bytecode (cont’d) Evolutionary operators Evolving unrestricted • Java bytecode is less fragile than source code Java software with FINCH • But, bytecode must be correct in order to run correctly Michael Orlov Moshe Sipper Correct bytecode requirements Introduction Stack use is type-consistent Evolution (e.g., can’t multiply an int by an Object ) Source code Parse trees Local variables use is type-consistent Bytecode Crossover (e.g., can’t read an int after storing an Object ) Experiments No stack underflow In the Wild No reading from uninitialized variables Conclusions • So, genetic operators are still delicate References • Need good genetic operators to produce correct offspring 19 / 54

Recommend


More recommend