From a3ce04f5ec7c96086d202d9cd7ac3cfe1eec5bde Mon Sep 17 00:00:00 2001 From: graehl Date: Sat, 4 Sep 2010 01:23:51 +0000 Subject: nothing git-svn-id: https://ws10smt.googlecode.com/svn/trunk@641 ec762483-ff6d-05da-a07a-a48fb63a330f --- utils/agenda.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/agenda.h b/utils/agenda.h index a4940a00..1dbcd7bb 100755 --- a/utils/agenda.h +++ b/utils/agenda.h @@ -95,8 +95,10 @@ struct Agenda : intern_pool { bool improve(ItemP i) { ItemP c=i; bool fresh=interneq(c); - if (fresh) - return add(c); + if (fresh) { + add(c); + return true; + } DBG_AGENDA(assert(q.contains(c))); return q.maybe_improve(priomap[i]); } @@ -113,6 +115,11 @@ struct Agenda : intern_pool { agenda_best_t best() const { return priomap[q.top()]; //TODO: cache/track the global best? } + // add only if worse than queue current best, otherwise evaluate immediately (e.g. for early stopping w/ expensive to compute additional cost). return true if postponed (added) + bool postpone(ItemP i) { + if (better(priomap[i],best())) return false; + return improve(i); + } Agenda(unsigned reserve=1000000,LocMap const& lm=LocMap(),PrioMap const& pm=PrioMap(),EqKey const& eq=EqKey(),Better const& better=Better()) : locmap(lm), priomap(pm), better(better), q(priomap,locmap,better,reserve) { } }; -- cgit v1.2.3