Darwin  1.10(beta)
Public Member Functions | Protected Attributes | List of all members
drwnSparseFactor Class Reference

Encapsulates variables that the represented function is a function of. Allows user to add variables, look up variable cardinality and retrieve all variables. Implementation uses coordinate format (Bader and Kolda, SIAM Journal on Scientific Computing, 2007). More...

Inheritance diagram for drwnSparseFactor:
drwnFactor drwnStdObjIface drwnWriteable drwnCloneable drwnTypeable

Public Member Functions

 drwnSparseFactor (const drwnVarUniversePtr &ptr)
 create an empty sparse factor
 
const char * type () const
 returns object type as a string (e.g., Foo::type() { return "Foo"; })
 
drwnSparseFactorclone (void) const
 returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); }
 
int entries () const
 
const std::map< drwnLocalAssignment, double > & getAssignments () const
 
double getValueOf (const drwnFullAssignment &y) const
 Returns the value of the factor for a given (full) assignment.
 
double getValueOf (const drwnPartialAssignment &y) const
 Returns the value of the factor for a given partial assignment.
 
void setValueOf (const drwnFullAssignment &y, double val)
 Sets the value of the factor for a given (full) assignment.
 
void setValueOf (const drwnPartialAssignment &y, double val)
 Sets the value of the factor for a given partial assignment.
 
- Public Member Functions inherited from drwnFactor
 drwnFactor (const drwnVarUniversePtr &ptr)
 create an empty factor
 
 drwnFactor (const drwnFactor &psi)
 copy constructor
 
bool empty () const
 true if the factor contains no variables
 
size_t size () const
 number of variables in this factor
 
virtual size_t memory () const
 number of bytes comsumed by the factor data (excludes variables lists, etc)
 
const drwnVarUniversePtrgetUniverse () const
 returns the variable universe
 
drwnVarUniverse getSubUniverse () const
 returns the subset of the universe for this factor
 
bool hasVariable (int var) const
 returns true if the variable is included in this factor
 
int varId (int indx) const
 returns variable at given index
 
int varCard (int indx) const
 return cardinality of variable at given index
 
virtual void addVariable (int var)
 add variable by id
 
void addVariable (const char *name)
 add variable by name
 
void addVariables (const char *name,...)
 add multiple variables
 
void addVariables (const vector< int > &c)
 
void addVariables (const drwnClique &c)
 
void addVariables (const drwnFactor &psi)
 
const vector< int > & getOrderedVars () const
 returns the ordered set of variables over which this factor is defined
 
drwnClique getClique () const
 returns the set of variables over which this factor is defined
 
bool save (drwnXMLNode &xml) const
 write object to XML node (see also write)
 
bool load (drwnXMLNode &xml)
 read object from XML node (see also read)
 
double getValueOf (const drwnPartialAssignment &y) const
 Returns the value of the factor for a given partial assignment. The variables in the scope of this factor must be defined.
 
void setValueOf (const drwnPartialAssignment &y, double val)
 Sets the value of the factor for a given partial assignment. The variables in the scope of this factor must be defined.
 
- Public Member Functions inherited from drwnWriteable
bool write (const char *filename) const
 write object to file (calls save)
 
bool read (const char *filename)
 read object from file (calls load)
 
void dump () const
 print object's current state to standard output (for debugging)
 

Protected Attributes

std::map< drwnLocalAssignment, double > _assignments
 maps variable values to costs
 
- Protected Attributes inherited from drwnFactor
drwnVarUniversePtr _pUniverse
 all variables in the universe
 
vector< int > _variables
 list of variables in factor (by index in factor)
 
map< int, int > _varIndex
 index of variable in factor (by variable id)
 

Detailed Description

Encapsulates variables that the represented function is a function of. Allows user to add variables, look up variable cardinality and retrieve all variables. Implementation uses coordinate format (Bader and Kolda, SIAM Journal on Scientific Computing, 2007).

Todo:
Replace getAssignments with overloading the [] operator.

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