Vlada Shevchuk Max Peysakhov Design Document for Lego Robot Evolution System Introduction This document describes the design of LEGO Robots Assembly Evolution system that can evolve geometrically and structurally valid designs to solve a functionally specified set of design constraints. Document includes functional requirements, system architecture and software design. It serves as the specification from which the LEGO Robots Assembly Evolution system will be developed and tested. Functional requirements and specifications The system will use an approach to the automatic generation of electromechanical engineering designs. The idea is to apply the Messy Genetic Algorithm optimization techniques to the evolution of assemblies composed of the Lego structures. Each design is represented as a labeled assembly graph. Designs are evaluated based on a set of behavior and structural equations, which will be optimized during system evolution. The eventual goal is to introduce a simulation of electromechanical (mechatronic) devices into our evaluation functions. The initial populations will be generated at random. Using selection techniques adapted for the domain of Lego assemblies will produce new individuals for subsequent generations. Single point crossovers will be applied by using cut and splice operators at the random points of the chromosomes; random mutations will be applied to modify the graph with a certain low probability. This cycle will continue until a suitable design is found. In the system representation of Lego designs as a mechanical assembly graph can be described as follows. A labeled assembly graph is more expressive and can represent greater variety of the Lego assemblies including kinematic mechanisms as well as static structures. The nodes of the graph will represent different Lego elements and the edges of the graph will represent connections between elements. Another problem that needs to be solved is the absence of the notation for describing valid Lego assemblies. The solution is to develop a graph grammar to define valid combinations of the nodes and edges precisely and unambiguously. The system should support uniform, one-point crossover as well as proportional, rank, universal stochastic sampling, sigma scaling, and Boltzman selection techniques. Other parameters to the system will include mutation and crossover rates, and population size. Although initial system will only handle static structures composed of block type elements, the general approach can be applied to much more elaborate kinematic mechanisms. LEGO Robots Assembly Evolution Data Flow Diagram The diagram above describes the idea of evolving a population of candidate solutions to a given problem, using operators inspired by natural genetics: crossover, mutation and selection in the system. GAs operates on chromosomes represented as collections of genes. Each gene is the smallest building block of the solution. Different permutations of genes create different chromosomes or individuals, which represents a solution of some quality to the given problem. In the diagram in the first step, the initial population is generated. Then each member of the population is evaluated. Then, one of the selection techniques is used to select candidates for the next generation. In order to form the next generation population mutation and crossover operators are applied with fixed probabilities. Architecture design for LEGO Robots Assembly Evolution (Object-oriented approach) The main components of the system is sGA which was extended from sGA system originally created by prof. Hartley and written on the Java programming language. Java3D and VRML97 were used in order to create a visualizer to monitor Lego structures as they evolve. The modifications were done by adding Translocation Mutation, Inversion Mutation, Sexual Selection, Universal Stochastic Sampling, Rank Selection, Boltzmann selection, Complete Initialization and Radiation (dynamically influence all mutation rates) functions to the class. The class LegoChromosome defines chromosome which is represented by a combination of two data structures: array containing all nodes and the adjacency hash table containing all edges with corresponding string keys. It takes one Mechanism object and treats it as a single chromosome by performing operations such as initialization, mutation, displaying (in Java3d) and so on. LegoChromosome class extends Chromosome class which contains all the properties and attributes of a single chromosome. MyChromosome class itself extends LegoChromosome and contains only basic constructors. The main class sGA performs all genetic algorithm operations such as initialization, mutation, crossover, elitism on MyChromosome object. ShowRoom3D is the class which displays the Lego evolving structure in Java3D. It uses bunch of DDD classes .Each DDD class represents every possible element of every shape and size that exists in Lego assembly. Description of classes contained by Graphs package Graph – the main class in Graphs package which creates a collection of Lego elements (nodes and edges) by reading them from the input file, validate Edge directions, contains access functions for Nodes and Edges. Mechanism – class which represents the structure of LEGO assembly evolution and which extends class Graph. It implements such operations on structure as Splice, Cut, Display, Traverse, contains Element validation in space , process elements. Edge - the high level class which represents the connection between two elements (nodes in graph); Connection – class which extends Edge class and contains attributes and their access functions of defined connection such as cost and strength Third level classes which derived from Edge class: Snap – class which represents connection between two Blocks ; Insert – class which represents connection the way Axle is connected to the Beam; GTrans – class which represents connection between two Gears; TInsert – class which represents connection between Axle or Motor to the Gear or Wheel Node - the high level class which represents the module in LEGO structure; Second level classes which derived from Node object: Element – class which represent an intermediate piece of LEGO assembly evolution; Third level classes which derived from Module object: Disk – is the parent class to classes Gear and Wheel ; Gear – class which represents LEGO element Gear with parameters such as diameter; Wheel – class which represents LEGO element Wheel Block - class which represents a rectangular LEGO peace with pegs on one side and is a parent to objects Plate ,Brick and Beam; Plate – class which represents LEGO element Plate with size 3 times smaller then Brick element and can be described by (N, M) pair of parameters where N and M can range from 1 to 16; Brick – class which represents LEGO element Brick and can be described by (N, M) pair of parameters where N and M can range from 1 to 16 (even numbers); Beam – class which represents LEGO element Beam with 1*N size where N can range from 2 to 16; Motor - class which represents LEGO element Motor which can be described by (4,5) or (5, 4) pair of parameters. Battery - class which represents LEGO element Battery which can be described by (14, 4) or (4, 14) pair of parameters; Pole – class which represents LEGO element Axle which can be described by (Len, 1) or (1, Len) set of parameters where Len can range in (2,4,6,8,10,12,16) set. Inheritance tree for LEGO Robot Evolution System There are few inheritance behaviors in the Object-Oriented structure of the LEGO robots assembly . First one can be observed in Chromosomes package. The inherited behavior goes from Chromosome class to LegoChromosome class to MyChromosome class. Chromosome LegoChromosome MyChromosome The second one can be observed in Lego package where DDD* classes used by ShowRoom3D class. Each basic type of Lego element has parent class DDD[name].java for example DDDAxle.java. Classes which represents every shape and size of this particular Lego element , for example DDDAxle3.java or DDDAxle4.java inherit behavior of parent class. DDDAxle DDDAxle3 The third one and most complex inheritance behavior can be observed in Graphs package. Inheritance behavior goes from Graph class to Mechanism class. Graph Mechanism One inheritance tree goes from Node class to Element to Block, Disk, Gear, Wheel, Motor, Battery, Pole classes. The classes Beam, Plate and Brick extend Block class. The other inheritance tree goes from Edge class to Connection to Snap, Insert, TInsert and Gtrans classes. System Usage Description To run the system in the jdk1.2 environment one has to type following command >java sGA -[option1] -[option2] …-[optionN] where options are as follows: ? Ud F s - Help Usage Debug Log File Name Type of selection such as: p – proportional, r – rank, u - universal stochastic sampling ,s - sexual, g - sigma scaling, b – Boltzman p - Population size .This option will set up the final population size, the initial population will be generated at random. x - Number of crossover points c - Crossover rate m - Mutation rate E - Do elitism R - Reinitialize after generation t - Time to run (sec) G - Maximum number of generations If t (G) set to 0 than sGA executes without time (generation) limit. Both t and G can be set to 0 only if solution fitness is known. P - Print per generation S - To run ShowRoom3D: 0 - do not display, 1- do not rotate, 2 - default Experiment Results Figure below demonstrates the result of 1000 generations of evolution of the static Lego structure with predefined geometric parameters. In this case the goal was to evolve a structure with the size of 10 Lego units in each x-y-z dimension with the minimal weight. In this experiment the mutation and crossover rates were 0.01 and 0.7 respectively and we employed a rank selection strategy and elitism on the population of 100 members. The resulting structure was discovered at the generation 895 and has the sizes 10 by 10 by 6.8, which is sufficiently close to the desired result. Further, we note that this is one of the lightest possible structures that satisfy these parameters that can be created from the set of elements given. In another run of the same experiment the structure 10 by 10 by 10 was actually generated. This structure is shown below. A second experiment is shown in last Figure, where we were evolving a pillar-like structure. The goal of this series of experiments was to make an assembly 4 by 2 in x-y dimension and 20, 40 and 60 in z. A second constraint we specified was density: the pillar should have as few holes as possible. We used the same parameters as in the first experiment and ran the simulation for various time. On average solution was discovered within 5000 generations.