void main() { TravelingEmployee emp("Bob", 45900, 'M', 10000); cout<<emp.getName()<<"'s transportation has accumulated "<<emp.getDistance()<<" miles."<<endl; emp.travel(225); cout<<emp.getName()<<"'s transportation has accumulated "<<emp.getDistance()<<" miles."<<endl; }
int main () { Employee emp(10,20,30); VendorBusiness(emp,&Employee::fun1); Employee emp1(11,21,31); VendorBusiness(&emp,&Employee::fun2); return 0; }
bool out_queue(PQUEUE pq,int *val) { if (emp(pq)) { printf("栈空!!\n"); return false; } else { *val=pq->front; pq->front=(pq->front+1)%6; return true; } }
TEST (test_person, person_test) { Person pers("BC"); EXPECT_STREQ(pers.getPosition().c_str(), "no money"); EXPECT_STREQ(pers.getEmployer().c_str(), "loser"); Employer emp("Nivis", "IT"); Position pos("programmer", "Linux programming"); EXPECT_TRUE(emp.hire(pers, pos)); EXPECT_STREQ(pers.getPosition().c_str(), "programmer"); EXPECT_STREQ(pers.getEmployer().c_str(), "Nivis"); }
void t_stl() { std::vector<unsigned> V(1024); //unsigned M = GaloisRuntime::LL::getMaxThreads(); std::cout << "stl:\nIterxSize\n"; std::cout << "Using " << 1 << " threads\n"; Galois::Timer t; t.start(); for (unsigned x = 0; x < iter; ++x) std::for_each(V.begin(), V.end(), emp()); t.stop(); std::cout << "STL(" << iter << "x" << V.size() << "): " << t.get() << "\n"; }
void main() { Department a, b, c; a.generate(); a.print(); b.generate(); b.print(); c.generate(); c = c + a; c.print(); Employee emp("Sergey", 15000, 30); a.add(emp); try { a.add(emp); } catch (std::exception &e) { std::cout << e.what() << std::endl; } try { b.remove(1); a.remove(30); c.remove(2); } catch (std::exception &e) { std::cout << e.what() << std::endl; } try { a.add("Igor", 25000, 30); if (!(a == b)) { a.add(*b[3]); } a.print(); } catch (std::exception &e) { std::cout << e.what() << std::endl; } std::cout <<"\n Count:"<< a.get_сount() << std::endl; system("pause"); }
int main(){ // Person *pers = new Person(std::string("Harald")); // std::cout << pers->getInfo()<<std::endl; // printPersonInfo(pers); // delete pers; // std::cout<<"---------------"<<std::endl; // Student *stud=new Student(std::string("Bernd"), std::string("1234")); // std::cout<<stud->getInfo()<<std::endl; // printPersonInfo(stud); // delete stud; // std::cout<<"---------------"<<std::endl; // Person *pStud=new Student("Holger", "9876"); // printPersonInfo(pStud); // delete pStud; Employee emp("Dieter","Mr. Schulz"); printPersonInfo(&emp); StudentAssistant assi("Mira","Bellen","Baum"); printPersonInfo(&assi); }
void t_doall() { std::vector<unsigned> V(1024); unsigned M = GaloisRuntime::LL::getMaxThreads(); std::cout << "doall:\nIterxSize\n"; while (M) { Galois::setActiveThreads(M); //GaloisRuntime::LL::getMaxThreads()); std::cout << "Using " << M << " threads\n"; Galois::Timer t; t.start(); for (unsigned x = 0; x < iter; ++x) Galois::do_all(V.begin(), V.end(), emp()); t.stop(); std::cout << "Galois(" << iter << "x" << V.size() << "): " << t.get() << "\n"; M >>= 1; } }
//Menu Options--------------- void FileManager::openFile() { string name; cout << "Enter the name of the file to open: "; cin >> name; while (name == "readme.txt" || name == "recent.txt") { cout << "\aOops... Those files are for read only choose another file to open" << endl; cin >> name; } name.append(".txt"); ifstream file; file.open(name); while(file.fail()) { cout << "\aFile with the name of " << name << " does not exist" << endl; cout << "Please try again." << endl; cout << "Enter the name of the file to open: "; cin >> name; name.append(".txt"); file.close(); file.open(name); } FileReader emp(name); if (emp.is_empty(name)) { cout << "File is empty." << endl; } else { cout << "\nThis is what the file has currently written" << endl << endl; } FileReader read(name); read.fileRead(); file.close(); Editor mem(name); mem.menu(); }
int main(int argc, char** argv) { const unsigned int T_SIZE = 3; // size for tournament selection const unsigned int VEC_SIZE = 3; // Number of object variables in genotypes const unsigned int POP_SIZE = 10; // Size of population const unsigned int MAX_GEN = 1000; // Maximum number of generation before STOP const unsigned int MIN_GEN = 10; // Minimum number of generation before ... const unsigned int STEADY_GEN = 10; // stop after STEADY_GEN gen. without improvement const float P_CROSS = 0.8; // Crossover probability const float P_MUT = 0.5; // mutation probability const double EPSILON = 0.01; // range for real uniform mutation double SIGMA = 0.3; // std dev. for normal mutation // some parameters for chosing among different operators const double hypercubeRate = 0.5; // relative weight for hypercube Xover const double segmentRate = 0.5; // relative weight for segment Xover const double uniformMutRate = 0.5; // relative weight for uniform mutation const double detMutRate = 0.5; // relative weight for det-uniform mutation const double normalMutRate = 0.5; // relative weight for normal mutation const unsigned int SEED = 42; // seed for random number generator po::options_description desc; std::string matrixdir, model, nullmodel, trainingset, testingset, lastrun; desc.add_options() ("matrixdir", po::value<std::string>(&matrixdir), "The directory set up by SOFT2Matrix") ("model", po::value<std::string>(&model), "The gene regulatory network model") ("nullmodel", po::value<std::string>(&nullmodel), "The gene regulatory network null (scrambled) model") ("trainingset", po::value<std::string>(&trainingset), "The list of arrays which have been selected for inclusion in the training set") ("testingset", po::value<std::string>(&testingset), "The list of arrays which have been selected for inclusion in the testing set") ("lastrun", po::value<std::string>(&lastrun), "The output file from the last run, to re-use scores from (optional)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); std::string wrong; if (!vm.count("help")) { if (!vm.count("matrixdir")) wrong = "matrixdir"; else if (!vm.count("model")) wrong = "model"; else if (!vm.count("trainingset")) wrong = "trainingset"; else if (!vm.count("testingset")) wrong = "testingset"; else if (!vm.count("nullmodel")) wrong = "nullmodel"; } if (wrong != "") std::cerr << "Missing option: " << wrong << std::endl; if (vm.count("help") || wrong != "") { std::cout << desc << std::endl; return 1; } if (!fs::is_directory(matrixdir)) { std::cout << "Matrix directory doesn't exist." << std::endl; return 1; } if (!fs::is_regular(model)) { std::cout << "Model file doesn't exist or not regular file." << std::endl; return 1; } if (!fs::is_regular(nullmodel)) { std::cout << "Null model file doesn't exist or not regular file." << std::endl; return 1; } if (!fs::is_regular(trainingset)) { std::cout << "Training set file doesn't exist or not regular file." << std::endl; return 1; } if (!fs::is_regular(testingset)) { std::cout << "Testing set file doesn't exist or not regular file." << std::endl; return 1; } std::list<double> lastRun; if (fs::is_regular(lastrun)) { std::ifstream flastrun(lastrun.c_str()); static const boost::regex prev(".*SVM Result: .* Result \\(([^\\)]+)\\).*"); while (flastrun.good()) { std::string l; std::getline(flastrun, l); boost::smatch m; if (!boost::regex_match(l, m, prev)) { continue; } lastRun.push_back(strtod(m[1].str().c_str(), NULL)); } } ExpressionMatrixProcessor emp(matrixdir); GRNModel m(model, emp, 30); GRNModel m2(nullmodel, emp, 30); std::list<std::string> trainingArrays, testingArrays; m.loadArraySet(trainingset, trainingArrays); m.loadArraySet(testingset, testingArrays); m.loadSVMTrainingData(trainingArrays); m2.loadArraySet(trainingset, trainingArrays); m2.loadArraySet(testingset, testingArrays); m2.loadSVMTrainingData(trainingArrays); // We seed it just so we can restart if need be. rng.reseed(SEED); EvaluateSVMFit eval(m, m2, trainingArrays, lastRun, 30, testingArrays.size()); std::vector<double> minVals, maxVals; // log(gamma) minVals.push_back(-15); maxVals.push_back(15); // log(C) minVals.push_back(-15); maxVals.push_back(2); // nu minVals.push_back(0); maxVals.push_back(1); eoRealVectorBounds rvb(minVals, maxVals); eoRealInitBounded<Indi> random(rvb); eoPop<Indi> pop(POP_SIZE, random); apply<Indi>(eval, pop); pop.sort(); std::cout << "Initial Population" << std::endl; std::cout << pop; eoDetTournamentSelect<Indi> selectOne(T_SIZE); eoSelectPerc<Indi> select(selectOne);// by default rate==1 eoGenerationalReplacement<Indi> replace; eoSegmentCrossover<Indi> xoverS; eoHypercubeCrossover<Indi> xoverA; eoPropCombinedQuadOp<Indi> xover(xoverS, segmentRate); xover.add(xoverA, hypercubeRate, true); eoUniformMutation<Indi> mutationU(EPSILON); eoDetUniformMutation<Indi> mutationD(EPSILON); eoNormalMutation<Indi> mutationN(SIGMA); eoPropCombinedMonOp<Indi> mutation(mutationU, uniformMutRate); mutation.add(mutationD, detMutRate); mutation.add(mutationN, normalMutRate, true); eoGenContinue<Indi> genCont(MAX_GEN); eoSteadyFitContinue<Indi> steadyCont(MIN_GEN, STEADY_GEN); eoCombinedContinue<Indi> continuator(genCont); continuator.add(steadyCont); eoSGATransform<Indi> transform(xover, P_CROSS, mutation, P_MUT); eoEasyEA<Indi> gga(continuator, eval, select, transform, replace); gga(pop); pop.sort(); std::cout << "Final Population:" << std::endl << pop << std::endl; return 0; }
void FileManager::copyFile() { string source, destination, content; FileReader emp(source); do { cout << "Enter the name of the source file: "; cin >> source; source.append(".txt"); if (FileManager::fileExist(source)) { cout << "This file does not exist. Try a file that exist." << endl; } if (emp.is_empty(source) && !FileManager::fileExist(source)) { cout << "\aThis file is empty. Try a file with something on it.\n"; } } while (emp.is_empty(source)); fstream file(source); while (!file.eof()) { getline(file, content, '~'); } if (file.fail()) { cout << "\aFile with the name of " << source << " does not exist" << endl; } else { do { cout << "Enter the name of the destination file: "; cin >> destination; destination.append(".txt"); if (FileManager::toUpper(destination) == FileManager::toUpper(source)) { cout << "\aYou cant clone a file to itself. Try Again. \n\n Destination File: "; cin >> destination; destination.append(".txt"); } } while (FileManager::toUpper(destination) == FileManager::toUpper(source)); destination.append(".txt"); ofstream file2(destination); fstream file3(destination); if (file3.is_open()) { file3 << content; FileManager::loading(); cout << "\aFile Cloning Completed." << endl << "You are editing " << destination << endl; } file.close(); if (file3.is_open()) { file3.close(); Editor edit(destination); edit.menu(); } else { cout << "\aWhoops! You broke something. Try Again!" << endl; } } }