43 virtual const char *
type()
const {
return "drwnVarUniverse"; }
51 int varCardinality(
int v)
const {
return _varCards.empty() ? _uniformCards : _varCards[v]; }
53 int maxCardinality()
const {
return _varCards.empty() ? _uniformCards : *max_element(_varCards.begin(), _varCards.end()); }
56 double logStateSpace()
const;
58 double logStateSpace(
const drwnClique& c)
const;
60 string varName(
int v)
const {
return _varNames.empty() ? (string(
"X") +
toString(v)) : _varNames[v]; }
62 int findVariable(
const char* name)
const;
65 int addVariable(
const char *name = NULL);
67 int addVariable(
int varCard,
const char *name = NULL);
76 bool save(drwnXMLNode& xml)
const;
77 bool load(drwnXMLNode& xml);
int _uniformCards
cardinality of variables if all the same
Definition: drwnVarUniverse.h:32
vector< string > _varNames
optional string name for each variable
Definition: drwnVarUniverse.h:34
vector< int > _varCards
cardinality of variables if some are different
Definition: drwnVarUniverse.h:33
bool hasUniformCardinality() const
returns true if all variables have the same cardinality
Definition: drwnVarUniverse.h:49
int maxCardinality() const
returns the greatest cardinality in the universe or in clique c
Definition: drwnVarUniverse.h:53
int varCardinality(int v) const
returns the cardinality of variable v (between 0 and _numVariables - 1)
Definition: drwnVarUniverse.h:51
virtual const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnVarUniverse.h:43
Data structure for definining the random variables (name and cardinality) for a given problem instanc...
Definition: drwnVarUniverse.h:29
int _numVariables
number of variables in the model (universe)
Definition: drwnVarUniverse.h:31
std::set< int > drwnClique
variable clique
Definition: drwnGraphUtils.h:37
virtual drwnVarUniverse * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnVarUniverse.h:44
std::string toString(const T &v)
Templated function to make conversion from simple data types like int and double to strings easy for ...
Definition: drwnStrUtils.h:134
string varName(int v) const
returns the name of variable v (between 0 and _numVariables - 1)
Definition: drwnVarUniverse.h:60
standard Darwin object interface (cloneable and writeable)
Definition: drwnInterfaces.h:72
int numVariables() const
returns the number of variables in the model
Definition: drwnVarUniverse.h:47