int main() { /* Repeat Loop Head */ char repeater('0'); while( repeater == '0') { /* Constants */ // Locations const int BUILDINGS(6), CTLM(0), MEYER_HALL(1), COOLBAUGH_HALL(2), GREEN_CENTER(3), BERTHOUD_HALL(4), BROWN_HALL(5); const string BNAMES[] = { "CTLM", "Meyer Hall", "Coolbaugh Hall", "Green Center", "Berthoud Hall", "Brown Hall", "Free Time" }; const string LNAMES[] = { "CTLM", "Meyer Hall", "Coolbaugh Hall", "Green Center", "Berthoud Hall", "Brown Hall", "Kafadar", "Library", "Student Center", "Rec Center" }; // Commons const int COMMONS(4), KAFADAR(0), LIBRARY(1), STUDENT_CENTER(2), REC_CENTER(3); // Time Specifications const int DAYS(2); const int HOURS(8); const int SIMWEEKS = 2; const int DAYS_IN_WEEK = 7; const int SATURDAY = 5; const string DNAMES[] = { "Monday, Wednesday, Friday", "Tues, Thursday" }; // Other Details const int LECTURES(5); const int FREE_BLOCK(BUILDINGS); /* Variables */ int schedule[DAYS][HOURS]; int locationCount[BUILDINGS + COMMONS] = {}; /* Header */ cout << "-- Schedule Simulator and Such --" << endl << endl; srand(readSeed()); /* Schedule Generator */ for(int i(0); i < DAYS; i++) { blocking( schedule[i], HOURS, BUILDINGS, LECTURES ); shuffler( schedule[i], HOURS ); } /* Simulate Multiple Weeks */ for( int d(0); d < SIMWEEKS * DAYS_IN_WEEK; d++ ) { if( d % DAYS_IN_WEEK < SATURDAY ) { // not the weekend for( int h(0); h < HOURS; h++ ) { int b = schedule[d % DAYS_IN_WEEK % DAYS][h]; // reduce d to either 0 or 1 (MWF or TR) if( b == FREE_BLOCK ) { // Pick a random common area int c = rand() % COMMONS; // choose one at random // add it to the count locationCount[BUILDINGS + c]++; } else { // in a building locationCount[b]++; } } } } /* Footer */ cout << endl; for( int d(0); d < DAYS; d++ ) { cout << DNAMES[d] << ": " << endl; for( int h(0); h < HOURS; h++ ) { cout << BNAMES[ schedule[d][h] ] << endl; } cout << endl << endl; } cout << endl << endl; for( int i(0); i < COMMONS + BUILDINGS; i++ ) { cout << LNAMES[i] << ": " << locationCount[i] << endl; } cout << endl << endl << endl << endl; /* Repeat Loop Foot */ repeater = '2'; while( repeater != '0' && repeater != '1') { cout << "0 to continue, 1 to quit." << endl; cin >> repeater; } cout << endl << endl; } system("PAUSE"); return 0; }
int main(int argc, char** argv) { boost::program_options::options_description options("Usage"); options.add_options() ("gridGraph", boost::program_options::value<int>(), "(int) The dimension of the square grid graph to use.") ("graphFile", boost::program_options::value<std::string>(), "(string) The path to a graphml file. ") ("completeGraph", boost::program_options::value<int>(), "(int) The number of vertices of the complete graph to use. ") ("opProbability", boost::program_options::value<std::string>(), "(float) The probability that an edge is operational") ("seed", boost::program_options::value<int>(), "(int) The random seed used to generate the random graphs") ("pointSize", boost::program_options::value<float>(), "(float) The size of graph vertices. Defaults to 0.1") ("interestVertices", boost::program_options::value<std::vector<int> >()->multitoken(), "(int) The vertices of interest, that should be connected. ") ("help", "Display this message"); #if defined(_WIN32) && defined(_MSC_VER) redirectConsoleOutput(); #endif boost::program_options::variables_map variableMap; try { boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options), variableMap); } catch(boost::program_options::error& ee) { std::cerr << "Error parsing command line arguments: " << ee.what() << std::endl << std::endl; std::cerr << options << std::endl; std::cerr << "Only one of gridGraph, graphFile and completeGraph can be specified" << std::endl; return -1; } if(variableMap.count("help") > 0) { std::cout << options << std::endl; std::cout << "Only one of gridGraph, graphFile and completeGraph can be specified" << std::endl; return 0; } boost::mt19937 randomSource; readSeed(variableMap, randomSource); mpfr_class probability; if(!readProbabilityString(variableMap, probability)) { std::cout << "Please enter a single value for input `opProbability'" << std::endl; return 0; } Context context = Context::emptyContext(); if(!readContext(variableMap, context, probability)) { return 0; } #if defined(_WIN32) registerQTPluginDir(); #endif float pointSize = 0.1f; if(variableMap.count("pointSize") >= 1) { pointSize = variableMap["pointSize"].as<float>(); } QApplication app(argc, argv); observationVisualiser viewer(context, randomSource, pointSize); viewer.show(); app.exec(); return 0; }