00001 /* -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 t-eoVector.cpp 00004 This program tests vector-like chromosomes 00005 (c) GeNeura Team, 1999, 2000 00006 00007 Modified by Maarten Keijzer 2001 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00023 Contact: todos@geneura.ugr.es, http://geneura.ugr.es 00024 00025 */ 00026 //----------------------------------------------------------------------------- 00027 #ifdef HAVE_CONFIG_H 00028 #include <config.h> 00029 #endif 00030 00031 #include <cassert> 00032 #include <iostream> 00033 00034 #include <utils/eoRndGenerators.h> 00035 #include <eoVector.h> // eoVector 00036 #include <eoInit.h> 00037 #include <eoScalarFitness.h> 00038 00039 //----------------------------------------------------------------------------- 00040 00041 typedef eoVector<eoMaximizingFitness, int> Chrom1; 00042 typedef eoVector<eoMinimizingFitness, int> Chrom2; 00043 00044 //----------------------------------------------------------------------------- 00045 00046 int main() 00047 { 00048 const unsigned SIZE = 4; 00049 00050 // check if the appropriate ctor gets called 00051 Chrom1 chrom(SIZE, 5); 00052 00053 for (unsigned i = 0; i < chrom.size(); ++i) 00054 { 00055 assert(chrom[i] == 5); 00056 } 00057 00058 eoUniformGenerator<Chrom1::AtomType> uniform(-1,1); 00059 eoInitFixedLength<Chrom1> init(SIZE, uniform); 00060 00061 init(chrom); 00062 00063 std::cout << chrom << std::endl; 00064 00065 Chrom2 chrom2(chrom); 00066 00067 std::cout << chrom2 << std::endl; 00068 00069 // eoInitVariableLength<Chrom1> initvar( 00070 00071 return 0; 00072 } 00073 00074 //-----------------------------------------------------------------------------