/* TRANSAX - Axial Transportation Polytope Generator TRANSPLAN - Planar Transportation Polytope Generator This material is based upon work supported by the National Science Foundation under Grant #DMS-0135345. Copyright (C) 2006 Edward D. Kim. http://www.math.ucdavis.edu/~ekim/ */ #include #include #include #include #include #include "manipulations.h" #include "trans.h" using namespace std; typedef vector intvec; int main(int argc, char *argv[]) { unsigned long int arg_start; string transp_type; char *argv0 = argv[0]; stringstream argv0_ss; argv0_ss << argv0; // cout << argv0_ss.str() << endl << endl; if (argv0_ss.str().find("transax", 0) != string::npos) { transp_type = "axial"; } else if (argv0_ss.str().find("transplan", 0) != string::npos) { transp_type = "planar"; } else { cerr << "Program name error!!!"; } // Print program banner to stderr: if (transp_type == "axial") { cerr << "TRANSAX - Axial Transportation Polytope Generator" << endl << endl; } else { cerr << "TRANSPLAN - Planar Transportation Polytope Generator" << endl << endl; } cerr << "This material is based upon work supported by "; cerr << "the National Science Foundation under Grant #DMS-0135345." << endl << endl; if (argc < 3) { cerr << endl << "Need a minimum of 2 integer arguments!" << endl; return -1; } // Rand? bool rand; char *argv1 = argv[1]; stringstream argv1_ss; argv1_ss << argv1; if (argv1_ss.str()=="rand") { // Generate one random polytope rand = true; arg_start = 2; if (argc < 4) { cerr << endl << "Need a minimum of 2 integer arguments!" << endl; return -1; } cout << "Option 'rand' is on. Will generate one random polytope." << endl; } else { rand = false; arg_start = 1; } ofstream log_file ("trans.log", ios::app ); if (! log_file) { // Always test file open cout << "Error opening log file!" << endl; } log_file << "Generation began at: " << current_time_string() << endl; log_file << "Transportation Polytope Type: " << transp_type << endl; if (rand) { log_file << "Option 'rand' is on. Will generate one random polytope." << endl; } trans transp(transp_type); intvec margin_sizes; log_file << "Margin sizes: "; for (unsigned long int i=arg_start; i < (argc); i++) { // Tack on each margin size (from arguments) to the vector // margin_sizes.push_back(atoi(argv[i])); transp.add_margin_size( atol(argv[i]) ); log_file << argv[i] << " "; } log_file << endl; cout << transp.compute_matrix_a() << endl; cout << transp.store_a_transpose() << endl; if (rand) { // Randomly generate one cout << transp.generate_one_random_polytope() << endl; } else { // Compute all cout << transp.make_point_configuraton_polymake_file() << endl; cout << transp.apply_gale_transform() << endl; cout << transp.find_regular_triangulations_and_generate_polytopes() << endl; //cout << transp.find_regular_triangulations() << endl; //cout << transp.generate_cones() << endl; //cout << transp.find_chamberinterior_point_and_make_polytopes() << endl; cout << "Checking chamber consistency..." << endl; transp.check_cone_interiors(); cout << "Check complete." << endl; } log_file << "Generation finished at: " << current_time_string() << endl << endl; log_file.close(); return 0; }