A set of benchmarks to compare a new prototype MiniZinc implementation
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#ifndef __MINIZINC_FLATTENER_H__ 14#define __MINIZINC_FLATTENER_H__ 15 16#include <minizinc/MIPdomains.hh> 17#include <minizinc/astexception.hh> 18#include <minizinc/builtins.hh> 19#include <minizinc/file_utils.hh> 20#include <minizinc/flatten.hh> 21#include <minizinc/flatten_internal.hh> // temp., TODO 22#include <minizinc/model.hh> 23#include <minizinc/optimize.hh> 24#include <minizinc/options.hh> 25#include <minizinc/parser.hh> 26#include <minizinc/passes/compile_pass.hh> 27#include <minizinc/solver_instance.hh> 28#include <minizinc/timer.hh> 29#include <minizinc/typecheck.hh> 30#include <minizinc/utils.hh> 31 32#include <ctime> 33#include <iomanip> 34#include <memory> 35#include <string> 36#include <vector> 37#ifdef HAS_GECODE 38#include <minizinc/passes/gecode_pass.hh> 39#endif 40 41namespace MiniZinc { 42 43class Flattener { 44private: 45 std::unique_ptr<Env> pEnv; 46 std::ostream& os; 47 std::ostream& log; 48 49public: 50 Flattener(std::ostream& os, std::ostream& log, const std::string& stdlibDir); 51 ~Flattener(); 52 bool processOption(int& i, std::vector<std::string>& argv); 53 void printVersion(std::ostream&); 54 void printHelp(std::ostream&); 55 56 void flatten(const std::string& modelString = std::string(), 57 const std::string& modelName = std::string("stdin")); 58 void printStatistics(std::ostream&); 59 60 void set_flag_verbose(bool f) { flag_verbose = f; } 61 bool get_flag_verbose() const { return flag_verbose; } 62 void set_flag_statistics(bool f) { flag_statistics = f; } 63 bool get_flag_statistics() const { return flag_statistics; } 64 void set_flag_timelimit(unsigned long long int t) { fopts.timeout = t; } 65 unsigned long long int get_flag_timelimit(void) { return fopts.timeout; } 66 void set_flag_output_by_default(bool f) { fOutputByDefault = f; } 67 Env* getEnv() const { 68 assert(pEnv.get()); 69 return pEnv.get(); 70 } 71 bool hasInputFiles(void) const { 72 return !filenames.empty() || flag_stdinInput || !flag_solution_check_model.empty(); 73 } 74 75 SolverInstance::Status status = SolverInstance::UNKNOWN; 76 77private: 78 Env* multiPassFlatten(const std::vector<std::unique_ptr<Pass> >& passes); 79 80 bool fOutputByDefault = false; // if the class is used in mzn2fzn, write .fzn+.ozn by default 81 std::vector<std::string> filenames; 82 std::vector<std::string> datafiles; 83 std::vector<std::string> includePaths; 84 bool is_flatzinc = false; 85 86 bool flag_ignoreStdlib = false; 87 bool flag_typecheck = true; 88 bool flag_verbose = false; 89 bool flag_newfzn = false; 90 bool flag_optimize = true; 91 bool flag_chain_compression = true; 92 bool flag_werror = false; 93 bool flag_only_range_domains = false; 94 bool flag_allow_unbounded_vars = false; 95 bool flag_noMIPdomains = false; 96 int opt_MIPDmaxIntvEE = 0; 97 double opt_MIPDmaxDensEE = 0.0; 98 bool flag_statistics = false; 99 bool flag_stdinInput = false; 100 bool flag_allow_multi_assign = false; 101 102 bool flag_gecode = false; 103 bool flag_two_pass = false; 104 bool flag_sac = false; 105 bool flag_shave = false; 106 unsigned int flag_pre_passes = 1; 107 108 std::string std_lib_dir; 109 std::string globals_dir; 110 111 bool flag_no_output_ozn = false; 112 std::string flag_output_base; 113 std::string flag_output_fzn; 114 std::string flag_output_ozn; 115 std::string flag_output_paths; 116 bool flag_keep_mzn_paths = false; 117 bool flag_output_fzn_stdout = false; 118 bool flag_output_ozn_stdout = false; 119 bool flag_output_paths_stdout = false; 120 bool flag_instance_check_only = false; 121 bool flag_model_check_only = false; 122 bool flag_model_interface_only = false; 123 bool flag_model_types_only = false; 124 FlatteningOptions::OutputMode flag_output_mode = FlatteningOptions::OUTPUT_ITEM; 125 bool flag_output_objective = false; 126 bool flag_output_output_item = false; 127 std::string flag_solution_check_model; 128 bool flag_compile_solution_check_model = false; 129 FlatteningOptions fopts; 130 131 Timer starttime; 132}; 133 134} // namespace MiniZinc 135 136#endif // __MINIZINC_FLATTENER_H__