git HEAD
--------
+* Removed deprecated interfaces.
* Added FactorGraph::isMaximal(size_t) and FactorGraph::maximalFactor(size_t).
* Added optional reverse argument to Permute::Permute( const std::vector<Var>& )
constructor.
return _clusters[I];
}
- /// Returns a constant reference to the clusters
- /** \deprecated Please use dai::ClusterGraph::clusters() instead
- */
- const std::vector<VarSet>& toVector() const { return _clusters; }
-
- /// Returns number of clusters
- /** \deprecated Please use dai::ClusterGraph::nrClusters() instead
- */
- size_t size() const { return _G.nrNodes2(); }
-
/// Returns the index of variable \a n
/** \throw OBJECT_NOT_FOUND if the variable does not occur in the cluster graph
*/
/// Returns a copy of the \a i 'th entry of the value vector
T operator[] (size_t i) const { return _p[i]; }
- /// Returns a reference to the \a i 'th entry of the value vector
- /// \deprecated Please use dai::TFactor::set() instead
- T& operator[] (size_t i) { return _p[i]; }
-
/// Returns constant reference to variable set (i.e., the variables on which the factor depends)
const VarSet& vars() const { return _vs; }
*/
size_t nrStates() const { return _p.size(); }
- /// Returns the number of possible joint states of the variables on which the factor depends, \f$\prod_{l\in L} S_l\f$
- /** \note This is equal to the length of the value vector.
- * \deprecated Please use dai::TFactor::nrStates() instead.
- */
- size_t states() const { return _p.size(); }
-
/// Returns the Shannon entropy of \c *this, \f$-\sum_i p_i \log p_i\f$
T entropy() const { return _p.entropy(); }
/// Shorthand for BipartiteGraph::Edge
typedef BipartiteGraph::Edge Edge;
- /// Iterator over factors
- /** \deprecated The FactorGraph iterator interface will be removed in future versions of libDAI
- */
- typedef std::vector<Factor>::iterator iterator;
-
- /// Constant iterator over factors
- /** \deprecated The FactorGraph iterator interface will be removed in future versions of libDAI
- */
- typedef std::vector<Factor>::const_iterator const_iterator;
-
private:
/// Stores the neighborhood structure
BipartiteGraph _G;
/// Returns constant reference to all variables
const std::vector<Var>& vars() const { return _vars; }
- /// Returns reference to \a I 'th factor
- /** \deprecated Please use the const member dai::FactorGraph::factor( size_t ) instead,
- * or dai::FactorGraph::setFactor() for changing a factor.
- */
- Factor& factor( size_t I ) {
- DAI_DEBASSERT( I < nrFactors() );
- return _factors[I];
- }
-
/// Returns constant reference to \a I 'th factor
const Factor& factor( size_t I ) const {
DAI_DEBASSERT( I < nrFactors() );
const Neighbor& nbF( size_t I, size_t _i ) const { return _G.nb2(I)[_i]; }
//@}
- /// \name Iterator interface
- //@{
- /// Returns iterator pointing to first factor
- /** \deprecated The FactorGraph iterator interface will be removed in future versions of libDAI
- */
- iterator begin() { return _factors.begin(); }
- /// Returns constant iterator pointing to first factor
- /** \deprecated The FactorGraph iterator interface will be removed in future versions of libDAI
- */
- const_iterator begin() const { return _factors.begin(); }
- /// Returns iterator pointing beyond last factor
- /** \deprecated The FactorGraph iterator interface will be removed in future versions of libDAI
- */
- iterator end() { return _factors.end(); }
- /// Returns constant iterator pointing beyond last factor
- /** \deprecated The FactorGraph iterator interface will be removed in future versions of libDAI
- */
- const_iterator end() const { return _factors.end(); }
- //@}
-
/// \name Queries
//@{
/// Returns neighborhood structure
* strict subset of another factor domain.
*/
std::vector<VarSet> maximalFactorDomains() const;
-
- /// Returns the maximal factors domains in this factorgraph
- /** \deprecated Please use dai::FactorGraph::maximalFactorDomains() instead
- */
- std::vector<VarSet> cliques() const {
- return maximalFactorDomains();
- }
//@}
/// \name Backup/restore mechanism for factors
container_type _p;
public:
- /// Enumerates different ways of normalizing a probability measure.
- /**
- * - NORMPROB means that the sum of all entries should be 1;
- * - NORMLINF means that the maximum absolute value of all entries should be 1.
- * \deprecated Please use dai::ProbNormType instead.
- */
- typedef enum { NORMPROB, NORMLINF } NormType;
- /// Enumerates different distance measures between probability measures.
- /**
- * - DISTL1 is the \f$\ell_1\f$ distance (sum of absolute values of pointwise difference);
- * - DISTLINF is the \f$\ell_\infty\f$ distance (maximum absolute value of pointwise difference);
- * - DISTTV is the total variation distance (half of the \f$\ell_1\f$ distance);
- * - DISTKL is the Kullback-Leibler distance (\f$\sum_i p_i (\log p_i - \log q_i)\f$).
- * - DISTHEL is the Hellinger distance (\f$\frac{1}{2}\sum_i (\sqrt{p_i}-\sqrt{q_i})^2\f$).
- * \deprecated Please use dai::ProbDistType instead.
- */
- typedef enum { DISTL1, DISTLINF, DISTTV, DISTKL, DISTHEL } DistType;
-
/// \name Constructors and destructors
//@{
/// Default constructor (constructs empty vector)
* \param end Points just beyond last instance to be added.
* \param sizeHint For efficiency, the number of entries can be speficied by \a sizeHint;
* the value 0 can be given if the size is unknown, but this will result in a performance penalty.
- * \deprecated In future libDAI versions, the \a sizeHint argument will no longer default to 0.
*/
template <typename TIterator>
- TProb( TIterator begin, TIterator end, size_t sizeHint=0 ) : _p() {
+ TProb( TIterator begin, TIterator end, size_t sizeHint ) : _p() {
_p.reserve( sizeHint );
_p.insert( _p.begin(), begin, end );
}
/// Returns a copy of the \a i 'th entry
T operator[]( size_t i ) const { return get(i); }
- /// Returns reference to the \a i 'th entry
- /** \deprecated Please use dai::TProb::set() instead
- */
- T& operator[]( size_t i ) { return _p[i]; }
-
/// Returns length of the vector (i.e., the number of entries)
size_t size() const { return _p.size(); }
- /// Accumulate over all values, similar to std::accumulate
- /** The following calculation is done:
- * \code
- * T t = op2(init);
- * for( const_iterator it = begin(); it != end(); it++ )
- * t = op1( t, op2(*it) );
- * return t;
- * \endcode
- * \deprecated Please use dai::TProb::accumulateSum or dai::TProb::accumulateMax instead
- */
- template<typename binOp, typename unOp> T accumulate( T init, binOp op1, unOp op2 ) const {
- T t = op2(init);
- for( const_iterator it = begin(); it != end(); it++ )
- t = op1( t, op2(*it) );
- return t;
- }
-
-
/// Accumulate all values (similar to std::accumulate) by summing
/** The following calculation is done:
* \code
return *this;
}
- /// Sets a property (a key \a key with a corresponding value \a val)
- /** \deprecated Please use dai::PropertySet::set(const PropertyKey&, const PropertyValue&) instead
- */
- PropertySet& Set( const PropertyKey& key, const PropertyValue& val ) {
- return set( key, val );
- }
-
/// Set properties according to \a newProps, overriding properties that already exist with new values
PropertySet& set( const PropertySet& newProps ) {
const std::map<PropertyKey, PropertyValue> *m = &newProps;
return *this;
}
- /// Set properties according to \a newProps, overriding properties that already exist with new values
- /** \deprecated Please use dai::PropertySet::set(const PropertySet&) instead
- */
- PropertySet& Set( const PropertySet& newProps ) {
- return set( newProps );
- }
-
/// Shorthand for (temporarily) adding properties
/** \par Example:
\code
}
}
}
-
- /// Converts the type of the property value corresponding with \a key from string to \a ValueType (if necessary)
- /** The implementation makes use of boost::lexical_cast
- * \tparam ValueType Type to which the value should be cast
- * \throw IMPOSSIBLE_TYPECAST if the type cast cannot be done
- * \deprecated Please use dai::PropertySet::convertTo() instead
- */
- template<typename ValueType>
- void ConvertTo( const PropertyKey& key ) {
- convertTo<ValueType>( key );
- }
//@}
//@}
return x->second;
}
- /// Gets the value corresponding to \a key
- /** \throw OBJECT_NOT_FOUND if the key cannot be found in \c *this
- * \deprecated Please use dai::PropertySet::get() instead
- */
- const PropertyValue& Get( const PropertyKey& key ) const {
- return get( key );
- }
-
/// Gets the value corresponding to \a key, cast to \a ValueType
/** \tparam ValueType Type to which the value should be cast
* \throw OBJECT_NOT_FOUND if the key cannot be found in \c *this
}
}
- /// Gets the value corresponding to \a key, cast to \a ValueType
- /** \tparam ValueType Type to which the value should be cast
- * \throw OBJECT_NOT_FOUND if the key cannot be found in \c *this
- * \throw IMPOSSIBLE_TYPECAST if the type cast cannot be done
- * \deprecated Please use dai::PropertySet::getAs() instead
- */
- template<typename ValueType>
- ValueType GetAs( const PropertyKey& key ) const {
- return getAs<ValueType>( key );
- }
-
/// Gets the value corresponding to \a key, cast to \a ValueType, converting from a string if necessary
/** If the type of the value is already equal to \a ValueType, no conversion is done.
* Otherwise, the type of the value should be a std::string, in which case boost::lexical_cast is
ns |= fac->second.vars();
recomputeORs( ns );
}
-
- /// Calculates counting numbers of inner regions based upon counting numbers of outer regions
- /** The counting numbers of the inner regions are set using the Moebius inversion formula:
- * \f[ c_\beta := 1 - \sum_{\gamma \in \mathrm{an}(\beta)} c_\gamma \f]
- * where \f$\mathrm{an}(\beta)\f$ are the ancestors of inner region \f$\beta\f$ according to
- * the partial ordering induced by the subset relation (i.e., a region is a child of another
- * region if its variables are a subset of the variables of its parent region).
- * \deprecated This functionality has been protected.
- */
- void calcCountingNumbers() { calcCVMCountingNumbers(); }
-
- /// Recompute all outer regions
- /** The factor contents of each outer region is set to the product of the factors belonging to that region.
- * \deprecated This functionality has been protected.
- */
- void RecomputeORs() { recomputeORs(); }
-
- /// Recompute all outer regions involving the variables in \a vs
- /** The factor contents of each outer region involving at least one of the variables in \a vs is set to the product of the factors belonging to that region.
- * \deprecated This functionality has been protected.
- */
- void RecomputeORs( const VarSet& vs ) { recomputeORs( vs ); }
-
- /// Recompute all outer regions involving factor \a I
- /** The factor contents of each outer region involving the \a I 'th factor is set to the product of the factors belonging to that region.
- * \deprecated This functionality has been protected.
- */
- void RecomputeOR( size_t I ) { recomputeOR( I ); }
//@}
/// \name Input/output
class DEdge {
public:
/// First node index (source of edge)
- union {
- size_t first;
- /// \deprecated Please use member dai::DEdge::first instead
- size_t n1;
- };
+ size_t first;
/// Second node index (target of edge)
- union {
- size_t second;
- /// \deprecated Please use member dai::DEdge::second instead
- size_t n2;
- };
+ size_t second;
/// Default constructor
DEdge() : first(0), second(0) {}
class UEdge {
public:
/// First node index
- union {
- size_t first;
- /// \deprecated Please use member dai::UEdge::first instead
- size_t n1;
- };
+ size_t first;
/// Second node index
- union {
- size_t second;
- /// \deprecated Please use member dai::UEdge::second instead
- size_t n2;
- };
+ size_t second;
/// Default constructor
UEdge() : first(0), second(0) {}
}
-/// Constructs a minimum spanning tree from the (non-negatively) weighted graph \a G using Prim's algorithm.
-/** \param G Weighted graph that should have non-negative weights.
- * \note Uses implementation from Boost Graph Library.
- * \note The vertices of \a G must be in the range [0,N) where N is the number of vertices of \a G.
- * \deprecated Please use dai::MinSpanningTree(const WeightedGraph&, bool) instead
- */
-template<typename T> RootedTree MinSpanningTree( const WeightedGraph<T> &G ) {
- return MinSpanningTree( G, true );
-}
-
-
-/// Constructs a minimum spanning tree from the (non-negatively) weighted graph \a G using Prim's algorithm.
-/** \param G Weighted graph that should have non-negative weights.
- * \note Uses implementation from Boost Graph Library.
- * \note The vertices of \a G must be in the range [0,N) where N is the number of vertices of \a G.
- * \deprecated Please use dai::MinSpanningTree(const WeightedGraph&, bool) instead
- */
-template<typename T> RootedTree MaxSpanningTree( const WeightedGraph<T> &G ) {
- return MaxSpanningTree( G, true );
-}
-
-
-/// Constructs a random undirected graph of \a N nodes, where each node has connectivity \a d
-/** Algorithm 1 in [\ref StW99].
- * Draws a random graph of size \a N and uniform degree \a d
- * from an almost uniform probability distribution over these graphs
- * (which becomes uniform in the limit that \a d is small and \a N goes
- * to infinity).
- * \deprecated Please use dai::createGraphRegular(size_t, size_t) instead
- */
-GraphEL RandomDRegularGraph( size_t N, size_t d );
-
-
} // end of namespace dai
}
-GraphEL RandomDRegularGraph( size_t N, size_t d ) {
- return GraphEL( createGraphRegular( N, d ) );
-}
-
-
} // end of namespace dai
DAI_THROWE(INVALID_FACTORGRAPH_FILE,"Cannot read number of nonzero factor values for " + toString(I) + "'th factor");
if( verbose >= 3 )
cout << " number of nonzero values: " << nrNonZeros << endl;
- DAI_ASSERT( nrNonZeros == factors[I].states() );
+ DAI_ASSERT( nrNonZeros == factors[I].nrStates() );
for( size_t li = 0; li < nrNonZeros; li++ ) {
Real val;
is >> val;
// assign value after calculating its linear index corresponding to the permutation
if( verbose >= 4 )
cout << " " << li << "'th value " << val << " corresponds with index " << permindex.convertLinearIndex(li) << endl;
- factors[I][permindex.convertLinearIndex( li )] = val;
+ factors[I].set( permindex.convertLinearIndex( li ), val );
}
}
if( verbose >= 3 )