git-subtree-dir: software/mza git-subtree-split: f970a59b177c13ca3dd8aaef8cc6681d83b7e813
48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
|
|
|
/*
|
|
* Main authors:
|
|
* Gleb Belov <gleb.belov@monash.edu>
|
|
*/
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/* This (main) file coordinates flattening and solving.
|
|
* The corresponding modules are flexibly plugged in
|
|
* as derived classes, prospectively from DLLs.
|
|
* A flattening module should provide MinZinc::GetFlattener()
|
|
* A solving module should provide an object of a class derived from SolverFactory.
|
|
* Need to get more flexible for multi-pass & multi-solving stuff TODO
|
|
*/
|
|
|
|
#include <minizinc/solver.hh>
|
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
using namespace MiniZinc;
|
|
|
|
int main(int argc, const char** argv) {
|
|
std::vector<std::string> args;
|
|
for (int i = 1; i < argc; ++i) {
|
|
args.emplace_back(argv[i]);
|
|
}
|
|
|
|
try {
|
|
MznSolver slv(args);
|
|
auto result = slv.run();
|
|
std::cout << result.second;
|
|
} catch (const LocationException& e) {
|
|
std::cerr << std::endl;
|
|
std::cerr << e.loc() << ":" << std::endl;
|
|
std::cerr << e.what() << ": " << e.msg() << std::endl;
|
|
} catch (const Exception& e) {
|
|
std::cerr << std::endl;
|
|
std::string what = e.what();
|
|
std::cerr << what << (what.empty() ? "" : ": ") << e.msg() << std::endl;
|
|
}
|
|
return 0;
|
|
}
|