crown  1.0.0
src/step_allocation_fastest.cpp
Go to the documentation of this file.
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 <fstream>
00023 
00024 #include <crown/allocation.h>
00025 
00026 #include <pelib/AmplOutput.hpp>
00027 #include <pelib/AmplInput.hpp>
00028 #include <pelib/Vector.hpp>
00029 #include <pelib/Matrix.hpp>
00030 #include <pelib/GraphML.hpp>
00031 
00032 using namespace std;
00033 using namespace pelib;
00034 
00035 int
00036 main(int argc, char **argv)
00037 {
00038         Algebra mapp;
00039 
00040         ifstream taskgraph(argv[1], std::ios::in);
00041         ifstream platform(argv[2], std::ios::in);
00042         ifstream parameters(argv[3], std::ios::in);
00043 
00044         Algebra alg_arch = AmplInput(AmplInput::floatHandlers()).parse(platform);
00045         Platform *arch = new Platform(alg_arch);
00046         Algebra param = AmplInput(AmplInput::floatHandlers()).parse(parameters);
00047         Taskgraph *tg = GraphML().parse(taskgraph);
00048         Algebra input = tg->buildAlgebra(*arch);
00049         taskgraph.close();
00050         platform.close();
00051         parameters.close();
00052 
00053         input = input.merge(arch->buildAlgebra());
00054         input = input.merge(param);
00055 
00056         delete arch;
00057         delete tg;
00058 
00059         cout << setprecision(6)
00060         << setiosflags(ios::fixed)
00061         << setiosflags(ios::showpoint);
00062 
00063         mapp = allocation_fastest(input);
00064 
00065         // Garbage to make output to look like Ampl/Gurobi output
00066         cout << "Presolve eliminates 0 constraints and 0 variables." << endl;
00067         cout << "Substitution eliminates 0 variables." << endl;
00068         cout << "Adjusted problem:" << endl;
00069         cout << "0 variables:" << endl;
00070         cout << "       0 binary variables" << endl;
00071         cout << "       0 linear variable" << endl;
00072         cout << "0 constraints, all linear; 0 nonzeros" << endl;
00073         cout << "0 linear objective; 0 nonzero." << endl;
00074         cout << endl;
00075         cout << "Gurobi 5.1.0: timelim 300" << endl;
00076         cout << "Gurobi 5.1.0: heuristic solution; nonoptimal 0" << endl;
00077         cout << "29 simplex iterations" << endl;
00078         cout << "plus 1 simplex iteration for intbasis" << endl;
00079 
00080         AmplOutput(AmplOutput::floatHandlers()).dump(cerr, Scalar<float>("complexity", allocation_fastest_complexity(mapp)));
00081 
00082         AmplOutput(AmplOutput::floatHandlers()).dump(cout, mapp);
00083 
00084         return EXIT_SUCCESS;
00085 }
00086