ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 4187

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

20 Genetic Algorithms

Program 20.4: Main program

1int main(int argc, char *argv[])

2{ int i;

3

4GeneInt genes[5];

5Chromosome* chromosomes[5];

6Population population;

7

8population.setCrossover(0.5f);

9population.setDecease(0.2f);

10population.setMutation(0.0f);

12// Initialise genes and add them to our chromosomes,

13// then add the chromosomes to the population

14for(i=0; i<5; i++) {

15genes[i].setData((void*) rand()%32);

16chromosomes[i].addGene(&genes[i]);

17population.addChromosome(&chromosomes[i]);

18}

19

20// Continually run the genetic algorithm until the

21// optimal solution is found by the top chromosome

23i = 0;

24do {

25printf("Iteration %d", i++);

26population.evolveNewPopulation();

27population.printState();

28} while((population.getChromosome(0)).getFitness()!=0);

30// Finished

31return 0;

32}

20.6References

BEASLEY, D., BULL, D., MARTIN, R. An Overview of Genetic Algorithms: Part 1, Fundamentals, University Computing, vol. 15, no. 2, 1993a, pp. 58-69 (12)

BEASLEY, D., BULL, D., MARTIN, R. An Overview of Genetic Algorithms: Part 2, Research Topics, University Computing, vol. 15, no. 4, 1993b, pp. 170-181 (12)

BEAULIEU, J., GAGNÉ, C. Open BEAGLE – A Versatile Evolutionary Computation Framework, Département de génie électrique et de génie informatique, Université Laval, Québec, Canada, http://www.gel.ulaval.

ca/~beagle/, 2006

304


References

DARWIN, C. On the Origin of Species by Means of Natural Selection, or Preservation of Favoured Races in the Struggle for Life, John Murray, London, 1859

GALIB Galib – A C++ Library of Genetic Algorithm Components, http:// lancet.mit.edu/ga/, 2006

GOLDBERG, D. Genetic Algorithms in Search, Optimization and Machine Learning, Addison-Wesley, Reading MA, 1989

HARVEY, I., HUSBANDS, P., CLIFF, D. Issues in Evolutionary Robotics, in J. Meyer, S. Wilson (Eds.), From Animals to Animats 2, Proceedings of the Second International Conference on Simulation of Adaptive Behavior, MIT Press, Cambridge MA, 1993

IJSPEERT, A. Evolution of neural controllers for salamander-like locomotion, Proceedings of Sensor Fusion and Decentralised Control in Robotics Systems II, 1999, pp. 168-179 (12)

LANGTON, C. (Ed.) Artificial Life – An Overview, MIT Press, Cambridge MA, 1995

LEWIS, M., FAGG, A., BEKEY, G. Genetic Algorithms for Gait Synthesis in a Hexapod Robot, in Recent Trends in Mobile Robots, World Scientific, New Jersey, 1994, pp. 317-331 (15)

RAM, A., ARKIN, R., BOONE, G., PEARCE, M. Using Genetic Algorithms to Learn Reactive Control Parameters for Autonomous Robotic Navigation, Journal of Adaptive Behaviour, vol. 2, no. 3, 1994, pp. 277-305 (29)

VENKITACHALAM, D. Implementation of a Behavior-Based System for the Control of Mobile Robots, B.E. Honours Thesis, The Univ. of Western Australia, Electrical and Computer Eng., supervised by T. Bräunl, 2002

305


GENETIC

21

PROGRAMMING

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . .

enetic programming extends the idea of genetic algorithms discussed Gin Chapter 20, using the same idea of evolution going back to Darwin [Darwin 1859]. Here, the genotype is a piece of software, a directly executable program. Genetic programming searches the space of possible computer programs that solve a given problem. The performance of each individual program within the population is evaluated, then programs are selected according to their fitness and undergo operations that produce a new set of programs. These programs can be encoded in a number of different programming languages, but in most cases a variation of Lisp [McCarthy et al. 1962] is cho-

sen, since it facilitates the application of genetic operators.

The concept of genetic programming was introduced by Koza [Koza 1992]. For further background reading see [Blickle, Thiele 1995], [Fernandez 2006], [Hancock 1994], [Langdon, Poli 2002].

21.1 Concepts and Applications

