Revert "Fix constraints"

This reverts commit 2b6545233a.
release/4.3a0
Frank Dellaert 2025-01-30 22:10:50 -05:00
parent 2b6545233a
commit 0d5b03d609
6 changed files with 5 additions and 36 deletions

View File

@ -136,6 +136,9 @@ class GTSAM_EXPORT DiscreteFactor : public Factor {
/** /**
* @brief Multiply in a DiscreteFactor and return the result as * @brief Multiply in a DiscreteFactor and return the result as
* DiscreteFactor, both via shared pointers. * DiscreteFactor, both via shared pointers.
*
* @param df DiscreteFactor shared_ptr
* @return DiscreteFactor::shared_ptr
*/ */
virtual DiscreteFactor::shared_ptr multiply( virtual DiscreteFactor::shared_ptr multiply(
const DiscreteFactor::shared_ptr& df) const = 0; const DiscreteFactor::shared_ptr& df) const = 0;
@ -167,7 +170,7 @@ class GTSAM_EXPORT DiscreteFactor : public Factor {
* *
* @return DiscreteFactor::shared_ptr * @return DiscreteFactor::shared_ptr
*/ */
virtual DiscreteFactor::shared_ptr scale() const; DiscreteFactor::shared_ptr scale() const;
/** /**
* Get the number of non-zero values contained in this factor. * Get the number of non-zero values contained in this factor.

View File

@ -72,11 +72,6 @@ class GTSAM_UNSTABLE_EXPORT AllDiff : public Constraint {
/// Partially apply known values, domain version /// Partially apply known values, domain version
Constraint::shared_ptr partiallyApply( Constraint::shared_ptr partiallyApply(
const Domains&) const override; const Domains&) const override;
// Scale just returns the same constraint.
DiscreteFactor::shared_ptr scale() const override {
return std::make_shared<AllDiff>(*this);
}
}; };
} // namespace gtsam } // namespace gtsam

View File

@ -96,11 +96,6 @@ class BinaryAllDiff : public Constraint {
AlgebraicDecisionTree<Key> errorTree() const override { AlgebraicDecisionTree<Key> errorTree() const override {
throw std::runtime_error("BinaryAllDiff::error not implemented"); throw std::runtime_error("BinaryAllDiff::error not implemented");
} }
// Scale just returns the same constraint.
DiscreteFactor::shared_ptr scale() const override {
return std::make_shared<BinaryAllDiff>(*this);
}
}; };
} // namespace gtsam } // namespace gtsam

View File

@ -29,9 +29,7 @@ class Domain;
using Domains = std::map<Key, Domain>; using Domains = std::map<Key, Domain>;
/** /**
* Base class for constraint factors. * Base class for constraint factors
* This class is used to represent constraints on discrete variables.
* The values are always either 0 or 1, with at least one 1.
* Derived classes include SingleValue, BinaryAllDiff, and AllDiff. * Derived classes include SingleValue, BinaryAllDiff, and AllDiff.
*/ */
class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor { class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
@ -82,16 +80,6 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
/// Partially apply known values, domain version /// Partially apply known values, domain version
virtual shared_ptr partiallyApply(const Domains&) const = 0; virtual shared_ptr partiallyApply(const Domains&) const = 0;
/// Multiply in a DecisionTreeFactor.
DecisionTreeFactor operator*(const DecisionTreeFactor& df) const override {
throw std::logic_error("Constraint::operator* not implemented");
}
/// Multiply with scalar just returns the constraint.
DiscreteFactor::shared_ptr operator*(double /* s*/) const override {
throw std::logic_error("Constraint::operator* not implemented");
}
/// Multiply factors, DiscreteFactor::shared_ptr edition /// Multiply factors, DiscreteFactor::shared_ptr edition
DiscreteFactor::shared_ptr multiply( DiscreteFactor::shared_ptr multiply(
const DiscreteFactor::shared_ptr& df) const override { const DiscreteFactor::shared_ptr& df) const override {
@ -116,8 +104,6 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
return toDecisionTreeFactor().sum(keys); return toDecisionTreeFactor().sum(keys);
} }
double max() const override { return 1.0; }
DiscreteFactor::shared_ptr max(size_t nrFrontals) const override { DiscreteFactor::shared_ptr max(size_t nrFrontals) const override {
return toDecisionTreeFactor().max(nrFrontals); return toDecisionTreeFactor().max(nrFrontals);
} }

View File

@ -114,11 +114,6 @@ class GTSAM_UNSTABLE_EXPORT Domain : public Constraint {
/// Partially apply known values, domain version /// Partially apply known values, domain version
Constraint::shared_ptr partiallyApply(const Domains& domains) const override; Constraint::shared_ptr partiallyApply(const Domains& domains) const override;
// Scale just returns the same constraint.
DiscreteFactor::shared_ptr scale() const override {
return std::make_shared<Domain>(*this);
}
}; };
} // namespace gtsam } // namespace gtsam

View File

@ -77,11 +77,6 @@ class GTSAM_UNSTABLE_EXPORT SingleValue : public Constraint {
/// Partially apply known values, domain version /// Partially apply known values, domain version
Constraint::shared_ptr partiallyApply( Constraint::shared_ptr partiallyApply(
const Domains& domains) const override; const Domains& domains) const override;
// Scale just returns the same constraint.
DiscreteFactor::shared_ptr scale() const override {
return std::make_shared<SingleValue>(*this);
}
}; };
} // namespace gtsam } // namespace gtsam