diff --git a/CHANGES.txt b/CHANGES.txt index 85f8186a2..f646f3437 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,18 @@ All bug numbers refer to the issue tracker at https://github.com/MiniZinc/libminizinc/issues +Version 2.0.8 +============= + +Bug fixes: + + - Fix incorrect negation of some reified comparisons. + - Make lb/ub functions work in more cases. + - Fix several bugs in the optimisation phase (could lead to incorrect + FlatZinc and crashes). + - Fix a problem with reverse mapper functions when the result of the reverse + mapper can be fixed to a constant. + Version 2.0.7 ============= diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e8cbaf2a..f78ef2473 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ project (libminizinc CXX) # The version number. set (libminizinc_VERSION_MAJOR 2) set (libminizinc_VERSION_MINOR 0) -set (libminizinc_VERSION_PATCH 7) +set (libminizinc_VERSION_PATCH 8) if (ADDITIONAL_DATE_STRING) set (libminizinc_VERSION_PATCH "${libminizinc_VERSION_PATCH}.${ADDITIONAL_DATE_STRING}") diff --git a/lib/builtins.cpp b/lib/builtins.cpp index 10e8dcde5..733233308 100644 --- a/lib/builtins.cpp +++ b/lib/builtins.cpp @@ -232,7 +232,7 @@ namespace MiniZinc { if (b.valid) return b.l; else - throw EvalError(env, e->loc(),"cannot determine bounds"); + return -IntVal::infinity(); } IntVal b_lb_varoptint(EnvI& env, Call* call) { ASTExprVec args = call->args(); @@ -307,7 +307,7 @@ namespace MiniZinc { if (foundMin) { return array_lb; } else { - throw EvalError(env, e->loc(),"cannot determine lower bound"); + return -IntVal::infinity(); } } @@ -316,7 +316,7 @@ namespace MiniZinc { if (b.valid) return b.u; else - throw EvalError(env, e->loc(),"cannot determine bounds"); + return IntVal::infinity(); } IntVal b_ub_varoptint(EnvI& env, Call* call) { ASTExprVec args = call->args(); @@ -367,7 +367,7 @@ namespace MiniZinc { if (foundMax) { return array_ub; } else { - throw EvalError(env, e->loc(),"cannot determine upper bound"); + return IntVal::infinity(); } } @@ -878,7 +878,7 @@ namespace MiniZinc { } break; default: - throw EvalError(env, ae->loc(),"invalid argument to ub"); + throw EvalError(env, ae->loc(),"invalid argument to dom"); } } if (al->v().size()==0) diff --git a/lib/flatten.cpp b/lib/flatten.cpp index 3e96ddf2d..5bd87e1ac 100644 --- a/lib/flatten.cpp +++ b/lib/flatten.cpp @@ -3411,8 +3411,9 @@ namespace MiniZinc { keepAlive->decl(constants().var_redef); ret = flat_exp(env, Ctx(), keepAlive, constants().var_true, constants().var_true); - env.reverseMappers.insert(ee.r()->cast(),revMap); - + if (ee.r()->isa()) { + env.reverseMappers.insert(ee.r()->cast(),revMap); + } break; } if ( (bo->op()==BOT_EQ || bo->op()==BOT_EQUIV) && (bo->lhs()==constants().absent || bo->rhs()==constants().absent) ) { diff --git a/lib/optimize.cpp b/lib/optimize.cpp index 5db868a2d..66c8f6519 100644 --- a/lib/optimize.cpp +++ b/lib/optimize.cpp @@ -590,7 +590,7 @@ namespace MiniZinc { if (bi->isa()) { c = bi->cast()->e()->dyn_cast(); } else { - c = bi->cast()->e()->e()->dyn_cast(); + c = Expression::dyn_cast(bi->cast()->e()->e()); } if (c==NULL) continue; @@ -910,7 +910,7 @@ namespace MiniZinc { Expression* arg = c->args()[0]->isa() ? c->args()[1] : c->args()[0]; IntSetVal* domain = ident->decl()->ti()->domain() ? eval_intset(env,ident->decl()->ti()->domain()) : NULL; if (domain) { - BinOpType bot = c->args()[0]->isa() ? (is_true ? BOT_LQ : BOT_GQ) : (is_true ? BOT_GQ: BOT_LQ); + BinOpType bot = c->args()[0]->isa() ? (is_true ? BOT_LQ : BOT_GR) : (is_true ? BOT_GQ: BOT_LE); IntSetVal* newDomain = LinearTraits::limit_domain(bot, domain, eval_int(env,arg)); ident->decl()->ti()->domain(new SetLit(Location().introduce(), newDomain)); ident->decl()->ti()->setComputedDomain(false); @@ -1257,6 +1257,7 @@ namespace MiniZinc { env.flat()->fail(env); vdi->e()->e(constants().boollit(isConjunction)); } + toRemove.push_back(vdi); } } else { // not subsumed, nonfixed==1 @@ -1276,8 +1277,7 @@ namespace MiniZinc { vd->e(constants().lit_true); } } else { - vdi->e()->e(id); - vardeclQueue.push_back(env.vo.idx.find(vdi->e()->id())->second); + remove = false; } } diff --git a/lib/optimize_constraints.cpp b/lib/optimize_constraints.cpp index 2d8191fe6..d78b932a3 100644 --- a/lib/optimize_constraints.cpp +++ b/lib/optimize_constraints.cpp @@ -145,11 +145,15 @@ namespace MiniZinc { al_c_new->type(Type::parint(1)); ArrayLit* al_x_new = new ArrayLit(al_x->loc(),x_e); al_x_new->type(al_x->type()); - c->args()[0] = al_c_new; - c->args()[1] = al_x_new; - if (d != 0) { - c->args()[2] = IntLit::a(eval_int(env,c->args()[2])-d); - } + + std::vector args(3); + args[0] = al_c_new; + args[1] = al_x_new; + args[2] = IntLit::a(eval_int(env,c->args()[2])-d); + Call* nc = new Call(Location(), c->id(), args); + nc->type(Type::varbool()); + rewrite = nc; + return OptimizeRegistry::CS_REWRITE; } return OptimizeRegistry::CS_OK; } @@ -187,9 +191,15 @@ namespace MiniZinc { al_c_new->type(Type::parint(1)); ArrayLit* al_x_new = new ArrayLit(al_x->loc(),x_e); al_x_new->type(al_x->type()); - c->args()[0] = al_c_new; - c->args()[1] = al_x_new; - c->args()[2] = IntLit::a(d); + + std::vector args(3); + args[0] = al_c_new; + args[1] = al_x_new; + args[2] = IntLit::a(d); + Call* nc = new Call(Location(),c->id(),args); + nc->type(c->type()); + rewrite = nc; + return OptimizeRegistry::CS_REWRITE; } } return OptimizeRegistry::CS_OK;