gtsam/gtsam_unstable/discrete/Constraint.h

85 lines
2.0 KiB
C
Raw Normal View History

/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file Constraint.h
* @date May 15, 2012
* @author Frank Dellaert
*/
#pragma once
#include <gtsam/discrete/DiscreteFactor.h>
2021-11-18 23:54:00 +08:00
#include <gtsam_unstable/dllexport.h>
#include <boost/assign.hpp>
namespace gtsam {
2021-11-18 23:54:00 +08:00
class Domain;
2021-11-18 23:54:00 +08:00
/**
* Base class for discrete probabilistic factors
* The most general one is the derived DecisionTreeFactor
*/
class Constraint : public DiscreteFactor {
public:
typedef boost::shared_ptr<Constraint> shared_ptr;
2021-11-18 23:54:00 +08:00
protected:
/// Construct n-way factor
Constraint(const KeyVector& js) : DiscreteFactor(js) {}
2021-11-18 23:54:00 +08:00
/// Construct unary factor
Constraint(Key j) : DiscreteFactor(boost::assign::cref_list_of<1>(j)) {}
2021-11-18 23:54:00 +08:00
/// Construct binary factor
Constraint(Key j1, Key j2)
: DiscreteFactor(boost::assign::cref_list_of<2>(j1)(j2)) {}
2021-11-18 23:54:00 +08:00
/// construct from container
template <class KeyIterator>
Constraint(KeyIterator beginKey, KeyIterator endKey)
: DiscreteFactor(beginKey, endKey) {}
2021-11-18 23:54:00 +08:00
public:
/// @name Standard Constructors
/// @{
2021-11-18 23:54:00 +08:00
/// Default constructor for I/O
Constraint();
2021-11-18 23:54:00 +08:00
/// Virtual destructor
~Constraint() override {}
2021-11-18 23:54:00 +08:00
/// @}
/// @name Standard Interface
/// @{
2021-11-18 23:54:00 +08:00
/*
* Ensure Arc-consistency
* @param j domain to be checked
* @param domains all other domains
*/
virtual bool ensureArcConsistency(size_t j,
std::vector<Domain>& domains) const = 0;
2021-11-18 23:54:00 +08:00
/// Partially apply known values
virtual shared_ptr partiallyApply(const Values&) const = 0;
2021-11-18 23:54:00 +08:00
/// Partially apply known values, domain version
virtual shared_ptr partiallyApply(const std::vector<Domain>&) const = 0;
/// @}
};
// DiscreteFactor
2021-11-18 23:54:00 +08:00
} // namespace gtsam