int main(void) { InitTotalStatistics(); TestFloatHelper(); TestIntegerHelper(); TestFastFunctions(); TestArrayMinimalTemplate(); TestPropertiesFile(); TestChars(); TestMap(); TestTextParser(); TestXMLParser(); TestXMLFile(); TestLogFile(); TestDurableSet(); TestDurableFile(); TestDurableFileController(); TestIndexTreeNodeFile(); TestIndexTreeBlockFile(); TestIndexedFile(); TestIndexedFiles(); TestIndexes(); TestIndexedHuge(); TestOperators(); TestFunctionCaller(); TestFiles(); TestPackFilesPacker(); TestIndexedData(); TestIndexedDataSmart(); TestNumber(); return TestTotalStatistics(); }
//---------------------GrabPermutation---------------------- // // given an int, this function returns a vector containing // a random permutation of all the integers up to the supplied // parameter. //------------------------------------------------------------ vector<int> SGenome::GrabPermutation(int &limit) { vector<int> vecPerm; for (int i=0; i<limit; i++) { //we use limit-1 because we want ints numbered from zero int NextPossibleNumber = RandInt(0, limit-1); while(TestNumber(vecPerm, NextPossibleNumber)) { NextPossibleNumber = RandInt(0, limit-1); } vecPerm.push_back(NextPossibleNumber); } return vecPerm; }
SQLiteDatabaseDumpComparisonTest::SQLiteDatabaseDumpComparisonTest(const TestNumber& number, const std::string& name, TestResult::EOutcome (*runFct)(SQLiteDatabaseDumpComparisonTest& test)) : Test(number, name), m_runFct(runFct), m_comparisonTest(TestNumber(), "Comparison") { }
SQLiteDatabaseDumpComparisonTest::SQLiteDatabaseDumpComparisonTest(const TestNumber& number, const std::string& name) : Test(number, name), m_runFct(0), m_comparisonTest(TestNumber(), "Comparison") { }
//----------------------- CrossoverPBX ----------------------------------- // // Position Based Crossover as described in Chapter 5 //------------------------------------------------------------------------ void CgaTSP::CrossoverPBX( const vector<int> &mum, const vector<int> &dad, vector<int> &baby1, vector<int> &baby2) { //Return dependent on the crossover rate or if the //chromosomes are the same. if ( (RandFloat() > m_dCrossoverRate) || (mum == dad)) { //make sure baby1 and baby2 are assigned some cities first! baby1 = mum; baby2 = dad; return; } //initialize the babies with minus values so we can tell which positions //have been filled later in the algorithm baby1.assign(mum.size(), -1); baby2.assign(mum.size(), -1); int l = baby2.size(); //holds the positions of the chosen cities vector<int> positions; //first city position int Pos = RandInt(0, mum.size()-2); //keep adding random cities until we can add no more //record the positions as we go while (Pos < mum.size()) { positions.push_back(Pos); //next city Pos += RandInt(1, mum.size()-Pos); } //now we have chosen some cities it's time to copy the selected cities //over into the offspring in the same position. for (int pos=0; pos<positions.size(); ++pos) { //baby1 receives from mum baby1[positions[pos]] = mum[positions[pos]]; //baby2 receives from dad baby2[positions[pos]] = dad[positions[pos]]; } //fill in the blanks. First create two position markers so we know //whereabouts we are in baby1 and baby2 int c1 = 0, c2 = 0; for (pos=0; pos<mum.size(); ++pos) { //advance position marker until we reach a free position //in baby2 while( (baby2[c2] > -1) && (c2 < mum.size())) { ++c2; } //baby2 gets the next city from mum which is not already //present if ( (!TestNumber(baby2, mum[pos])) ) { baby2[c2] = mum[pos]; } //now do the same for baby1 while((baby1[c1] > -1) && (c1 < mum.size())) { ++c1; } //baby1 gets the next city from dad which is not already //present if ( (!TestNumber(baby1, dad[pos])) ) { baby1[c1] = dad[pos]; } } }