A functional design framework for genetic algorithms - CiteSeerX

0 downloads 0 Views 63KB Size Report
mic design strategies through high-order functions which provide the programmer with a general ... a simple roulette-wheel strategy (to be described later).
A functional design framework for genetic algorithms Fethi A. Rabhi1 , Guy Lapalme2, and Albert Y. Zomaya3 1

3

Department of Computer Science, University of Hull, Hull HU6 7RX (UK) [email protected] 2 D´epartement d’Informatique et de Recherche Op´erationnelle Universit´e de Montr´eal C.P. 6128, Succ. Centre-ville Montr´eal, Qu´ebec, Canada H3C 3J7 [email protected] Department of Electronic Engineering, University of Western Australia The Nedlands, 6907 Western Australia [email protected]

Abstract One of the advantages of functional languages is the ability to use higher-order functions to guide the design of certain classes of algorithms. This paper is concerned with genetic algorithms (GAs) and their application to the solution of the single row routing (SRR) problem which is an important problem in the design of multilayer printed circuit boards (MPCBs). The paper presents a framework which allows high-level modelling of a GA solution as well as providing an executable specification which can be used to refine the parameters of the GA search. This is a first step towards “intelligent” GA design interfaces and efficient implementations possibly based on parallel evaluation.

1

INTRODUCTION

One of the advantages of functional programming is the ability to model algorithmic design strategies through high-order functions which provide the programmer with a general framework for the definition of instance algorithms. Such frameworks have been presented [5] for several simple strategies such as divide-andconquer, backtracking and dynamic programming. Frameworks can be useful in many different ways. Firstly, they allow the programmer to concentrate on the basic constituents of the algorithm which could be specified using a variety of means and notations (including visual interfaces). Secondly, frameworks provide executable specifications which can be used for rapid prototyping and allow the exploration of alternative algorithms. Finally, the underlying implementation can exploit a wide range of optimisations (in both time and space) that are specific to the strategy concerned. Examples of the latter is illustrated in the work on skeletons [4, 8] which has resulted in several frameworks being studied and implemented in parallel. This paper concentrates on a particular class of algorithms with relevance to an important number of real-life applications, namely genetic algorithms. It defines a simple framework for the definition of such algorithms and presents the associated higher-order function and its constituent parameters. The framework is then applied to the solution of the single row routing (SRR) problem which is an important problem in the design of Multilayer Printed Circuit Boards (MPCBs). Since the functional language Haskell [11] is used throughout this paper, a basic knowledge of the language is required for an understanding of the programs presented. 2 GENETIC ALGORITHMS 2.1 GA search: general principles Genetic algorithms (GA) are stochastic search optimisation techniques, based on the principle of natural biological evolution. A GA starts with a pool of feasible solutions (population) and a set of biologically inspired operators defined over the population itself. At each iteration, a new population of solutions is created by breeding and mutation, with the fitter solutions being more likely to procreate. According to evolutionary theories, only the most suited elements in a population are likely to survive and generate offspring, transmitting their biological inheritance to the next generation. GAs operate through a simple cycle of stages: creation of a population of strings, evaluation of each string, selection of the best strings, and reproduction to create a new population. For an introductory textbook, see the one by Goldberg [2]

2.2 A simple framework for GA There are several strategies for conducting GA search. In this paper, we will stick as much as possible to the principles described in [2] with some additional simplifications. For example, we will assume that selection is made according to a simple roulette-wheel strategy (to be described later). In addition, we assume a library of random numbers generators with the following interface: randInts randDoubles randSeeds

:: Seed -> [Int] :: Seed -> [Double] :: Seed -> [Seed]

--generate random ints --generate random doubles --generate random seeds

