Skip to content

Commit

Permalink
remove unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal committed Dec 31, 2024
1 parent 9cacb98 commit c6e9bfc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 79 deletions.
34 changes: 0 additions & 34 deletions gtsam/discrete/DiscreteTableConditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,6 @@ bool DiscreteTableConditional::equals(const DiscreteFactor& other,
}
}

/* ************************************************************************** */
TableFactor::shared_ptr DiscreteTableConditional::likelihood(
const DiscreteValues& frontalValues) const {
throw std::runtime_error("Likelihood not implemented");
}

/* ****************************************************************************/
TableFactor::shared_ptr DiscreteTableConditional::likelihood(
size_t frontal) const {
throw std::runtime_error("Likelihood not implemented");
}

/* ****************************************************************************/
DiscreteConditional::shared_ptr DiscreteTableConditional::max(
const Ordering& keys) const {
Expand Down Expand Up @@ -180,26 +168,4 @@ DiscreteConditional::shared_ptr DiscreteTableConditional::prune(
this->nrFrontals(), this->discreteKeys(), pruned.sparseTable());
}

/* ************************************************************************** */
size_t DiscreteTableConditional::argmax(
const DiscreteValues& parentsValues) const {
// Initialize
size_t maxValue = 0;
double maxP = 0;
DiscreteValues values = parentsValues;

assert(nrFrontals() == 1);
Key j = firstFrontalKey();
for (size_t value = 0; value < cardinality(j); value++) {
values[j] = value;
double pValueS = (*this)(values);
// Update MPE solution if better
if (pValueS > maxP) {
maxP = pValueS;
maxValue = value;
}
}
return maxValue;
}

} // namespace gtsam
47 changes: 2 additions & 45 deletions gtsam/discrete/DiscreteTableConditional.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,28 +158,8 @@ class GTSAM_EXPORT DiscreteTableConditional : public DiscreteConditional {
/// @name Standard Interface
/// @{

/// Log-probability is just -error(x).
double logProbability(const DiscreteValues& x) const { return -error(x); }

/// print index signature only
void printSignature(
const std::string& s = "Discrete Conditional: ",
const KeyFormatter& formatter = DefaultKeyFormatter) const {
static_cast<const BaseConditional*>(this)->print(s, formatter);
}

/** Convert to a likelihood factor by providing value before bar. */
TableFactor::shared_ptr likelihood(const DiscreteValues& frontalValues) const;

/** Single variable version of likelihood. */
TableFactor::shared_ptr likelihood(size_t frontal) const;

/**
* @brief Return assignment for single frontal variable that maximizes value.
* @param parentsValues Known assignments for the parents.
* @return maximizing assignment for the frontal variable.
*/
size_t argmax(const DiscreteValues& parentsValues = DiscreteValues()) const;
/// Return the underlying TableFactor
TableFactor table() const { return table_; }

/**
* @brief Create new conditional by maximizing over all
Expand All @@ -195,29 +175,6 @@ class GTSAM_EXPORT DiscreteTableConditional : public DiscreteConditional {
/// @name Advanced Interface
/// @{

/// Return all assignments for frontal variables.
std::vector<DiscreteValues> frontalAssignments() const;

/// Return all assignments for frontal *and* parent variables.
std::vector<DiscreteValues> allAssignments() const;

/// @}
/// @name HybridValues methods.
/// @{

using BaseConditional::operator(); ///< HybridValues version

/**
* Calculate log-probability log(evaluate(x)) for HybridValues `x`.
* This is actually just -error(x).
*/
double logProbability(const HybridValues& x) const override {
return -error(x);
}

/// Return the underlying TableFactor
TableFactor table() const { return table_; }

/// Evaluate the conditional given the values.
virtual double evaluate(const Assignment<Key>& values) const override {
return table_.evaluate(values);
Expand Down

0 comments on commit c6e9bfc

Please sign in to comment.