move sum, max and nrValues to Constraint class as well

release/4.3a0
Varun Agrawal 2025-01-06 13:38:45 -05:00
parent 7561da4df2
commit ff5371fd4a
5 changed files with 21 additions and 74 deletions

View File

@ -72,25 +72,6 @@ class GTSAM_UNSTABLE_EXPORT AllDiff : public Constraint {
/// Partially apply known values, domain version
Constraint::shared_ptr partiallyApply(
const Domains&) const override;
/// Get the number of non-zero values contained in this factor.
uint64_t nrValues() const override { return 1; };
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override {
return toDecisionTreeFactor().sum(nrFrontals);
}
DiscreteFactor::shared_ptr sum(const Ordering& keys) const override {
return toDecisionTreeFactor().sum(keys);
}
DiscreteFactor::shared_ptr max(size_t nrFrontals) const override {
return toDecisionTreeFactor().max(nrFrontals);
}
DiscreteFactor::shared_ptr max(const Ordering& keys) const override {
return toDecisionTreeFactor().max(keys);
}
};
} // namespace gtsam

View File

@ -96,25 +96,6 @@ class BinaryAllDiff : public Constraint {
AlgebraicDecisionTree<Key> errorTree() const override {
throw std::runtime_error("BinaryAllDiff::error not implemented");
}
/// Get the number of non-zero values contained in this factor.
uint64_t nrValues() const override { return 1; };
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override {
return toDecisionTreeFactor().sum(nrFrontals);
}
DiscreteFactor::shared_ptr sum(const Ordering& keys) const override {
return toDecisionTreeFactor().sum(keys);
}
DiscreteFactor::shared_ptr max(size_t nrFrontals) const override {
return toDecisionTreeFactor().max(nrFrontals);
}
DiscreteFactor::shared_ptr max(const Ordering& keys) const override {
return toDecisionTreeFactor().max(keys);
}
};
} // namespace gtsam

View File

@ -68,7 +68,8 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
/*
* Ensure Arc-consistency by checking every possible value of domain j.
* @param j domain to be checked
* @param (in/out) domains all domains, but only domains->at(j) will be checked.
* @param (in/out) domains all domains, but only domains->at(j) will be
* checked.
* @return true if domains->at(j) was changed, false otherwise.
*/
virtual bool ensureArcConsistency(Key j, Domains* domains) const = 0;
@ -92,6 +93,25 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
return this->toDecisionTreeFactor() / df;
}
/// Get the number of non-zero values contained in this factor.
uint64_t nrValues() const override { return 1; };
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override {
return toDecisionTreeFactor().sum(nrFrontals);
}
DiscreteFactor::shared_ptr sum(const Ordering& keys) const override {
return toDecisionTreeFactor().sum(keys);
}
DiscreteFactor::shared_ptr max(size_t nrFrontals) const override {
return toDecisionTreeFactor().max(nrFrontals);
}
DiscreteFactor::shared_ptr max(const Ordering& keys) const override {
return toDecisionTreeFactor().max(keys);
}
/// @}
/// @name Wrapper support
/// @{

View File

@ -114,22 +114,6 @@ class GTSAM_UNSTABLE_EXPORT Domain : public Constraint {
/// Partially apply known values, domain version
Constraint::shared_ptr partiallyApply(const Domains& domains) const override;
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override {
return toDecisionTreeFactor().sum(nrFrontals);
}
DiscreteFactor::shared_ptr sum(const Ordering& keys) const override {
return toDecisionTreeFactor().sum(keys);
}
DiscreteFactor::shared_ptr max(size_t nrFrontals) const override {
return toDecisionTreeFactor().max(nrFrontals);
}
DiscreteFactor::shared_ptr max(const Ordering& keys) const override {
return toDecisionTreeFactor().max(keys);
}
};
} // namespace gtsam

View File

@ -77,25 +77,6 @@ class GTSAM_UNSTABLE_EXPORT SingleValue : public Constraint {
/// Partially apply known values, domain version
Constraint::shared_ptr partiallyApply(
const Domains& domains) const override;
/// Get the number of non-zero values contained in this factor.
uint64_t nrValues() const override { return 1; };
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override {
return toDecisionTreeFactor().sum(nrFrontals);
}
DiscreteFactor::shared_ptr sum(const Ordering& keys) const override {
return toDecisionTreeFactor().sum(keys);
}
DiscreteFactor::shared_ptr max(size_t nrFrontals) const override {
return toDecisionTreeFactor().max(nrFrontals);
}
DiscreteFactor::shared_ptr max(const Ordering& keys) const override {
return toDecisionTreeFactor().max(keys);
}
};
} // namespace gtsam