t-eoVirus.cpp

00001 /* -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003     t-eoVirus.cpp
00004       This program tests the the binary cromosomes and several genetic operators
00005     (c) GeNeura Team, 1999
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     Contact: todos@geneura.ugr.es, http://geneura.ugr.es
00022 
00023 */
00024 //-----------------------------------------------------------------------------
00025 
00026 #include <iostream>   // std::cout
00027 #include <eo>         // general EO
00028 #include "MGE/VirusOp.h"
00029 #include "MGE/eoVirus.h"
00030 #include "MGE/eoInitVirus.h"
00031 #include <utils/eoRndGenerators.h>
00032 
00033 #include "binary_value.h"
00034 
00035 //-----------------------------------------------------------------------------
00036 
00037 typedef eoVirus<float> Chrom;
00038 
00039 //-----------------------------------------------------------------------------
00040 
00041 int main()
00042 {
00043   const unsigned SIZE = 8;
00044   eoBooleanGenerator gen;
00045   eo::rng.reseed( time( 0 ) );
00046 
00047   Chrom chrom(SIZE), chrom2(SIZE);
00048   chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2));
00049   std::cout << chrom << std::endl;
00050   std::cout << chrom2 << std::endl;
00051 
00052   // Virus Mutation
00053   VirusBitFlip<float> vf;
00054   unsigned i;
00055   for ( i = 0; i < 10; i++ ) {
00056         vf( chrom );
00057         std::cout << chrom << std::endl;
00058   }
00059 
00060   // Chrom Mutation
00061   std::cout << "Chrom mutation--------" << std::endl;
00062   VirusMutation<float> vm;
00063   for ( i = 0; i < 10; i++ ) {
00064         vm( chrom );
00065         std::cout << chrom << std::endl;
00066   }
00067 
00068   // Chrom Transmision
00069   std::cout << "Chrom transmission--------" << std::endl;
00070   VirusTransmission<float> vt; 
00071   vt( chrom2, chrom );
00072   std::cout << chrom2 << std::endl;
00073 
00074   return 0;
00075 
00076 }
00077 

Generated on Thu Oct 19 05:06:44 2006 for EO by  doxygen 1.3.9.1