/** * Load Road Network Data */ void loadData(char *path) { readBuffer = (char *)malloc(nowSize); LoadNode(path); LoadEdge(path); LoadNet(path); }
void CPnet::CPMenu(void) { int selection; while(selection != 8) { cout << "=================================================================\n"; cout << "\tPerceptron Neural Net using Perceptron learning rule\n"; cout << "=================================================================\n\n"; cout << "[1]. Create a new Neural Net" << endl; cout << "[2]. Train the current Neural Net" << endl; cout << "[3]. Load a Neural Net from file" << endl; cout << "[4]. Test Neural Net" << endl; cout << "[5]. Save the current Net" << endl; cout << "[6]. Set training display" << endl; cout << "[7]. Display Neural Net Info" << endl; cout << "[8]. Quit the program" << endl << endl; cout << "selection: "; selection = getche() - '0'; WAIT(0.5*SECOND); CLEAR_SCREEN(); switch(selection) { case 1: SaveCurrentData(); cout << "\nCreating Neural Net..."; WAIT(1*SECOND); CreateNet(); break; case 2: if (bNeuralNetCreated) { cout << "\nTraining \"" << szNeuralNetName << "\" function..." << endl; WAIT(0.7*SECOND); cout << "Enter Learning rate: "; cin >> LEARNING_RATE; WAIT(0.7*SECOND); cout << "Enter number of epochs: "; cin >> CPN_ITER; NormalizeInput(); NormalizeTarget(); CLEAR_SCREEN(); WAIT(0.7*SECOND); cout << "\nTraining \"" << szNeuralNetName << "\" function..." << endl; WAIT(2*SECOND); CLEAR_SCREEN(); TrainNetwork(); } else { UpdateScreen(); } break; case 3: SaveCurrentData(); cout << "\n\nLoading Neural Net..." << endl; WAIT(0.85*SECOND); cout << "\nEnter the name of the Neural Net or the complete path where " << "the Net data can be found\n: "; cin.sync(); cin.getline(szNeuralNetName, MAX_PATH); LoadNet(); WAIT(1.5*SECOND); CLEAR_SCREEN(); cout << "\n\n\n\n\n\n\n\n\n\t\t\tNeural Net loaded successfuly!" << endl; UpdateScreen(); break; case 4: if (bNeuralNetTrained) { cout << "\nTesting \"" << szNeuralNetName << "\" function..." << endl; cout << "1. default test" << endl; cout << "2. selective test" << endl; cout << "\nselection: "; int nNumOfPattern; int sel = getche(); CLEAR_SCREEN(); WAIT(0.7*SECOND); DeNormalizeInput(); DeNormalizeTarget(); switch(sel) { case '1': TestNetwork(); break; case '2': cout << "\nEnter the number of patterns to be tested: "; cin >> nNumOfPattern; SelectiveTest(nNumOfPattern); UpdateScreen(); break; default: cout << "\nunknown selection." << endl; UpdateScreen(); } } else { UpdateScreen(); } break; case 5: if (bNeuralNetCreated) { if (fExist(szNeuralNetName)) { CLEAR_SCREEN(); WAIT(0.5*SECOND); cout << "\n\"" << szNeuralNetName << "\""; cout << ": this file already exist,do you want to overwrite it?" << endl; cout << "Yes(y) No(n): "; char response; cin >> response; response = tolower(response); if(response == 'y') { SaveNet(); } else { WAIT(0.5*SECOND); cout << "\nPlease enter a new name or a complete file path where the " << "Neural Net will be saved\n: "; cin.sync(); cin.getline(szNeuralNetName, MAX_PATH); SaveNet(); } } else { SaveNet(); } CLEAR_SCREEN(); WAIT(1.5*SECOND); cout << "\n\n\n\n\n\n\n\n\n\t\t\tThe Neural Net was saved successfuly!" << endl; }