summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-09-04 01:23:51 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-09-04 01:23:51 +0000
commita3ce04f5ec7c96086d202d9cd7ac3cfe1eec5bde (patch)
tree22ee17e2c401c166d69a1f4908f41be2fecc5386
parent28f2a235be95f1638e3b2e101fccdeb07ede6078 (diff)
nothing
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@641 ec762483-ff6d-05da-a07a-a48fb63a330f
-rwxr-xr-xutils/agenda.h11
1 files changed, 9 insertions, 2 deletions
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<Item,KeyF,HashKey,EqKey,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<Item,KeyF,HashKey,EqKey,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) { }
};