/***************************************************************************** We run the program by calling something along the lines of: guessMushroom -train mushrooms.data -test moreMushrooms.data -out mushrooms.out ******************************************************************************/ int main(int argc, char* argv[]) { MushroomP trainingShroomList; trainingShroomList = NULL; MushroomP testingShroomList; testingShroomList = NULL; ValueP availableValues; DecisionP decisionTree; availableValues = NULL; decisionTree = NULL; char infilenameTraining[STRLEN]; /* input file name for training data */ char infilenameTesting[STRLEN]; /* input file name for testing data */ char outfilename[STRLEN]; /* output file name for printing the results */ printf( "This program processes data about the attributes mushrooms.\n" ); /* initialize filenames to dummy strings */ strcpy( infilenameTraining, "none" ); strcpy( infilenameTesting, "none" ); strcpy( outfilename, "none" ); /* TAKEN FROM p5.c EXAMLPE process command-line arguments */ while( *++argv ) { /* while there are still command-line args */ if ( !strcmp( *argv, "-train" ) ) /* set input file name */ strcpy( infilenameTraining, *++argv ); else if( !strcmp( *argv,"-test" ) ) /* set input file name */ strcpy( infilenameTesting, *++argv ); else if( !strcmp( *argv,"-out" ) ) /* set output file name */ strcpy( outfilename,*++argv ); else { /* error checking */ printf( "\nERROR: option %s not recognized\n", *argv ); printf( "...exiting program\n\n" ); exit( 0 ); } } /* end, while there are still command-line args */ /* this is the training data */ trainingShroomList = readMushrooms( infilenameTraining ); /* this is the testing data */ testingShroomList = readMushrooms( infilenameTesting ); availableValues = findAvailableValues( 'e', 0, trainingShroomList ); decisionTree = createDecisionTree( 'e', 0, trainingShroomList, availableValues ); printDecisionTree( decisionTree, outfilename ); printTestResults( 'e', 0, decisionTree, testingShroomList, outfilename ); /* free the list of test mushrooms */ freeMushrooms( trainingShroomList ); freeMushrooms( testingShroomList ); /* note that Decision structs are freed in printDecisionTree */ /* free value list */ freeValues( availableValues ); return (0); } /* end main */
int main( int argc, char *argv[] ) { int numInputs; Layer *hiddenLayer, *outputLayer; TestCase testCase; int i; initRand(); if( !processArguments( argc, argv ) ) { fprintf( stderr, "Usage: main [-r, -t] [node definition file] [input file, training file]\n" ); exit( EXIT_FAILURE ); } numInputs = buildLayers( &hiddenLayer, &outputLayer ); if( !numInputs ) { exit( EXIT_FAILURE ); } getDefaultTestCase( numInputs, outputLayer->numNodes, &testCase ); if( trainingFlag ) { for( i = 0; i < 1000; ++i ) { populateNextTestCase( &testCase ); train( &testCase, hiddenLayer, outputLayer ); } if( !persistWeights( numInputs, hiddenLayer, outputLayer ) ) { exit( EXIT_FAILURE ); } } else { while( populateNextTestCase( &testCase ) == NEW_INPUT ) { forwardPropagate( testCase.inputs, hiddenLayer, outputLayer ); printTestResults( testCase.inputs, outputLayer, testCase.desiredOutputs ); } } exit( EXIT_SUCCESS ); }
void Benchmark::test(const int algorithm, vector<deque<int>> &out, int n, int m) { out.clear(); out.resize(queries.size()); size_t memoryUsed; int preparingTime; vector<int> searchingTimes(numberOfTestingCycles); ms start, end; string algorithmName = "Unkown"; switch (algorithm) { case 0: { algorithmName = "MinHash (UM)"; start = getTime(); memoryUsed = getCurrentMemoryUsed(); MinHashUM index(text, n, m); index.prepare(); memoryUsed = getCurrentMemoryUsed() - memoryUsed; end = getTime(); preparingTime = (end - start).count(); for (int i = 0; i < numberOfTestingCycles; i++) { out.clear(); out.resize(queries.size()); start = getTime(); index.query(queries, out); end = getTime(); searchingTimes[i] = (end - start).count(); } break; } case 1: { algorithmName = "MinHash (VP)"; start = getTime(); memoryUsed = getCurrentMemoryUsed(); MinHashVP index(text, n, m); index.prepare(); memoryUsed = getCurrentMemoryUsed() - memoryUsed; end = getTime(); preparingTime = (end - start).count(); for (int i = 0; i < numberOfTestingCycles; i++) { out.clear(); out.resize(queries.size()); start = getTime(); index.query(queries, out); end = getTime(); searchingTimes[i] = (end - start).count(); } break; } case 2: { algorithmName = "HashTable"; start = getTime(); memoryUsed = getCurrentMemoryUsed(); HashTable index(text); index.prepare(); memoryUsed = getCurrentMemoryUsed() - memoryUsed; end = getTime(); preparingTime = (end - start).count(); for (int i = 0; i < numberOfTestingCycles; i++) { out.clear(); out.resize(queries.size()); start = getTime(); index.query(queries, out); end = getTime(); searchingTimes[i] = (end - start).count(); } break; } case 3: { algorithmName = "FMIndex"; start = getTime(); memoryUsed = getCurrentMemoryUsed(); FMIndex index(text); index.prepare(); memoryUsed = getCurrentMemoryUsed() - memoryUsed; end = getTime(); preparingTime = (end - start).count(); for (int i = 0; i < numberOfTestingCycles; i++) { out.clear(); out.resize(queries.size()); start = getTime(); index.query(queries, out); end = getTime(); searchingTimes[i] = (end - start).count(); } break; } default: cout << "Unkown algorithm." << endl; return; } printTestResults(algorithmName, pair<int, int>(n, m), vector<int>({ numberOfElements(out), (int)(memoryUsed / 1024 / 1024), preparingTime, averageValue(searchingTimes) }) ); }
/** Main entry point for the idl compiler. */ int main(int argc, char **argv) { NOMClassMgr *NOMClassMgrObject; HREGDLL hReg=NULL; AClass* aObject; BClass* bObject; /* Unit test */ NOMArray* nArray; TestNomObject* tstNomObject; TestNOMClassMgr* tstNOMClassMgr; int a; #if 0 /* Preload the DLL otherwise it won't be found by the GC registering function */ if((rc=DosLoadModule(uchrError, sizeof(uchrError),"nobjtk.dll", &hModuleGC))!=NO_ERROR) { printf("DosLoadmodule for nobjtk.dll failed with rc=0x%x because of module %s.\n", (int)rc, uchrError); return 1; }; fprintf(stderr, "DLL handle for nobjtk.dll is: 0x%x\n", (int)hModuleGC); #endif nomInitGarbageCollection(NULL); /* Register DLLs with the garbage collector */ hReg=nomBeginRegisterDLLWithGC(); if(NULL==hReg) return 1; #if 0 //g_assert(nomRegisterDLLByName(hReg, "GLIB2.DLL" )); //g_assert(nomRegisterDLLByName(hReg, "GOBJECT2.DLL")); g_assert(nomRegisterDLLByName(hReg, "GMODULE2.DLL")); g_assert(nomRegisterDLLByName(hReg, "GDK2.DLL")); g_assert(nomRegisterDLLByName(hReg, "GDKPIX2.DLL")); g_assert(nomRegisterDLLByName(hReg, "GTK2.DLL" )); g_assert(nomRegisterDLLByName(hReg, "ATK.DLL" )); #endif g_assert(nomRegisterDLLByName(hReg, "NOBJTK.DLL")); nomEndRegisterDLLWithGC(hReg); g_message("NOM test application started."); /* Init NOM */ NOMClassMgrObject=nomEnvironmentNew(); g_message("\n"); g_message("================================================================"); g_message("===== Testing AClass, child of NOMObject ====="); g_message("================================================================"); /* Try to create an AClass object */ aObject=createAClassObject(); g_assert(aObject); /* -- Call methods on the object --- */ tstAClassInstanceVarInitValues(aObject); tstSetAClassInstanceVar(aObject); g_message("================================================================"); g_message("===== Testing BClass, child of AClass ====="); g_message("================================================================"); /* Try to create an AClass object */ bObject=createBClassObject(); g_assert(bObject); tstAClassInstanceVarInitValues(bObject); tstBClassInstanceVarInitValues(bObject); tstSetAClassInstanceVar(bObject); tstSetBClassInstanceVar(bObject); nomPrintf("\n"); g_message("================================================================"); g_message("===== Testing NOMObject base class ====="); g_message("================================================================"); tstNomObject=TestNomObjectNew(); _setClassMgrObject(tstNomObject, NOMClassMgrObject, NULL); nArray=_runTests(tstNomObject, NULL); nomPrintf("\n"); printTestResults(nArray); nomPrintf("\n"); g_message("================================================================"); g_message("===== Testing NOMClassMgr base class ====="); g_message("================================================================"); tstNOMClassMgr=TestNOMClassMgrNew(); _setClassMgrObject(tstNOMClassMgr, NOMClassMgrObject, NULL); nArray=_runTests(tstNOMClassMgr, NULL); nomPrintf("\n"); printTestResults(nArray); return 0; };