next up previous
Next: Constructors Up: viewlooking at Previous: Introduction

How to use views

Two views are defined by default: a variable-gene size chromosome, in which each gene has a different number of bits, and a fixed-size gene chromosome, in which all genes have got the same size, and they must be decoded to a certain predefined range. Both use the same interface, so that views can be hauled back and forth without worrying about how to access them. This is achieved by using a letter/envelope structure (see [Coplien, 1994]); different ``letter'' and thus, different implementations are used for different views, but the client-programmer need not worry about it. This is done mainly because views are friends of chromosomes, and since friendship is not inherited, only view base objects can access the chromosome internal representation (i.e. the bitstring). This causes a problem with templates, since in gnu's g++, there is no such a thing as frienship-to-template. Currently, only templates instantiated with float and char can be used; to use any other, it must be added to the friendship list at the beginning of chrom.

{ Creating and using views.  

In the text box 2, a compilable example using view is shown. In this case, a fixed-size gene view is shown; this is defined just by giving the size of the gene. From them on, the chromosome is seen as an array of float in the range [-1,1], the default range. There are, in principle, two ways of defining views, which will create different internal representations.

[JJ J. J. Merelo *[E-MAIL]
Equipo GeNeura -- GeNeura Team
Departamento de Electrónica y Tecnología de los Computadores
Universidad de Granada Granada (Espaņa)
Phone: +34-58-243162; Fax: +34-58-243230