We now describe the GA interface and a simple implementation of this interface. 2.2.1 The GA interface Our framework presents an interface to the programmer in the form of the three higher-order functions. The first one (function initialPop) creates the initial population; the second one (function nextGen) computes the next generation and the third one (function searchGA) controls the overall GA search. Figure 1 shows the connection between these three functions and their input parameters, most of which must be supplied by the programmer. The programmer may also need to specify how to process the final population (which is returned by the function searchGA) to obtain the desired result. 2.2.2 A simple implementation For rapid prototyping, a simple GA implementation has been developed in Haskell. In this implementation, the functions searchGA, initialPop and nextGen are defined as follows: searchGA noIts test succ (pop,s) | noIts==0 = pop | test pop = pop | otherwise = searchGA (noIts-1) test succ (succ (pop,s)) initialPop chromSize popSize genChrom s = ([genChrom chromSize (rs!!i) | iSeed->chrom)

fitness crossover function function (Int->chrom (chrom->f) ->chrom->[chrom])

maximum generations (Int)

crossover probability (Double)

termination test ([chrom]->Bool)

mutation function (chrom->Seed->chrom)

compute next generation (nextGen)

seed (Seed)

compute initial population (initialPop)

conduct GA search (searchGA) OUTPUT

FIGURE 1.

final population [chrom]

The GA Search Higher-Order Function

The searchGA function is self-explanatory: given a population, it computes the next generation repeatedly until the termination condition is satisfied or a specified limit is reached. The initialPop function computes the initial population by calling the function that generates a (random) chromosome (i.e. function genChrom) as many times as popSize. The nextGen function computes the next generation by applying a selectioncrossover-mutation cycle. Considering selection, determining the fittest chromosomes will be made according to the fitness function. We assume a roulette wheel selection where a percentage value is computed for each chromosome so that it occupies a slice in the 0-100% range of size equal to the value. Selected chromosomes are those for which a random percentage value falls within their range. The resulting function is: select f n (p,s) = ([select’ f p t where (s1:s2:_) rs t

(fromInt (rs!!i)) | i (2,[(2,6),(1,5),(8,13),(10,12),(4,7),(3,11),(9,14)])

In this case, an optimal solution is returned1. In general, several runs of the algorithm are needed, each with a different set of parameters before an optimal solution can be found. 5

CONCLUSION AND FUTURE WORK

This paper presented a framework for the definition of a simple GA search technique and demonstrated its applicability a real-life application (the SRR problem). This framework is intended to form the basis of a graphical user-interface for specifying GA parameters using boxes and pull-down menus. This interface can also present the results of the search in a visual form that includes the variations of the fitness function. The idea is to provide sufficient feedback to the programmer to fine-tune the GA parameters and refine the search algorithm. Future work will be conducted on two fronts. First is the issue of providing standard GA operators (such as well-known selection, crossover and mutation operators) as predefined functions and allowing the selection of these operators through the user-interface. The system can be made more “intelligent” by performing static analysis of constituent parameters and giving advice about optimal operator choices. At present, the execution is restricted to small problems as it makes heavy use of non-updatable list structures for storing populations. Therefore, the second area of future work is to provide an efficient implementation that could tackle large problems. One possibility is to use a state monad for the reuse of space. Another possibility is to exploit the parallelism inherent in the selectioncrossover-mutation cycle and provide an implementation of the GA framework that is suitable for parallel and distributed architectures.

1 The

computation took 10 minutes on a Sun Ultra 1 running Solaris 2

REFERENCES [1] A. Chipperfield and P. Flemming. Parallel genetic algorithms. In A. Y. Zomaya, editor, Parallel and Distributed Computer Handbook, pages 1118–1143. McGrawHill, 1996. [2] D. E. Goldberg. Genetic algorithms in search, optimisation and machine learning. Addison-Wesley, 1989. [3] L. C. Liu and H. C. Du. A near-optimal heuristic algorithm for single-row routing. IEEE Transactions on Computers, C-38(4):603–608, April 1989. [4] F. A. Rabhi. Exploiting parallelism in functional languages : a “paradigm-oriented” approach. In J. R. Davy and P. M. Dew, editors, Abstract Machine Models for Highly Parallel Computers, pages 118–139. Oxford University Press, 1995. [5] F. A. Rabhi and G. Lapalme. Algorithms: a functional programming approach. Addison-Wesley Longman, 1999. [6] F. A. Rabhi, G. Lapalme, and A. Y. Zomaya. A functional genetic algorithm framework and its application to the single row routing problem. In P. Trinder and G. Michaelson, editors, Proc. 1st Scottish Workshop on Functional Programming, number RM/99/9 in Technical Report, pages 309–320, Edinburgh, 1999. Department of Computing and Electrical Engineering, Heriot-Watt University. [7] R. Raghavan and S. Sahni. Complexity of single row routing problems. IEEE Transactions on Circuits and Systems, 31:462–471, 1984. [8] D. B. Skillicorn and D. Talia. Models and Languages for Parallel Computation. ACM Computing Surveys, 30(2):123–169, June 1998. [9] H. C. So. Some theoretical results on the outing of multilayer printed wiring boards. In Proc. IEEE international symposium on circuits and systems, pages 396–303, New-York, 1974. IEEE. [10] T. T. K. Tarng, M. Marek-Sadowska, and E. S. Kuh. An efficient single-row routing algorithm. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, CAD-3:178–183, July 1984. [11] S. Thompson. Haskell: The Craft of Functional Programming (2nd ed.). AddisonWesley Longman, 1999.

Suggest Documents