Skip to content

Commit

Permalink
Fixes #210.
Browse files Browse the repository at this point in the history
Bug was caused by control returning to a continuation it shouldn't have returned to once inference finished.
(Bugs like this one highlight how tricky it can be to write complex inference backends in CPS.)
  • Loading branch information
dritchie committed Oct 12, 2015
1 parent d1e1ba4 commit 90a07fc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/inference/incrementalmh.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ module.exports = function(env) {
tabbedlog(4, this.depth, 'no, ERP params have not changed');
tabbedlog(5, this.depth, 'params:', this.params);
}
return this.kontinue();
// Bail out early if we know proposal will be rejected
if (this.score === -Infinity) {
tabbedlog(4, this.depth, 'score became -Infinity; bailing out early');
return this.coroutine.exit();
} else {
return this.kontinue();
}
};

ERPNode.prototype.registerInputChanges = function(s, k, unused, params) {
Expand Down Expand Up @@ -178,10 +184,6 @@ module.exports = function(env) {
var oldscore = this.score;
updateProperty(this, 'score', this.erp.score(this.params, this.val));
this.coroutine.score += this.score - oldscore;
if (this.score === -Infinity) {
tabbedlog(4, this.depth, 'score became -Infinity; bailing out early');
return this.coroutine.exit();
}
};

// ------------------------------------------------------------------
Expand Down

0 comments on commit 90a07fc

Please sign in to comment.