Skip to content

Commit

Permalink
Merge branch 'hotfix/2.1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Sep 22, 2017
2 parents 334d55b + df71540 commit d215ecb
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 22 deletions.
16 changes: 16 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
All bug numbers refer to the issue tracker at
https://github.com/MiniZinc/libminizinc/issues

Version 2.1.6
=============

Bug fixes:

- Fully evaluate parameters before binding formal arguments when evaluating
call expressions. Fixes #177.
- Fix incorrect simplification of Boolean constraints assigned to variables
that are assigned to false
- Fix bug in flattening of linear equations that contain the same variable on
both sides
- Fix un-trailing for let expressions, which could sometimes cause incorrect
code to be emitted when lets are evaluated in nested loops. Fixes #166.
- Fix bug in JSON output of one-dimensional array literals
- Fix unification of enum type-inst variables

Version 2.1.5
=============

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 5)
set (libminizinc_VERSION_PATCH 6)

if (ADDITIONAL_DATE_STRING)
set (libminizinc_VERSION_PATCH "${libminizinc_VERSION_PATCH}.${ADDITIONAL_DATE_STRING}")
Expand Down
13 changes: 11 additions & 2 deletions lib/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,12 @@ namespace MiniZinc {
}
void
Let::popbindings(void) {
GC::untrail();
for (unsigned int i=_let.size(); i--;) {
if (VarDecl* vd = _let[i]->dyn_cast<VarDecl>()) {
GC::untrail();
break;
}
}
}

