/* * Main authors: * Kevin Leo * Andrea Rendl * Guido Tack */ /* 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/. */ #ifndef __MINIZINC_GECODE_FZN_SPACE_HH__ #define __MINIZINC_GECODE_FZN_SPACE_HH__ #include #include #include #ifdef GECODE_HAS_SET_VARS #include #endif #ifdef GECODE_HAS_FLOAT_VARS #include #endif #include namespace MiniZinc { class FznSpace : public Gecode::Space { public: /// The integer variables std::vector iv; /// The introduced integer variables Gecode::IntVarArray iv_aux; /// Indicates whether an integer variable is introduced by mzn2fzn std::vector iv_introduced; /// Indicates whether an integer variable is defined std::vector iv_defined; /// The Boolean variables std::vector bv; /// The introduced Boolean variables Gecode::BoolVarArray bv_aux; /// Indicates whether a Boolean variable is introduced by mzn2fzn std::vector bv_introduced; /// Indicates whether a Boolean variable is defined std::vector bv_defined; #ifdef GECODE_HAS_SET_VARS /// The set variables std::vector sv; /// The introduced set variables Gecode::SetVarArray sv_aux; /// Indicates whether a set variable is introduced by mzn2fzn std::vector sv_introduced; /// Indicates whether a set variable is introduced by mzn2fzn std::vector sv_defined; #endif #ifdef GECODE_HAS_FLOAT_VARS /// The float variables std::vector fv; /// The introduced float variables Gecode::FloatVarArray fv_aux; /// Indicates whether a float variable is introduced by mzn2fzn std::vector fv_introduced; /// Indicates whether a float variable is defined std::vector fv_defined; #endif /// Indicates if the objective variable is integer (float otherwise) bool _optVarIsInt; /// Index of the variable to optimize int _optVarIdx; /// Whether the introduced variables still need to be copied bool _copyAuxVars; /// solve type (SAT, MIN or MAX) MiniZinc::SolveI::SolveType _solveType; /// copy constructor FznSpace(FznSpace&); /// standard constructor FznSpace(void) : _optVarIsInt(true), _optVarIdx(-1), _copyAuxVars(true){}; ~FznSpace(void) {} /// get the index of the Boolean variable in bv; return -1 if not exists int getBoolAliasIndex(Gecode::BoolVar bvar) { for (unsigned int i = 0; i < bv.size(); i++) { if (bv[i].varimp() == bvar.varimp()) { // std::cout << "DEBUG: settings bool alias of variable to index " << i << std::endl; return i; } } return -1; // we should have found the boolvar in bv } protected: /// Implement optimization virtual void constrain(const Space& s); /// Copy function virtual Gecode::Space* copy(void); }; } // namespace MiniZinc #endif