The main concept of genetic programming is its ability to create working programs without the full knowledge of the problem or the solution. No additional encoding is required as in genetic algorithms, since the executable program itself is the phenotype. Other than that, genetic programming is very similar to genetic algorithms. Each program is evaluated by running it and then assigning a fitness value. Fitness values are the base for selection and genetic manipulation of a new generation. As for genetic algorithms, it is important to maintain a wide variety of individuals (here: programs), in order to fully cover the search area.

Koza summarizes the steps in genetic programming as follows [Koza 1992]:

307307


21 Genetic Programming

Applications

in robotics

1.Randomly generate a combinatorial set of computer programs.

2.Perform the following steps iteratively until a termination criterion is satisfied (i.e. the program population has undergone the maximum number of generations, or the maximum fitness value has been reached, or the population has converged to a sub-optimal solution).

a.Execute each program and assign a fitness value to each individual.

b.Create a new population with the following steps:

i.Reproduction: Copy the selected program unchanged to the new population.

ii.Crossover: Create a new program by recombining two selected programs at a random crossover point.

iii.Mutation: Create a new program by randomly changing a selected program.

3.The best sets of individuals are deemed the optimal solution upon termination.

The use of genetic programming is widely spread from evolving mathematical expressions to locating optimum control parameters in a PID controller. The genetic programming paradigm has become popular in the field of robotics and is used for evolving control architectures and behaviors of mobile robots.

[Kurashige, Fukuda, Hoshino 1999] use genetic programming as the learning method to evolve the motion planning of a six-legged walker. The genetic programming paradigm is able to use primitive leg-moving functions and evolve a program that performs robot walking with all legs moving in a hierarchical manner.

[Koza 1992] shows the evolution of a wall-following robot. He uses primitive behaviors of a subsumption architecture [Brooks 1986] to evolve a new behavior that lets the robot execute a wall-following pattern without prior knowledge of the hierarchy of behaviors and their interactions.

[Lee, Hallam, Lund 1997] apply genetic programming as the means to evolve a decision arbitrator on a subsumption system. The goal is to produce a high-level behavior that can perform box-pushing, using a similar technique to Koza’s genetic programming.

[Walker, Messom 2002] use genetic programming and genetic algorithms to auto-tune a mobile robot control system for object tracking.

The initial population holds great importance for the final set of solutions. If the initial population is not diverse enough or strong enough, the optimal solution may not be found. [Koza 1992] suggests a minimum initial population size of 500 for robot motion control and 1,000 for robot wall-following (see Table 21.1).

308


Lisp

Problem

Reference

Initial

Pop. Size

Wall-following robot

[Koza 1992]

1,000

Box-moving robot

[Mahadevon, Connell 1991]

500

Evolving behavior prim-

[Lee, Hallam, Lund 1997]

150

itives and arbitrators

Motion planning for

[Kurashige, Fukuda, Hoshino 1999]

2,000

six-legged robot

Evolving communica-

[Iba, Nonzoe, Ueda 1997]

500

tion agents

Mobile robot motion

[Walker, Messom 2002]

500

control

Table 21.1: Initial population sizes

21.2 Lisp

Lisp functions: atoms and lists

It is possible to formulate inductive programs in any programming language. However, evolving program structures such as C or Java are not straightforward. Therefore, Koza used the functional language Lisp (“List Processor”) for genetic programming. Lisp was developed by McCarthy starting in 1958 [McCarthy et al. 1962], which makes it one of the oldest programming languages of all. Lisp is available in a number of implementations, among them the popular Common Lisp [Graham 1995]. Lisp is usually interpreted and provides only a single program and data structure: the list.

Every object in Lisp is either an atom (a constant, here: integer or a parameterless function name) or a list of objects, enclosed in parentheses.

Examples for atoms:

7,

123, obj_size

Examples for lists:

(1

2 3), (+ obj_size 1), (+ (* 8 5) 2)

S-Expression Lists may be nested and are not only the representation for data structures, but also for program code as well. Lists that start with an operator, such as (+ 1 2), are called S-expressions. An S-expression can be evaluated by the Lisp interpreter (Figure 21.1) and will be replaced by a result value (an atom or a list, depending on the operation). That way, a program execution in a procedural programming language like C will be replaced by a function call in Lisp:

Lisp subset for robotics

(+ (* 8 5) 2) o (+ 40 2) o 42

Only a small subset of Lisp is required for our purpose of driving a mobile robot in a restricted environment. In order to speed up the evolutionary process, we use very few functions and constants (see Table 21.2).

309