Skip to content

Commit

Permalink
Merge pull request #2245 from OlivierHamel/fix-profiler-cost-est
Browse files Browse the repository at this point in the history
Fix profiler cost estimate
  • Loading branch information
b-scholz committed Apr 1, 2022
2 parents 37b159d + 68294e6 commit 4cdd345
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ast/utility/SipsMetric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ std::vector<std::size_t> StaticSipsMetric::getReordering(
while (numAdded < atoms.size()) {
// grab the index of the next atom, based on the SIPS function
const auto& costs = evaluateCosts(atoms, bindingStore);
assert(atoms.size() == costs.size() && "each atom should have exactly one cost");
std::size_t minIdx = static_cast<std::size_t>(
std::distance(costs.begin(), std::min_element(costs.begin(), costs.end())));
const auto* nextAtom = atoms[minIdx];
Expand Down Expand Up @@ -700,7 +701,7 @@ std::vector<double> ProfileUseSips::evaluateCosts(
// prioritise propositions
std::size_t arity = atom->getArity();
if (arity == 0) {
cost.push_back(0);
cost.push_back(-1); // cheaper than any non-proposition
continue;
}

Expand All @@ -709,6 +710,7 @@ std::vector<double> ProfileUseSips::evaluateCosts(
std::size_t numFree = arity - numBound;
double value = log(profileUse.getRelationSize(atom->getQualifiedName()));
value *= (numFree * 1.0) / arity;
cost.push_back(value);
}
return cost;
}
Expand Down

0 comments on commit 4cdd345

Please sign in to comment.