mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Remove debug output; Stop if the best estimated solution will never lead to a
solution (Infinity).
This commit is contained in:
@@ -37,6 +37,10 @@ _.extend(PriorityQueue.prototype, {
|
||||
empty: function () {
|
||||
var self = this;
|
||||
return self._heap.empty();
|
||||
},
|
||||
size: function () {
|
||||
var self = this;
|
||||
return self._heap.size();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -120,28 +120,21 @@ ConstraintSolver.Resolver.prototype.resolve =
|
||||
pq.push(startState, [estimateCostFunction(startState, opts), 0]);
|
||||
|
||||
var someError = null;
|
||||
var stateStrings = {};
|
||||
while (! pq.empty()) {
|
||||
var currentState = pq.pop();
|
||||
var tentativeCost =
|
||||
costFunction(currentState.choices, opts) +
|
||||
estimateCostFunction(currentState, opts);
|
||||
console.log(">> ", tentativeCost);
|
||||
var tentativeCost =
|
||||
costFunction(currentState.choices, opts) +
|
||||
estimateCostFunction(currentState, opts);
|
||||
|
||||
if (tentativeCost === Infinity)
|
||||
break;
|
||||
|
||||
if (_.isEmpty(currentState.dependencies))
|
||||
return currentState.choices;
|
||||
|
||||
var currentCost = costFunction(currentState.choices, opts);
|
||||
var neighborsObj = self._stateNeighbors(currentState);
|
||||
|
||||
|
||||
if (! neighborsObj.success) {
|
||||
console.log(":( ", currentState.choices.map(function (x) { return x.toString() }))
|
||||
console.log("<< left: ", currentState.dependencies)
|
||||
console.log("<< constr: ", _.map(_.filter(currentState.constraints, function (x) { return _.contains(currentState.dependencies, x.name) }), function (x) { return x.toString() }));
|
||||
console.log(neighborsObj.failureMsg, '\n\n')
|
||||
//console.log(neighborsObj.failureMsg, neighborsObj.triedUnitVersions.map(function (x) { return x.toString() }), '\n', neighborsObj.lastInvalidNeighbor.choices.map(function (x) { return x.toString() }), '\n', neighborsObj.lastInvalidNeighbor.constraints.map(function (x) { return x.toString() }), '\n\n')
|
||||
|
||||
someError = someError || neighborsObj.failureMsg;
|
||||
} else {
|
||||
_.each(neighborsObj.neighbors, function (state) {
|
||||
@@ -149,8 +142,7 @@ ConstraintSolver.Resolver.prototype.resolve =
|
||||
costFunction(state.choices, opts) +
|
||||
estimateCostFunction(state, opts);
|
||||
|
||||
//if (_.isFinite(tentativeCost))
|
||||
pq.push(state, [tentativeCost, -state.choices.length]);
|
||||
pq.push(state, [tentativeCost, -state.choices.length]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user