dai::SharedParameters Class Reference

Represents a single factor or set of factors whose parameters should be estimated. More...

#include <dai/emalg.h>

List of all members.

Public Types

typedef size_t FactorIndex
 Convenience label for an index of a factor in a FactorGraph.
typedef std::map< FactorIndex,
std::vector< Var > > 
FactorOrientations
 Convenience label for a grouping of factor orientations.

Public Member Functions

 SharedParameters (const FactorOrientations &varorders, ParameterEstimation *estimation, bool ownPE=false)
 Constructor.
 SharedParameters (std::istream &is, const FactorGraph &fg)
 Construct a SharedParameters object from an input stream is and a factor graph fg.
 SharedParameters (const SharedParameters &sp)
 Copy constructor.
 ~SharedParameters ()
 Destructor.
void collectSufficientStatistics (InfAlg &alg)
 Collect the sufficient statistics from expected values (beliefs) according to alg.
void setParameters (FactorGraph &fg)
 Estimate and set the shared parameters.

Private Member Functions

void setPermsAndVarSetsFromVarOrders ()
 Initializes _varsets and _perms from _varorders and checks whether their state spaces correspond with _estimation.probSize().

Static Private Member Functions

static Permute calculatePermutation (const std::vector< Var > &varOrder, VarSet &outVS)
 Calculates the permutation that permutes the canonical ordering into the desired ordering.

Private Attributes

std::map< FactorIndex, VarSet_varsets
 Maps factor indices to the corresponding VarSets.
std::map< FactorIndex, Permute_perms
 Maps factor indices to the corresponding Permute objects that permute the canonical ordering into the desired ordering.
FactorOrientations _varorders
 Maps factor indices to the corresponding desired variable orderings.
ParameterEstimation_estimation
 Parameter estimation method to be used.
bool _ownEstimation
 Indicates whether *this gets ownership of _estimation.


Detailed Description

Represents a single factor or set of factors whose parameters should be estimated.

To ensure that parameters can be shared between different factors during EM learning, each factor's values are reordered to match a desired variable ordering. The ordering of the variables in a factor may therefore differ from the canonical ordering used in libDAI. The SharedParameters class combines one or more factors (together with the specified orderings of the variables) with a ParameterEstimation object, taking care of the necessary permutations of the factor entries / parameters.

Author:
Charles Vaske

Member Typedef Documentation

Convenience label for an index of a factor in a FactorGraph.

typedef std::map<FactorIndex, std::vector<Var> > dai::SharedParameters::FactorOrientations

Convenience label for a grouping of factor orientations.


Constructor & Destructor Documentation

dai::SharedParameters::SharedParameters ( const FactorOrientations varorders,
ParameterEstimation estimation,
bool  ownPE = false 
)

Constructor.

Parameters:
varorders all the factor orientations for this parameter
estimation a pointer to the parameter estimation method
ownPE whether the constructed object gets ownership of estimation

dai::SharedParameters::SharedParameters ( std::istream &  is,
const FactorGraph fg 
)

Construct a SharedParameters object from an input stream is and a factor graph fg.

See also:
Shared parameters block format
Exceptions:
INVALID_EMALG_FILE if the input stream is not valid

dai::SharedParameters::SharedParameters ( const SharedParameters sp  )  [inline]

Copy constructor.

dai::SharedParameters::~SharedParameters (  )  [inline]

Destructor.


Member Function Documentation

Permute dai::SharedParameters::calculatePermutation ( const std::vector< Var > &  varOrder,
VarSet outVS 
) [static, private]

Calculates the permutation that permutes the canonical ordering into the desired ordering.

Parameters:
varOrder Desired ordering of variables
outVS Contains variables in varOrder represented as a VarSet
Returns:
Permute object for permuting variables in varOrder from the canonical libDAI ordering into the desired ordering

void dai::SharedParameters::setPermsAndVarSetsFromVarOrders (  )  [private]

Initializes _varsets and _perms from _varorders and checks whether their state spaces correspond with _estimation.probSize().

void dai::SharedParameters::collectSufficientStatistics ( InfAlg alg  ) 

Collect the sufficient statistics from expected values (beliefs) according to alg.

For each of the relevant factors (that shares the parameters we are interested in), the corresponding belief according to alg is obtained and its entries are permuted such that their ordering corresponds with the shared parameters that we are estimating. Then, the parameter estimation subclass method addSufficientStatistics() is called with this vector of expected values of the parameters as input.

void dai::SharedParameters::setParameters ( FactorGraph fg  ) 

Estimate and set the shared parameters.

Based on the sufficient statistics collected so far, the shared parameters are estimated using the parameter estimation subclass method estimate(). Then, each of the relevant factors in fg (that shares the parameters we are interested in) is set according to those parameters (permuting the parameters accordingly).


Member Data Documentation

Maps factor indices to the corresponding VarSets.

Maps factor indices to the corresponding Permute objects that permute the canonical ordering into the desired ordering.

Maps factor indices to the corresponding desired variable orderings.

Parameter estimation method to be used.

Indicates whether *this gets ownership of _estimation.


The documentation for this class was generated from the following files:

Generated on Thu Aug 5 19:04:05 2010 for libDAI by  doxygen 1.5.5