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

/magnus/back_end/Genetic/include/GAIsPartOfBasis.h

Go to the documentation of this file.
00001 /*
00002  *   $Id:
00003  */
00004  
00005 // Copyright (C) 1998 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 //
00008 // Contents: Definition of WhiteHeadGA class
00009 //
00010 // Principal Author: Alexei Miasnikov
00011 //
00012 // Status: in progress
00013 //
00014 // Revision History:
00015 //
00016 
00017 
00018 #ifndef _GA_PART_OF_BASIS_H_
00019 #define _GA_PART_OF_BASIS_H_
00020 
00021 //#define DRAW
00022 
00023 
00024 #include "RandomNumbers.h"
00025 #include "FPGroup.h"
00026 #include "FreeGroup.h"
00027 #include "ACConfig.h"
00028 #include "Associations.h"
00029 #include "WhiteheadOrbit.h"
00030 #include "CayleyDiagram.h"
00031 
00032 // @am for drawing purposes
00033 #define SHOWSIZE 5
00034 
00035 // ------------------------------- GAIsPartOfBasis ------------------------- //
00036 
00037 
00038 class GAIsPartOfBasis
00039 {
00040 
00041 public:
00042   
00043   /////////////////////////////////////////////////////////////////////////
00044   //                                                                     //
00045   // Constructors:                                                       //
00046   //                                                                     //
00047  /////////////////////////////////////////////////////////////////////////
00048 
00049   GAIsPartOfBasis( const FreeGroup& G, const ACConfig& config,
00050                    const VectorOf<Word>& v, float s = 0.0);
00051   
00052   GAIsPartOfBasis( const FreeGroup& G, const ACConfig& config,
00053                    const VectorOf<Word>&,const VectorOf<Word>&, float s = 0.0);
00054    
00055   GAIsPartOfBasis( const FreeGroup& G, const ACConfig& config,
00056                    const Word& w, float s = 0.0);
00057   
00058   // copy constructor supplied by compiler.
00059   
00060   // destructor supplied by compiler.
00061   
00062   ~GAIsPartOfBasis() { 
00063 #ifdef DRAW
00064     // @am for drawing purposes
00065     delete cd1; delete ts1;
00066     delete cd2; delete ts2; 
00067     delete cd3; delete ts3; 
00068     delete mls;
00069 #endif
00070   }
00071   /////////////////////////////////////////////////////////////////////////
00072   //                                                                     //
00073   // Accessors:                                                          //
00074   //                                                                     //
00075   /////////////////////////////////////////////////////////////////////////
00076 
00077   Trichotomy transform( ostream& , int );
00078 
00079   bool isPartOfBasis(ostream& out1, ostream& out2);
00080   bool isPartOfBasis(ostream& out1, const Chars& out2_f_name);
00081 
00082   VectorOf<Word> getAutomorphism() const { return theAuto;}
00083 
00084   Word  getSolutionSequence() const { return solutionSequence; }
00085   const VectorOf<Word>& getCurrentBestWords()const { return bestWords; }
00086   const VectorOf<Word>& getFixedWords() const { return fixedWords; }
00087 
00088   int nOfGenerations() const { return g; }
00089   int fitness( const Word& u,ostream& out = cout, bool print = false );
00090   
00091   Word randomWord( );
00092 
00093   /////////////////////////////////////////////////////////////////////////
00094   //                                                                     //
00095   // OI:                                                                 //
00096   //                                                                     //
00097   /////////////////////////////////////////////////////////////////////////
00098  
00099 
00100   void printTransformations(ostream& out) const;
00101   
00102 private:
00103   
00104   /////////////////////////////////////////////////////////////////////////
00105   //                                                                     //
00106   // Private functions:                                                  //
00107   //                                                                     //
00108   /////////////////////////////////////////////////////////////////////////
00109 
00110   void initialize();
00111 
00112   void printWords(ostream& o, const VectorOf<Word>& v) const;
00113 
00114   Word mutate( const Word& u );
00115   
00116   int randomGen( );
00117   
00118   Word crossover1( const Word& w1,const Word& w2 );
00119   
00120   int genToInsertAfter( Generator g );
00121   
00122   int genToInsertBefore( Generator g );
00123   
00124   int genToInsert( Generator g1, Generator g2 );
00125   
00126   VectorOf<Word> computeAuto(const Word&);
00127 
00128   int computeFitnessReduce( const VectorOf<Word>& v ) const;
00129 
00130   int computeFitnessAuto( const VectorOf<Word>& v ) const;
00131 
00132   int hamingDistance(const Word& w1,const Word& w2) const;
00133 
00134   int hamingDistanceCyclic(const Word& w1,const Word& w2) const;
00135 
00136   int tupleHamingDistance(const VectorOf<Word>&,const VectorOf<Word>&)const;
00137   void permuteVector(VectorOf<Word>& v1, int move_to) const;
00138 
00139   /////////////////////////////////////////////////////////////////////////
00140   //                                                                     //
00141   // Data members:                                                       //
00142   //                                                                     //
00143   /////////////////////////////////////////////////////////////////////////
00144   
00145   FPGroup theGroup;
00146   ACConfig cfg;
00147   VectorOf<Word> theWords;
00148 
00149   VectorOf<Word> tmpWords;
00150 
00151   VectorOf<Word> bestWords;
00152   VectorOf<Word> fixedWords;
00153 
00154   Chars best_out_name;
00155   bool print_best_each_time;
00156 
00157   friend int main(int, char **);
00158  
00159   UniformRandom r;
00160   int numberOfGens;
00161   int numberOfTrans;
00162   int threshold;
00163   
00164   VectorOf<Word> transformations;
00165   VectorOf<Word> transferImage;
00166   VectorOf<Word> theAuto;
00167   Word solutionSequence;
00168   AssociationsOf<int,int> reduces;
00169 
00170   int g;
00171   int sav_first_max;
00172 
00173   Word finalResult;
00174   Word bestTransformation;
00175   int total_tr;
00176   int swithc_tr;
00177 
00178   SetOf<PairOfWords> orig_min;
00179 
00180 
00181   // @am for drawing purposes
00182 
00183   float step;
00184 
00185 #ifdef DRAW
00186   VectorOf<Word> showWords[SHOWSIZE];
00187   int showFitness[SHOWSIZE];
00188 
00189   CayleyDiagram* cd1;
00190   TableGScreen* ts1;
00191   CayleyDiagram* cd2;
00192   TableGScreen* ts2;
00193   CayleyDiagram* cd3;
00194   TableGScreen* ts3;
00195 
00196   MultLayerGScreen* mls;
00197 #endif
00198 };
00199 
00200 
00201 
00202 #endif

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