crown
1.0.0
|
00001 /* 00002 Copyright 2015 Nicolas Melot 00003 00004 This file is part of Crown. 00005 00006 Crown is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 Crown is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Crown. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 00022 #include <iostream> 00023 #include <cstdlib> 00024 #include <fstream> 00025 #include <string> 00026 #include <boost/regex.hpp> 00027 #include <iomanip> 00028 00029 #include <pelib/AmplInput.hpp> 00030 #include <pelib/AmplOutput.hpp> 00031 00032 #include <pelib/AmplOutputScalar.hpp> 00033 #include <pelib/AmplOutputVector.hpp> 00034 #include <pelib/AmplOutputSet.hpp> 00035 #include <pelib/AmplOutputMatrix.hpp> 00036 00037 #include <pelib/AmplInputScalar.hpp> 00038 #include <pelib/AmplInputVector.hpp> 00039 #include <pelib/AmplInputSet.hpp> 00040 #include <pelib/AmplInputMatrix.hpp> 00041 00042 using namespace pelib; 00043 using namespace std; 00044 00045 const int b = 2; 00046 00047 typedef map<int, int> TaskWidthVector; 00048 typedef map<int, int> TaskScheduleVector; 00049 typedef map<int, TaskScheduleVector> ProcScheduleMatrix; 00050 00051 int 00052 group_size(int group, int p, int b) 00053 { 00054 return (int)(p / pow(b, floor((log(group) / log(b))))); 00055 } 00056 00057 Algebra 00058 parse(AlgebraParser &parser, std::istream &input) 00059 { 00060 Algebra rec; 00061 00062 try { 00063 rec = parser.parse(input); 00064 } catch(ParseException &e) 00065 { 00066 std::cerr << e.what() << std::endl; 00067 } 00068 00069 return rec; 00070 } 00071 00072 int 00073 main(int argc, char **argv) 00074 { 00075 AmplOutput input(AmplOutput::floatHandlers()); 00076 AmplOutput output(AmplOutput::floatHandlers()); 00077 Algebra rec; 00078 00079 // Open input file 00080 //std::ifstream myfile; 00081 //myfile.open (argv[1], std::ios::in); 00082 00083 // Load input file 00084 //rec = parse(input, myfile); 00085 rec = parse(input, cin); 00086 00087 // Close input file 00088 //myfile.close(); 00089 00090 cout << setprecision(6) 00091 << setiosflags(ios::fixed) 00092 << setiosflags(ios::showpoint); 00093 00094 Vector<int, float> group("step_group", rec.find<Vector<int, float> >("group")->getValues()); 00095 Vector<int, float> frequency("step_frequency", rec.find<Vector<int, float> >("frequency")->getValues()); 00096 00097 cout << "option show_stats 0; \n\ 00098 \n\ 00099 Presolve eliminates 29 constraints and 3 variables.\n\ 00100 Substitution eliminates 191 variables.\n\ 00101 Adjusted problem:\n\ 00102 377 variables:\n\ 00103 314 binary variables\n\ 00104 63 linear variables\n\ 00105 131 constraints, all linear; 740 nonzeros\n\ 00106 1 linear objective; 314 nonzeros.\n\ 00107 \n\ 00108 Gurobi 5.1.0: timelim 300\n\ 00109 Gurobi 5.1.0: optimal solution; objective 329.92\n\ 00110 plus 63 simplex iterations for intbasis\n\ 00111 Time after optimization:\n\ 00112 step_time [*] :=\n\ 00113 1 0 5 6 9 2 13 16 17 5 21 8 25 5 29 3\n\ 00114 2 4 6 3 10 6 14 8 18 18 22 4 26 17 30 2\n\ 00115 3 2 7 3 11 9 15 2 19 3 23 4 27 1 31 5\n\ 00116 4 1 8 7 12 4 16 3 20 6 24 11 28 4 32 4\n\ 00117 ;\n\ 00118 \n\ 00119 Static, dynamic and combined energy:\n\ 00120 step_static = 41.92\n\ 00121 \n\ 00122 step_dynamic = 288\n\ 00123 \n\ 00124 step_energy = 329.92\n\ 00125 \n\ 00126 Task mapping to core groups and frequency:" << endl; 00127 00128 output.dump(cout, &group); 00129 cout << endl; 00130 output.dump(cout, &frequency); 00131 00132 cout << endl; 00133 cout << "# time: 0.50049090385437" << endl; 00134 cout << endl; 00135 00136 return EXIT_SUCCESS; 00137 }