Skip to content

Commit

Permalink
Merge branch 'hotfix/2.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Feb 6, 2017
2 parents 64e482e + 40975bb commit 3eb086f
Show file tree
Hide file tree
Showing 26 changed files with 681 additions and 185 deletions.
37 changes: 37 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,43 @@
All bug numbers refer to the issue tracker at
https://github.com/MiniZinc/libminizinc/issues

Version 2.1.3
=============

Changes:
- Remove more internal annotations from the generated FlatZinc.
- Detect failure earlier if optimisation pass leads to fixing of variables
outside their domains.

Bug fixes:
- Fix CBC backend to correctly print UNSAT message for models where the
compiler already detected unsatisfiability, and print solution separators
even where there is no other output.
- Add missing var_dom function for arrays of optional integer variables.
Fixes #133.
- Fix aliasing for optional integer variables. Fixes #132.
- Remove all annotations from output model.
- Fix computation of return type for functions that return arrays of enums.
- Don't output newline if user-defined solution separator or status message is empty
- Fix return type computation for functions where return type contains
enums.
- Check finiteness of float literals and bounds. Fixes #138.
- More checks for function return values. Fixes #136.
- Fix var int comprehensions (now triggers error message instead of crash
for var set of int comprehensions). Fixes #135.
- Fix output of variables with quoted identifiers.
- Fix flattening of let expressions that contain variables with undefined
(i.e., partial) right hand side.
- Make printing of error messages to stdout or stderr more consistent
across executables.
- Fix type checking of initialisation of enum types.
- Improve error messages for array access and index set errors. Fixes #131.
- Fix definition of multi-dimensional element constraints to impose
correct bounds on index variables.
- Fix binding analysis during type checking, which did not handle the
shadowing of top-level declarations by comprehension generators correctly.
Fixes #129.

Version 2.1.2
=============

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endif()
# The version number.
set (libminizinc_VERSION_MAJOR 2)
set (libminizinc_VERSION_MINOR 1)
set (libminizinc_VERSION_PATCH 2)
set (libminizinc_VERSION_PATCH 3)