void
Expand Down Expand Up @@ -713,8 +718,12 @@ namespace MiniZinc {
tiit.enumId(enumIds[enumIds.size()-1]);
}
tiit.dim(0);
if (tii->type().st()==Type::ST_SET)
if (tii->type().st()==Type::ST_SET) {
tiit.st(Type::ST_PLAIN);
}
if (isaEnumTIId(tii->domain())) {
tiit.st(Type::ST_SET);
}
ASTStringMap<Type>::t::iterator it = tmap.find(tiid);
if (it==tmap.end()) {
tmap.insert(std::pair<ASTString,Type>(tiid,tiit));
Expand Down
4 changes: 3 additions & 1 deletion lib/builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,9 @@ namespace MiniZinc {
if (ArrayLit* al = e->dyn_cast<ArrayLit>()) {

std::vector<unsigned int> dims(al->dims()-1);
dims[0] = al->max(al->dims()-1)-al->min(al->dims()-1)+1;
if (dims.size() != 0) {
dims[0] = al->max(al->dims()-1)-al->min(al->dims()-1)+1;
}

for (unsigned int i=1; i<al->dims()-1; i++) {
dims[i] = dims[i-1] * (al->max(al->dims()-1-i)-al->min(al->dims()-1-i)+1);
Expand Down
6 changes: 5 additions & 1 deletion lib/eval_par.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,15 @@ namespace MiniZinc {
template<class Eval>
typename Eval::Val eval_call(EnvI& env, Call* ce) {
std::vector<Expression*> previousParameters(ce->decl()->params().size());
std::vector<Expression*> params(ce->decl()->params().size());
for (unsigned int i=0; i<ce->decl()->params().size(); i++) {
params[i] = eval_par(env, ce->args()[i]);
}
for (unsigned int i=ce->decl()->params().size(); i--;) {
VarDecl* vd = ce->decl()->params()[i];
previousParameters[i] = vd->e();
vd->flat(vd);
vd->e(eval_par(env, ce->args()[i]));
vd->e(params[i]);
if (vd->e()->type().ispar()) {
if (Expression* dom = vd->ti()->domain()) {
if (!dom->isa<TIId>()) {
Expand Down
4 changes: 2 additions & 2 deletions lib/flatten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,7 @@ namespace MiniZinc {
} else {
GCLock lock;
if (assignTo != NULL) {
Val resultCoeff;
Val resultCoeff = 0;
typename LinearTraits<Lit>::Bounds bounds(d,d,true);
for (unsigned int i=coeffv.size(); i--;) {
if (alv[i]()==assignTo) {
Expand All @@ -2525,7 +2525,7 @@ namespace MiniZinc {
break;
}
}
if (bounds.valid) {
if (bounds.valid && resultCoeff!=0) {
if (resultCoeff < 0) {
bounds.l = LinearTraits<Lit>::floor_div(bounds.l,-resultCoeff);
bounds.u = LinearTraits<Lit>::ceil_div(bounds.u,-resultCoeff);
Expand Down
41 changes: 26 additions & 15 deletions lib/optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ namespace MiniZinc {
int idCount = 0;
std::vector<VarDecl*> pos;
std::vector<VarDecl*> neg;

for (unsigned int j=0; j<c->args().size(); j++) {
bool unit = (j==0 ? isConjunction : !isConjunction);
ArrayLit* al = follow_id(c->args()[j])->cast<ArrayLit>();
Expand Down Expand Up @@ -454,27 +453,39 @@ namespace MiniZinc {
if (bi->isa<ConstraintI>()) {
env.envi().fail();
} else {
CollectDecls cd(envi.vo,deletedVarDecls,bi);
topDown(cd,bi->cast<VarDeclI>()->e()->e());
bi->cast<VarDeclI>()->e()->ti()->domain(constants().lit_false);
bi->cast<VarDeclI>()->e()->ti()->setComputedDomain(true);
bi->cast<VarDeclI>()->e()->e(constants().lit_false);
pushVarDecl(envi, bi->cast<VarDeclI>(), boolConstraints[i], vardeclQueue);
pushDependentConstraints(envi, bi->cast<VarDeclI>()->e()->id(), constraintQueue);
if (bi->cast<VarDeclI>()->e()->ti()->domain()) {
if (eval_bool(envi, bi->cast<VarDeclI>()->e()->ti()->domain())) {
envi.fail();
}
} else {
CollectDecls cd(envi.vo,deletedVarDecls,bi);
topDown(cd,bi->cast<VarDeclI>()->e()->e());
bi->cast<VarDeclI>()->e()->ti()->domain(constants().lit_false);
bi->cast<VarDeclI>()->e()->ti()->setComputedDomain(true);
bi->cast<VarDeclI>()->e()->e(constants().lit_false);
pushVarDecl(envi, bi->cast<VarDeclI>(), boolConstraints[i], vardeclQueue);
pushDependentConstraints(envi, bi->cast<VarDeclI>()->e()->id(), constraintQueue);
}
}
} else {
if (bi->isa<ConstraintI>()) {
CollectDecls cd(envi.vo,deletedVarDecls,bi);
topDown(cd,bi->cast<ConstraintI>()->e());
bi->remove();
} else {
CollectDecls cd(envi.vo,deletedVarDecls,bi);
topDown(cd,bi->cast<VarDeclI>()->e()->e());
bi->cast<VarDeclI>()->e()->ti()->domain(constants().lit_true);
bi->cast<VarDeclI>()->e()->ti()->setComputedDomain(true);
bi->cast<VarDeclI>()->e()->e(constants().lit_true);
pushVarDecl(envi, bi->cast<VarDeclI>(), boolConstraints[i], vardeclQueue);
pushDependentConstraints(envi, bi->cast<VarDeclI>()->e()->id(), constraintQueue);
if (bi->cast<VarDeclI>()->e()->ti()->domain()) {
if (!eval_bool(envi, bi->cast<VarDeclI>()->e()->ti()->domain())) {
envi.fail();
}
} else {
CollectDecls cd(envi.vo,deletedVarDecls,bi);
topDown(cd,bi->cast<VarDeclI>()->e()->e());
bi->cast<VarDeclI>()->e()->ti()->domain(constants().lit_true);
bi->cast<VarDeclI>()->e()->ti()->setComputedDomain(true);
bi->cast<VarDeclI>()->e()->e(constants().lit_true);
pushVarDecl(envi, bi->cast<VarDeclI>(), boolConstraints[i], vardeclQueue);
pushDependentConstraints(envi, bi->cast<VarDeclI>()->e()->id(), constraintQueue);
}
}
}
}
Expand Down

0 comments on commit d215ecb

Please sign in to comment.