t-eoFitnessAssembled.cpp

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002  
00003 //-----------------------------------------------------------------------------
00004 // t-eoFitnessAssembled.cpp
00005 // Marc Wintermantel & Oliver Koenig
00006 // IMES-ST@ETHZ.CH
00007 // March 2003
00008 
00009 /*
00010     This library is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU Lesser General Public
00012     License as published by the Free Software Foundation; either
00013     version 2 of the License, or (at your option) any later version.
00014  
00015     This library is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018     Lesser General Public License for more details.
00019  
00020     You should have received a copy of the GNU Lesser General Public
00021     License along with this library; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  
00024     Contact: todos@geneura.ugr.es, http://geneura.ugr.es
00025              Marc.Schoenauer@inria.fr
00026              mak@dhi.dk
00027 */
00028 //-----------------------------------------------------------------------------
00029 #include <iostream>
00030 #include <stdexcept>
00031 
00032 #include "eoScalarFitnessAssembled.h"
00033 
00034 void test_eoScalarFitnessAssembledClass(){
00035   
00036   // Create instances
00037   eoAssembledMinimizingFitness A,B,C(5, 1.3, "C value");
00038 
00039   // Add some values to them
00040   A.push_back( 5.6, "first value"  );
00041   A.push_back( 3.2, "second value" );
00042   A.push_back( 2.6, "third value" );
00043 
00044   B.push_back( 1.2 );
00045   B.push_back( 3.2 );
00046   B.push_back( 5.2 );
00047 
00048   B.setDescription( 1, "B descr" );
00049 
00050   std::cout << "Created instances A,B and C, added some vals; testing << operator " << std::endl;
00051   std::cout << "A= " << A << std::endl;
00052   std::cout << "B= " << B << std::endl;
00053   std::cout << "C= " << C << std::endl;
00054   std::cout << "Printing values and descriptions: " << std::endl;
00055   std::cout << "A: "; A.printAll( std::cout ); std::cout << std::endl;
00056   std::cout << "B: "; B.printAll( std::cout ); std::cout << std::endl; 
00057   std::cout << "C: "; C.printAll( std::cout ); std::cout << std::endl;
00058   
00059   A.resize(8, 100.3, "A resized");
00060   std::cout << "Resized A: "; A.printAll( std::cout ); std::cout << std::endl;
00061 
00062   std::cout << "Access fitness values of A and B: " << "f(A)= " << (double) A << " f(B)= " << (double) B << std::endl;
00063 
00064   // Testing constructors and assignments
00065   eoAssembledMinimizingFitness D(A) ,E(3.2);
00066   std::cout << "D(A) = " << D << "\t" << "E(3.2)= " << E << std::endl;
00067   eoAssembledMinimizingFitness F,G;
00068   F=A;
00069   G= 7.5;
00070   std::cout << "F = A : " << F << "\t G = 7.5 : " << G << std::endl;
00071  
00072   // Comparing...
00073   std::cout << "A<B: " << (A<B) << std::endl;
00074   std::cout << "A>B: " << (A>B) << std::endl;
00075   std::cout << "A<=B: " << (A<=B) << std::endl;
00076   std::cout << "A>=B: " << (A>=B) << std::endl;
00077 
00078 }
00079 
00080 
00081 
00082 int main(){
00083   
00084   std::cout << "-----------------------------------" << std::endl;
00085   std::cout << "START t-eoFitnessAssembled" << std::endl;
00086 
00087   try{
00088     // Test the fitness class itself
00089     test_eoScalarFitnessAssembledClass();
00090     
00091     
00092 
00093   }
00094   catch(std::exception& e){
00095     std::cout << e.what() << std::endl;
00096     return 1;
00097   }
00098 
00099   std::cout << "END  t-eoFitnessAssembled" << std::endl;
00100   std::cout << "----------------------------------" << std::endl;
00101 
00102   return 0;
00103 
00104 }
00105 

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