if (ADDITIONAL_DATE_STRING)
set (libminizinc_VERSION_PATCH "${libminizinc_VERSION_PATCH}.${ADDITIONAL_DATE_STRING}")
Expand Down
2 changes: 2 additions & 0 deletions include/minizinc/ast.hh
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,8 @@ namespace MiniZinc {
Expression* where(void) const { return _where; }
/// Return generator body
Expression* e(void) const { return _e; }
/// Set generator body
void e(Expression* e0) { _e = e0; }
/// Re-construct (used for copying)
void init(Expression* e, Generators& g);
};
Expand Down
4 changes: 2 additions & 2 deletions include/minizinc/flatten_internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ namespace MiniZinc {
}
static ASTString id_eq(void) { return constants().ids.float_.eq; }
typedef FloatBounds Bounds;
static bool finite(const FloatBounds& ib) { return true; }
static bool finite(const FloatVal&) { return true; }
static bool finite(const FloatBounds& ib) { return ib.l.isFinite() && ib.u.isFinite(); }
static bool finite(const FloatVal& v) { return v.isFinite(); }
static Bounds compute_bounds(EnvI& env, Expression* e) { return compute_float_bounds(env,e); }
typedef FloatSetVal* Domain;
static Domain eval_domain(EnvI& env, Expression* e) { return eval_floatset(env, e); }
Expand Down
6 changes: 3 additions & 3 deletions include/minizinc/solver.hh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace MiniZinc {
Flattener* flt=0;
SolverInstanceBase* si=0;
bool is_mzn2fzn;

std::string executable_name;
public:
Solns2Out s2out;

Expand All @@ -102,8 +102,8 @@ namespace MiniZinc {
MznSolver(bool ism2f = false);
virtual ~MznSolver();
virtual void addFlattener();
virtual bool processOptions(int argc, const char** argv);
virtual void printHelp();
virtual bool processOptions(int argc, const char** argv, std::ostream& os);
virtual void printHelp(std::ostream& os);
virtual void flatten();
virtual size_t getNSolvers() { return getGlobalSolverRegistry()->getSolverFactories().size(); }
/// If building a flattening exe only.
Expand Down
47 changes: 37 additions & 10 deletions include/minizinc/typecheck.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,62 @@

namespace MiniZinc {

/// Scoped variable declarations
class Scopes {
protected:
typedef IdMap<VarDecl*> DeclMap;
struct Scope {
/// Whether this scope is toplevel
bool toplevel;
/// Map from identifiers to declarations
DeclMap m;
/// Constructor
Scope(void) : toplevel(false) {}
};
/// Stack of scopes
std::vector<Scope> s;
public:

/// Constructor
Scopes(void);

/// Add a variable declaration
void add(EnvI& env, VarDecl* vd);

/// Push a new scope
void push(bool toplevel);
/// Pop topmost scope
void pop(void);

/// Return declaration for \a ident, or NULL if not found
VarDecl* find(Id* ident);

};

/// Topological sorting of items
class TopoSorter {
public:
typedef std::vector<VarDecl*> Decls;
typedef IdMap<Decls> DeclMap;
typedef UNORDERED_NAMESPACE::unordered_map<VarDecl*,int> PosMap;

/// List of all declarations
Decls decls;
/// Map from identifiers to declarations
DeclMap idmap;
/// Scoped declarations
Scopes scopes;
/// Map from declarations to positions
PosMap pos;
/// The model
Model* model;

TopoSorter(Model* model0) : model(model0) {}

/// Add a variable declaration
void add(EnvI& env, VarDecl* vd, bool unique);
/// Add a variable declaration item
void add(EnvI& env, VarDeclI* vd, bool unique, bool handleEnums, Model* enumItems);
/// Remove a variable declaration
void remove(EnvI& env, VarDecl* vd);
void add(EnvI& env, VarDeclI* vd, bool handleEnums, Model* enumItems);
/// Get variable declaration from identifier \a id
VarDecl* get(EnvI& env, const ASTString& id, const Location& loc);

VarDecl* checkId(EnvI& env, const ASTString& id, const Location& loc);
VarDecl* checkId(EnvI& env, Id* id, const Location& loc);
VarDecl* checkId(EnvI& env, const ASTString& ident, const Location& loc);
VarDecl* checkId(EnvI& env, Id* ident, const Location& loc);
/// Run the topological sorting for expression \a e
void run(EnvI& env, Expression* e);
};
Expand Down
18 changes: 15 additions & 3 deletions lib/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@ namespace MiniZinc {
if (tii->domain() && tii->domain()->isa<TIId>()) {
ASTString tiid = tii->domain()->cast<TIId>()->v();
Type tiit = getType(ta[i]);
if (tiit.enumId() != 0 && tiit.dim() > 0) {
const std::vector<unsigned int>& enumIds = env.getArrayEnum(tiit.enumId());
tiit.enumId(enumIds[enumIds.size()-1]);
}
tiit.dim(0);
if (tii->type().st()==Type::ST_SET)
tiit.st(Type::ST_PLAIN);
Expand Down Expand Up @@ -780,13 +784,21 @@ namespace MiniZinc {
if (dh.beginsWith("$")) {
// this is an enum
ret.bt(Type::BT_INT);
ret.enumId(it->second.enumId());
} else {
ret.bt(it->second.bt());
ret.enumId(it->second.enumId());
if (ret.st()==Type::ST_PLAIN)
ret.st(it->second.st());
}
if (fi->ti()->ranges().size() > 0 && it->second.enumId() != 0) {
std::vector<unsigned int> enumIds(fi->ti()->ranges().size()+1);
for (unsigned int i=0; i<fi->ti()->ranges().size(); i++) {
enumIds[i] = 0;
}
enumIds[enumIds.size()-1] = it->second.enumId();
ret.enumId(env.registerArrayEnum(enumIds));
} else {
ret.enumId(it->second.enumId());
}
}
if (rh.size() != 0) {
ASTStringMap<Type>::t::iterator it = tmap.find(rh);
Expand All @@ -810,7 +822,7 @@ namespace MiniZinc {
if (it==tmap.end())
throw TypeError(env, fi->loc(),"type-inst variable $"+enumTIId.str()+" used but not defined");
enumIds[i] = it->second.enumId();
hadRealEnum = (enumIds[i] != 0);
hadRealEnum |= (enumIds[i] != 0);
} else {
enumIds[i] = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ namespace MiniZinc {
opt->setBoolParam(constants().opts.verbose.str(),true);
}
void cli_version(CLIOptions* opt) {
std::cout << "NICTA MiniZinc to FlatZinc converter, version "
std::cout << "MiniZinc to FlatZinc converter, version "
<< MZN_VERSION_MAJOR << "." << MZN_VERSION_MINOR << "." << MZN_VERSION_PATCH << std::endl;
std::cout << "Copyright (C) 2014, 2015 Monash University and NICTA" << std::endl;
std::cout << "Copyright (C) 2014-2017 Monash University, NICTA, Data61" << std::endl;
std::exit(EXIT_SUCCESS);
}
void cli_werror(CLIOptions* opt) {
Expand Down Expand Up @@ -566,4 +566,4 @@ namespace MiniZinc {
_known_options[constants().cli.solver.fzn_solver_str.str()] = o_fznSolver;
}

}
}
Loading

0 comments on commit 3eb086f

Please sign in to comment.