Constraint.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* ----------------------------------------------------------------------------
  2. * GTSAM Copyright 2010, Georgia Tech Research Corporation,
  3. * Atlanta, Georgia 30332-0415
  4. * All Rights Reserved
  5. * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
  6. * See LICENSE for the license information
  7. * -------------------------------------------------------------------------- */
  8. /**
  9. * @file Constraint.h
  10. * @date May 15, 2012
  11. * @author Frank Dellaert
  12. */
  13. #pragma once
  14. #include <gtsam/discrete/DiscreteFactor.h>
  15. #include <gtsam_unstable/dllexport.h>
  16. #include <boost/assign.hpp>
  17. namespace gtsam {
  18. class Domain;
  19. /**
  20. * Base class for discrete probabilistic factors
  21. * The most general one is the derived DecisionTreeFactor
  22. */
  23. class Constraint : public DiscreteFactor {
  24. public:
  25. typedef boost::shared_ptr<Constraint> shared_ptr;
  26. protected:
  27. /// Construct n-way factor
  28. Constraint(const KeyVector& js) : DiscreteFactor(js) {}
  29. /// Construct unary factor
  30. Constraint(Key j) : DiscreteFactor(boost::assign::cref_list_of<1>(j)) {}
  31. /// Construct binary factor
  32. Constraint(Key j1, Key j2)
  33. : DiscreteFactor(boost::assign::cref_list_of<2>(j1)(j2)) {}
  34. /// construct from container
  35. template <class KeyIterator>
  36. Constraint(KeyIterator beginKey, KeyIterator endKey)
  37. : DiscreteFactor(beginKey, endKey) {}
  38. public:
  39. /// @name Standard Constructors
  40. /// @{
  41. /// Default constructor for I/O
  42. Constraint();
  43. /// Virtual destructor
  44. ~Constraint() override {}
  45. /// @}
  46. /// @name Standard Interface
  47. /// @{
  48. /*
  49. * Ensure Arc-consistency
  50. * @param j domain to be checked
  51. * @param domains all other domains
  52. */
  53. virtual bool ensureArcConsistency(size_t j,
  54. std::vector<Domain>& domains) const = 0;
  55. /// Partially apply known values
  56. virtual shared_ptr partiallyApply(const Values&) const = 0;
  57. /// Partially apply known values, domain version
  58. virtual shared_ptr partiallyApply(const std::vector<Domain>&) const = 0;
  59. /// @}
  60. };
  61. // DiscreteFactor
  62. } // namespace gtsam