next up previous
Next: How to use views Up: viewlooking at Previous: viewlooking at

Introduction

Views, as defined in GAGS, are a way of looking at chromosomes and making them seem whatever we want. A chromosome is a raw string of bits, with no structure in it; to operate on them, print them, or evaluate them, we need to watch them as some other thing, for instance, an array of floats in a certain range. This is what views do for us, present a chromosome in any way we want.

 
Figure 1: Graph showing the way views work. Views act on a number of bits, converting them to the range specified in the view definition. 

Views are usually templates, so that some chromosomes can be seen as arrays of integers, and others as character strings; they must be instantiated to the type we want.

There is usually only one view object defined for all chromosomes, if they are to be seen in the same way; in this way, presentation information is not included within the chromosome, avoiding memory overhead within each chromosome object. It acts as a functor, having the same syntax that a function call.

	#include <gagsview.hpp>
	//.... stuff here....
	chrom aChrom( NUMGENS*SIZEGENES );
	view<float> aView( SIZEGENES );

	// .... more stuff here ...
From then on, each gene i in the chromosomes can be printed with
cout << aView( &aChrom, i) << endl;

This presents aChrom, and any other chromosome defined in the same way, as an array of float; each element of the array would correspond to a gene within the chromosome. Views need not be defined if chromosomes' raw bits are used directly; however, they are a convenient way of representing and evaluating chromosomes. It is advised to create a new view for any new interpretation of the chromosome; it will be shown how later on.

They need not be defined, if the chromosome is going to be seen as a complex structure, like a neural network. A programmer is better off if she includes within that structure a constructor that builds a neural network from a chromosome object or from the bitstring inside the chromosome.


next up previous
Next: How to use views Up: viewlooking at Previous: viewlooking at

[JJ J. J. Merelo * jmerelo@kal-el.ugr.es[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