Skip to content

Commit

Permalink
Merge branch 'release/2.0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Oct 19, 2015
2 parents c61e72d + da4f907 commit 34fb555
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 20 deletions.
12 changes: 12 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
10 changes: 5 additions & 5 deletions lib/builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expression> args = call->args();
Expand Down Expand Up @@ -307,7 +307,7 @@ namespace MiniZinc {
if (foundMin) {
return array_lb;
} else {
throw EvalError(env, e->loc(),"cannot determine lower bound");
return -IntVal::infinity();
}
}

Expand All @@ -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<Expression> args = call->args();
Expand Down Expand Up @@ -367,7 +367,7 @@ namespace MiniZinc {
if (foundMax) {
return array_ub;
} else {
throw EvalError(env, e->loc(),"cannot determine upper bound");
return IntVal::infinity();
}
}

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lib/flatten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Id>(),revMap);

if (ee.r()->isa<Id>()) {
env.reverseMappers.insert(ee.r()->cast<Id>(),revMap);
}
break;
}
if ( (bo->op()==BOT_EQ || bo->op()==BOT_EQUIV) && (bo->lhs()==constants().absent || bo->rhs()==constants().absent) ) {
Expand Down
8 changes: 4 additions & 4 deletions lib/optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ namespace MiniZinc {
if (bi->isa<ConstraintI>()) {
c = bi->cast<ConstraintI>()->e()->dyn_cast<Call>();
} else {
c = bi->cast<VarDeclI>()->e()->e()->dyn_cast<Call>();
c = Expression::dyn_cast<Call>(bi->cast<VarDeclI>()->e()->e());
}
if (c==NULL)
continue;
Expand Down Expand Up @@ -910,7 +910,7 @@ namespace MiniZinc {
Expression* arg = c->args()[0]->isa<Id>() ? 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<Id>() ? (is_true ? BOT_LQ : BOT_GQ) : (is_true ? BOT_GQ: BOT_LQ);
BinOpType bot = c->args()[0]->isa<Id>() ? (is_true ? BOT_LQ : BOT_GR) : (is_true ? BOT_GQ: BOT_LE);
IntSetVal* newDomain = LinearTraits<IntLit>::limit_domain(bot, domain, eval_int(env,arg));
ident->decl()->ti()->domain(new SetLit(Location().introduce(), newDomain));
ident->decl()->ti()->setComputedDomain(false);
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
}

Expand Down
26 changes: 18 additions & 8 deletions lib/optimize_constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expression*> 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;
}
Expand Down Expand Up @@ -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<Expression*> 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;
Expand Down

0 comments on commit 34fb555

Please sign in to comment.