this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
3/*
4 * Main authors:
5 * Guido Tack <guido.tack@monash.edu>
6 * Gleb Belov <gleb.belov@monash.edu>
7 */
8
9/* This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
12
13/* This (main) file coordinates flattening and solving.
14 * The corresponding modules are flexibly plugged in
15 * as derived classes, prospectively from DLLs.
16 * A flattening module should provide MinZinc::GetFlattener()
17 * A solving module should provide an object of a class derived from SolverFactory.
18 * Need to get more flexible for multi-pass & multi-solving stuff TODO
19 */
20
21#include <minizinc/solver.hh>
22
23#include <chrono>
24#include <cstdlib>
25#include <ctime>
26#include <fstream>
27#include <iomanip>
28#include <iostream>
29#include <ratio>
30
31using namespace std;
32using namespace MiniZinc;
33
34int main(int argc, const char** argv) {
35 Timer starttime;
36 bool fSuccess = false;
37
38 try {
39 MznSolver slv(std::cout, std::cerr);
40 try {
41 std::vector<std::string> args(argc - 1);
42 for (int i = 1; i < argc; i++) args[i - 1] = argv[i];
43 fSuccess = (slv.run(args, "", argv[0]) != SolverInstance::ERROR);
44 } catch (const LocationException& e) {
45 if (slv.get_flag_verbose()) std::cerr << std::endl;
46 std::cerr << e.loc() << ":" << std::endl;
47 std::cerr << e.what() << ": " << e.msg() << std::endl;
48 } catch (const Exception& e) {
49 if (slv.get_flag_verbose()) std::cerr << std::endl;
50 std::string what = e.what();
51 std::cerr << what << (what.empty() ? "" : ": ") << e.msg() << std::endl;
52 } catch (const exception& e) {
53 if (slv.get_flag_verbose()) std::cerr << std::endl;
54 std::cerr << e.what() << std::endl;
55 } catch (...) {
56 if (slv.get_flag_verbose()) std::cerr << std::endl;
57 std::cerr << " UNKNOWN EXCEPTION." << std::endl;
58 }
59
60 if (slv.get_flag_verbose()) {
61 std::cerr << " Done (";
62 cerr << "overall time " << starttime.stoptime() << ")." << std::endl;
63 }
64 return !fSuccess;
65 } catch (const Exception& e) {
66 std::string what = e.what();
67 std::cerr << what << (what.empty() ? "" : ": ") << e.msg() << std::endl;
68 std::exit(EXIT_FAILURE);
69 }
70} // int main()