Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

/magnus/back_end/Genetic/include/Config.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: Config.h,v 1.2 1998/08/03 21:04:55 bormotov Exp $
00003  */
00004  
00005 // Copyright (C) 1997 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 //
00008 // Contents: Definition of GHNConfig class
00009 //
00010 // Chars is a char* which knows its length, wrapped up as a user class.
00011 //
00012 // Principal Author: Dmitry Bormotov
00013 //
00014 // Status: in progress
00015 //
00016 // Revision History:
00017 //
00018 
00019 
00020 #ifndef _GHNConfig_H_
00021 #define _GHNConfig_H_
00022 
00023 #include "global.h"
00024 
00025 
00026 //------------------------------ GHNConfig ----------------------------------//
00027 
00028 
00029 class GHNConfig
00030 {
00031 
00032 public:
00033   
00034   /////////////////////////////////////////////////////////////////////////
00035   //                                                                     //
00036   // Constructors:                                                       //
00037   //                                                                     //
00038   /////////////////////////////////////////////////////////////////////////
00039   
00040   //GHNConfig( );
00041   
00042   GHNConfig( int pop = 50, int gen = -1, int cross = 100, 
00043              int mut = 100, int elit = 1, bool fit = true );
00044   
00045   // copy constructor supplied by compiler.
00046   
00047   // destructor supplied by compiler.
00048 
00049 
00050   /////////////////////////////////////////////////////////////////////////
00051   //                                                                     //
00052   // Accessors:                                                          //
00053   //                                                                     //
00054   /////////////////////////////////////////////////////////////////////////
00055 
00056   int populationSize( ) const { return population; }
00057 
00058   int numOfGenerations( ) const { return generations; }
00059 
00060   double chanceOfCrossover( ) const { return double(crossover)/100; }
00061   // returns value betweeen 0 and 1
00062   
00063   double chanceOfMutation( ) const { return double(mutation)/100; }
00064   // returns value betweeen 0 and 1
00065   
00066   bool haveElitistSelection( ) const { return elitistSelection == 1; }
00067 
00068   bool haveStrongElitistSelection( ) const { return elitistSelection == 2; }
00069 
00070   bool haveFitnessScaling( ) const { return bFitnessScaling; }
00071   
00072   
00073   /////////////////////////////////////////////////////////////////////////
00074   //                                                                     //
00075   // OI:                                                                 //
00076   //                                                                     //
00077   /////////////////////////////////////////////////////////////////////////
00078   
00079   // assignment operator supplied by compiler
00080 
00081   friend ostream& operator << ( ostream& ostr, const GHNConfig& C )
00082   {
00083     C.printOn(ostr);
00084     return ostr;
00085   }
00086     
00087   friend istream& operator >> ( istream& istr, GHNConfig& C )
00088   {
00089     C.readFrom(istr);
00090     return istr;
00091   }
00092 
00093 
00094 private:
00095 
00096   /////////////////////////////////////////////////////////////////////////
00097   //                                                                     //
00098   // Private functions:                                                  //
00099   //                                                                     //
00100   /////////////////////////////////////////////////////////////////////////
00101 
00102   void readFrom( istream& istr );
00103 
00104   void printOn( ostream& ostr ) const;
00105 
00106   void setVariable( const char*, int );
00107   // used by readFrom() to set variables
00108 
00109   /////////////////////////////////////////////////////////////////////////
00110   //                                                                     //
00111   // Data members:                                                       //
00112   //                                                                     //
00113   /////////////////////////////////////////////////////////////////////////
00114   
00115   int population;
00116   int generations;
00117   int crossover;
00118   int mutation;
00119   int elitistSelection;
00120   bool bFitnessScaling;
00121 };
00122 
00123 #endif

Generated at Tue Jun 19 09:49:35 2001 for Magnus Classes by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001