crown  1.0.0
src/step_mapping_ltlg.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/mapping.h>
00025 
00026 #include <pelib/AmplOutput.hpp>
00027 #include <pelib/AmplInput.hpp>
00028 #include <pelib/Vector.hpp>
00029 #include <pelib/Matrix.hpp>
00030 
00031 using namespace std;
00032 using namespace pelib;
00033 
00034 int
00035 main(int argc, char **argv)
00036 {
00037         ifstream taskgraph(argv[1], std::ios::in);
00038 
00039         Algebra input = AmplInput(AmplInput::floatHandlers()).parse(taskgraph);
00040         taskgraph.close();
00041 
00042         cout << setprecision(6)
00043         << setiosflags(ios::fixed)
00044         << setiosflags(ios::showpoint);
00045 
00046         input = mapping_ltlg(input);
00047 
00048         // Garbage to make output to look like Ampl/Gurobi output
00049         cout << "Presolve eliminates 0 constraints and 0 variables." << endl;
00050         cout << "Substitution eliminates 0 variables." << endl;
00051         cout << "Adjusted problem:" << endl;
00052         cout << "0 variables:" << endl;
00053         cout << "       0 binary variables" << endl;
00054         cout << "       0 linear variable" << endl;
00055         cout << "0 constraints, all linear; 0 nonzeros" << endl;
00056         cout << "0 linear objective; 0 nonzero." << endl;
00057         cout << endl;
00058         cout << "LTLG heuristic: heuristic solution; nonoptimal 0" << endl;
00059         cout << "29 simplex iterations" << endl;
00060         cout << "plus 1 simplex iteration for intbasis" << endl;
00061                 
00062         float quality = mapping_quality(input);
00063         Scalar<float> q("quality", quality);
00064         input.insert(&q);
00065 
00066         AmplOutput(AmplOutput::floatHandlers()).dump(cout, input);
00067         AmplOutput(AmplOutput::floatHandlers()).dump(cerr, Scalar<float>("complexity", mapping_ltlg_complexity(input)));
00068 
00069         return EXIT_SUCCESS;
00070 }
00071