| 39 | using namespace Gecode; |
| 40 | |
| 41 | int main(int argc, char** argv) { |
| 42 | |
| 43 | Support::Timer t_total; |
| 44 | t_total.start(); |
| 45 | FlatZinc::FlatZincOptions opt("Gecode/FlatZinc"); |
| 46 | opt.parse(argc, argv); |
| 47 | |
| 48 | if (argc!=2) { |
| 49 | cerr << "Usage: " << argv[0] << " [options] <file>" << endl; |
| 50 | cerr << " " << argv[0] << " -help for more information" << endl; |
| 51 | exit(EXIT_FAILURE); |
| 52 | } |
| 53 | |
| 54 | const char* filename = argv[1]; |
| 55 | opt.name(filename); |
| 56 | |
| 57 | FlatZinc::Printer p; |
| 58 | FlatZinc::FlatZincSpace* fg = nullptr; |
| 59 | Rnd rnd(opt.seed()); |
| 60 | try { |
| 61 | if (!strcmp(filename, "-")) { |
| 62 | fg = FlatZinc::parse(cin, p, std::cerr, nullptr, rnd); |
| 63 | } else { |
| 64 | fg = FlatZinc::parse(filename, p, std::cerr, nullptr, rnd); |
| 65 | } |
| 66 | |
| 67 | if (fg) { |
| 68 | fg->createBranchers(p, fg->solveAnnotations(), opt, |
| 69 | false, std::cerr); |
| 70 | fg->shrinkArrays(p); |
| 71 | if (opt.output()) { |
| 72 | std::ofstream os(opt.output()); |
| 73 | if (!os.good()) { |
| 74 | std::cerr << "Could not open file " << opt.output() << " for output." |
| 75 | << std::endl; |
| 76 | exit(EXIT_FAILURE); |
| 77 | } |
| 78 | fg->run(os, p, opt, t_total); |
| 79 | os.close(); |
| 80 | } else { |
| 81 | fg->run(std::cout, p, opt, t_total); |
| 82 | } |
| 83 | } else { |
| 84 | exit(EXIT_FAILURE); |
| 85 | } |
| 86 | delete fg; |
| 87 | } catch (FlatZinc::Error& e) { |
| 88 | std::cerr << "Error: " << e.toString() << std::endl; |
| 89 | return 1; |
| 90 | } |
| 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | // STATISTICS: flatzinc-any |
nothing calls this directly
no test coverage detected