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

/magnus/back_end/Genetic/include/WhiteheadExperiment.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: Informal test.
00009 //
00010 // Principal Author: Alexei Miasnikov
00011 //
00012 // Status:
00013 //
00014 // Revision History:
00015 //
00016 
00017 #ifndef WHITEHEAD_EXP
00018 #define WHITEHEAD_EXP
00019 
00020 #include <values.h>
00021 #include "global.h"
00022 #include "Map.h"
00023 #include "Polynomial.h"
00024 #include "ACConfig.h"
00025 #include "RandomNumbers.h"
00026 #include "Roulette.h"
00027 #include "GAIsPartOfBasis.h"
00028 #include <time.h>
00029 #include "RandomAutoInFree.h"
00030 #include "NormalRandomWord.h"
00031 
00032 
00033 class WhiteheadExperiment
00034 {
00035 private:
00036   int uBound;
00037   int lBound;
00038   ACConfig c;
00039   ofstream exp_out;
00040   FreeGroup G;
00041   int N;
00042   int autos;
00043   int lbound;
00044   int ubound;
00045   
00046 public: 
00047   WhiteheadExperiment() : uBound(500),lBound(5),exp_out("garbage")
00048   {
00049     Chars errMsg;
00050     
00051     ifstream in("ac.in");
00052     
00053     if ( !in ) {
00054       cout << " Error: Configuration file \"ac.in\" couldn't be found." << endl;
00055       exit( 0 );
00056     }
00057     
00058     in >> c;
00059     cout << c << endl;
00060     
00061     cout << "Enter a free group: ";
00062     errMsg = cin >> G;
00063     if( errMsg.length() > 0 ) {
00064       cout << errMsg;
00065       exit(0);
00066     }
00067     
00068     cout << G << endl;
00069     
00070     exp_out << "Group : " << G << endl;
00071     cout << "Number of experiments : "; cin >> N; cout << N << endl;
00072     cout << "Number of Whitehead autos : "; cin >> autos; 
00073     cout << autos << endl;
00074     
00075     cout << "Lower bound : "; cin >> lbound; cout << lbound << endl;
00076     cout << "Upper bound : "; cin >> ubound; cout << ubound << endl;
00077   }
00078 
00079   void run(){
00080     int autoLSum = 0;
00081     int tupleLSum1 = 0;
00082     int tupleLSum2 = 0;
00083     int tupleLSumMin = 0;
00084     int nGens = 0;
00085     int sumWordsInTuple = 0;
00086     float sumOfSeconds = 0;
00087     int numOfSucs = 0;
00088     
00089     UniformRandom randPicker;
00090     
00091     bool draw_transf = true;
00092     
00093     RandomAutoInFree rAuto( G,autos, false);
00094     
00095     for (int i = 0; i < N; i++){
00096       // get map
00097       int auto_l = 0;
00098       
00099       
00100       // while |tuple| not in bounds
00101       Map map = rAuto.getAutomorphism();
00102       
00103       
00104       VectorOf<Word> image = map.generatingImages();
00105       VectorOf<Word> tuple(1);
00106       tuple[0] = image[randPicker.rand(0,G.numberOfGenerators()-1)].freelyReduce();
00107       
00108       //      if (tuple[0].length() < 13 ){
00109       //        i--;
00110       //        continue;
00111       //      }
00112       
00113       // find minimal of the  tuple 
00114       bool found;
00115       int nTrys = 0;
00116       if (tuple[0].length() >= lbound && tuple[0].length() <= ubound) {
00117         found = false;
00118         nTrys = 0;
00119         while ( nTrys < 5 && !found){
00120           nTrys++;
00121           GAIsPartOfBasis min_tuple(G,c,tuple);
00122           
00123           if (draw_transf){
00124             min_tuple.printTransformations( cout );
00125             draw_transf = false;
00126           }
00127           found = min_tuple.isPartOfBasis(exp_out,exp_out);
00128           
00129           if (found) {
00130             //       if (false) {
00131             cout << endl << endl << tuple[0].length() << " |  " << min_tuple.nOfGenerations() << " | " << min_tuple.getSolutionSequence() << " | ";
00132           } 
00133         }
00134         if (!found) {
00135           cout << endl << endl << tuple[0].length() << " |  " << 999999 << " | ";
00136         }
00137         cout << nTrys << " | ";
00138         G.printVectorOfWords(cout, tuple); 
00139       } else {
00140         i--;
00141       }
00142     }
00143     
00144     exp_out.close();
00145     //   best_out.close();
00146   }
00147 };
00148 
00149 #endif

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