![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Class for assigning/browsing values to tuples of discrete variables. More...
#include <agrum/tools/multidim/SetInst.h>
Public Member Functions | |
Constructors / Destructors | |
SetInst () | |
Default constructor: creates an empty tuple. More... | |
SetInst (const SetInst &aI) | |
Copy constructor. More... | |
SetInst (const Instantiation &aI) | |
Copy constructor. More... | |
SetInst & | operator= (const SetInst &aI) |
Copy operator. More... | |
SetInst (MultiDimAdressable &aMD) | |
Constructor for a SetInst of all the variables of a MultiDimAdressable. More... | |
SetInst (const MultiDimAdressable &aMD) | |
Constructor for a SetInst of all the variables of a MultiDimAdressable. More... | |
SetInst (MultiDimAdressable *aMD) | |
Constructor for a SetInst of all the variables of a MultiDimAdressable. More... | |
SetInst (const MultiDimAdressable *aMD) | |
Constructor for a SetInst of all the variables of a MultiDimAdressable. More... | |
~SetInst () | |
Class destructor. More... | |
Accessors / Modifiers | |
Idx | nbrDim () const |
Returns the number of variables in the SetInst. More... | |
void | add (const DiscreteVariable &v) |
Adds a new variable in the SetInst. More... | |
void | erase (const DiscreteVariable &v) |
Removes a variable from the SetInst. More... | |
void | clear () |
Erase all variables from an SetInst. More... | |
Size | domainSize () const |
Returns the product of the variable's domain size in the SetInst. More... | |
Idx | pos (const DiscreteVariable &v) const |
Returns the position of the variable v. More... | |
Size | vals (Idx i) const |
Returns the current value of the variable at position i. More... | |
Size | vals (const DiscreteVariable &var) const |
Returns the current value of a given variable. More... | |
Size | vals (const DiscreteVariable *var) const |
Returns the current value of a given variable. More... | |
Idx | nbrOccurences (const DiscreteVariable &var) const |
Returns the current value of the variable at position i. More... | |
Idx | val (Idx i) const |
Returns the current value of a variable at a given position. More... | |
Idx | val (const DiscreteVariable &var) const |
Returns the current value of a given variable. More... | |
Idx | val (const DiscreteVariable *var) const |
Returns the current value of a given variable. More... | |
const DiscreteVariable & | variable (Idx i) const |
Returns the variable at position i in the tuple. More... | |
SetInst & | chgVal (const DiscreteVariable &v, Idx newVal) |
Assign newVal to variable v in the SetInst. More... | |
SetInst & | chgVal (const DiscreteVariable *v, Idx newVal) |
Assign newVal to variable v in the SetInst. More... | |
SetInst & | chgVal (Idx varPos, Idx newVal) |
Assign newVal to variable at position varPos in the SetInst. More... | |
SetInst & | chgVals (const DiscreteVariable &v, const Size newVal) |
Assign newVal to variable v in the SetInst. More... | |
SetInst & | addVal (const DiscreteVariable &v, Idx newVal) |
Add newVal to variable v in the SetInst. More... | |
SetInst & | addVals (const DiscreteVariable &v, const Size newVal) |
Add newVal to variable v in the SetInst. More... | |
SetInst & | remVal (const DiscreteVariable &v, Idx newVal) |
Remove newVal from the variable v in the SetInst. More... | |
SetInst & | remVals (const DiscreteVariable &v, const Size newVal) |
Remove newVal from the variable v in the SetInst. More... | |
SetInst & | interVals (const DiscreteVariable &v, const Size newVal) |
Does an intersection (binary and) between the old value and new value. More... | |
SetInst & | interVal (const DiscreteVariable &v, Idx newVal) |
Does an intersection (binary and) between the old value and new value. More... | |
SetInst & | chgVals (const DiscreteVariable *v, const Size newVal) |
Assign newVal to variable v in the SetInst. More... | |
SetInst & | addVal (const DiscreteVariable *v, Idx newVal) |
Add newVal to variable v in the SetInst. More... | |
SetInst & | addVals (const DiscreteVariable *v, const Size newVal) |
Add newVal to variable v in the SetInst. More... | |
SetInst & | remVal (const DiscreteVariable *v, Idx newVal) |
Remove newVal from the variable v in the SetInst. More... | |
SetInst & | remVals (const DiscreteVariable *v, const Size newVal) |
Remove newVal from the variable v in the SetInst. More... | |
SetInst & | interVals (const DiscreteVariable *v, const Size newVal) |
Does an intersection (binary and) between the old value and new value. More... | |
SetInst & | interVal (const DiscreteVariable *v, Idx newVal) |
Does an intersection (binary and) between the old value and new value. More... | |
SetInst & | chgVals (Idx varPos, const Size newVal) |
Assign newVal to variable at position varPos in the SetInst. More... | |
SetInst & | addVal (Idx varPos, Idx newVal) |
Add newVal to variable v in the SetInst. More... | |
SetInst & | addVals (Idx varPos, const Size newVal) |
Add newVal to variable varPos in the SetInst. More... | |
SetInst & | remVal (Idx varPos, Idx newVal) |
Remove newVal from the variable varPos in the SetInst. More... | |
SetInst & | remVals (Idx varPos, const Size newVal) |
Remove newVal from the variable varPos in the SetInst. More... | |
SetInst & | interVals (Idx varPos, const Size newVal) |
Does an intersection (binary and) between the old value and new value. More... | |
SetInst & | interVal (Idx varPos, Idx newVal) |
Does an intersection (binary and) between the old value and new value. More... | |
SetInst & | chgDifVal (Idx varPos, const Size newVal) |
Does the difference (binary or) between the old value and new value. More... | |
SetInst & | chgValIn (const SetInst &i) |
Change all the values to match does in i. More... | |
bool | contains (const DiscreteVariable &v) const |
Indicates whether a given variable belongs to the SetInst. More... | |
bool | contains (const DiscreteVariable *v) const |
Indicates whether a given variable belongs to the SetInst. More... | |
const Sequence< const DiscreteVariable *> & | variablesSequence () const |
Returns the sequence of DiscreteVariable of this SetInst. More... | |
virtual bool | empty () const |
Returns true if the SetInst is empty. More... | |
std::string | toString () const |
Give a string version of SetInst. More... | |
void | reorder (const Sequence< const DiscreteVariable * > &v) |
Reorder the variables given v. More... | |
void | reorder (const SetInst &i) |
Reorder the variables given i. More... | |
Overflow management methods. | |
bool | inOverflow () const |
Indicates whether the current value of the tuple is correct or not. More... | |
void | unsetOverflow () |
Removes the flag overflow. More... | |
void | unsetEnd () |
Alias for unsetOverflow(). More... | |
bool | end () const |
Returns true if the SetInst reached the end. More... | |
bool | rend () const |
Returns true if the SetInst reached the rend. More... | |
Static Public Member Functions | |
Static methods | |
static void | assign_values (Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const SetInst &i, SetInst &j) |
Assign the values of i in j, using bij as a bijection between i and j variables. More... | |
Protected Member Functions | |
virtual void | replace_ (const DiscreteVariable *x, const DiscreteVariable *y) |
Class for assigning/browsing values to tuples of discrete variables.
SetInst is designed to assign a set of deterministic values to tuples of variables for contextual dependencies detection.
For a variable I of possible determinstic instances \(i1, i2, i3, \ldots\) in the expresion of a set of instantiations is express by the boolean state of each instance transform in an integer. For example: \(i1\) or \(i2\) or \(i4\) will be :
There is two different types of setters:
To print information about a SetInst use the following function:
gum::SetInst::SetInst | ( | ) |
Default constructor: creates an empty tuple.
gum::SetInst::SetInst | ( | const Instantiation & | aI | ) |
Copy constructor.
aI | The SetInst to copy. |
gum::SetInst::SetInst | ( | MultiDimAdressable & | aMD | ) |
Constructor for a SetInst of all the variables of a MultiDimAdressable.
aMD | The array the variables of which are those of the SetInst. |
gum::SetInst::SetInst | ( | const MultiDimAdressable & | aMD | ) |
Constructor for a SetInst of all the variables of a MultiDimAdressable.
aMD | The array the variables of which are those of the SetInst. |
gum::SetInst::SetInst | ( | MultiDimAdressable * | aMD | ) |
Constructor for a SetInst of all the variables of a MultiDimAdressable.
aMD | The array the variables of which are those of the SetInst. |
gum::SetInst::SetInst | ( | const MultiDimAdressable * | aMD | ) |
Constructor for a SetInst of all the variables of a MultiDimAdressable.
aMD | The array the variables of which are those of the SetInst |
gum::SetInst::~SetInst | ( | ) |
Class destructor.
|
private |
Adds a new var to the sequence of vars.
If variable v already belongs to the SetInst tuple of variables, then nothing is done. In particular, no exception is thrown in this case.
@ warning note that this function does not deassociate the SetInst from its master MultiDimAdressable, if any. To do so, use function add instead.
v | The new var. |
DuplicateElement | Raised if v is already in the SetInst. |
Change the value of a variable.
varPos | The variable index. |
newVal | The new value. |
Change the value of a variable.
varPos | The variable index. |
newVal | The new value. |
|
private |
Removes a variable from the sequence of vars.
If variable v does not belong to the SetInst tuple of variables, then nothing is done. In particular, no exception is thrown in this case.
v | The variable to remove. |
|
private |
Swap 2 vars in the SetInst.
i | The first variable to swap. |
j | The second variable to swap. |
void gum::SetInst::add | ( | const DiscreteVariable & | v | ) |
Adds a new variable in the SetInst.
v | The new variable. |
DuplicateElement | Raised if c is already in this SetInst. |
OperationNotAllowed | Raised if the SetInst is a slave. |
SetInst& gum::SetInst::addVal | ( | const DiscreteVariable & | v, |
Idx | newVal | ||
) |
Add newVal to variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The value added to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
SetInst& gum::SetInst::addVal | ( | const DiscreteVariable * | v, |
Idx | newVal | ||
) |
Add newVal to variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The value added to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
Add newVal to variable v in the SetInst.
varPos | The variable whose value is assigned. |
newVal | The value added to the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos. |
SetInst& gum::SetInst::addVals | ( | const DiscreteVariable & | v, |
const Size | newVal | ||
) |
Add newVal to variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The value added to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
SetInst& gum::SetInst::addVals | ( | const DiscreteVariable * | v, |
const Size | newVal | ||
) |
Add newVal to variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The value added to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
Add newVal to variable varPos in the SetInst.
varPos | The variable whose value is assigned. |
newVal | The value added to the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos. |
|
static |
Assign the values of i in j, using bij as a bijection between i and j variables.
bij | Firsts are variables in i and seconds are variables in j. |
i | An SetInst used to change the values in j. |
j | An SetInst which receives new values from i using bij. |
NotFound | raised if a variable in i does not point to a variable in j or if a variable in i is missing in bij. |
Does the difference (binary or) between the old value and new value.
varPos | The variable whose value is assigned. |
newVal | The value intersected with the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos. |
SetInst& gum::SetInst::chgVal | ( | const DiscreteVariable & | v, |
Idx | newVal | ||
) |
Assign newVal to variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
SetInst& gum::SetInst::chgVal | ( | const DiscreteVariable * | v, |
Idx | newVal | ||
) |
Assign newVal to variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
Assign newVal to variable at position varPos in the SetInst.
varPos | The index of the variable whose value is assigned in the tuple of variables of the SetInst. |
newVal | The index of the value assigned (consider the values of the variable as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by the variable. |
NotFound | raised if the variable does not belong to this |
OutOfBound | raised if newVal is not a possible value for the variable |
Change all the values to match does in i.
i | The new set of value for this SetInst. |
SetInst& gum::SetInst::chgVals | ( | const DiscreteVariable & | v, |
const Size | newVal | ||
) |
Assign newVal to variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
SetInst& gum::SetInst::chgVals | ( | const DiscreteVariable * | v, |
const Size | newVal | ||
) |
Assign newVal to variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
Assign newVal to variable at position varPos in the SetInst.
varPos | The index of the variable whose value is assigned in the tuple of variables of the SetInst. |
newVal | The index of the value assigned (consider the values of the variable as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by the variable. |
NotFound | Raised if the variable does not belong to this |
OutOfBound | Raised if newVal is not a possible value for the variable |
void gum::SetInst::clear | ( | ) |
Erase all variables from an SetInst.
OperationNotAllowed | Raised if the SetInst is a slave. |
bool gum::SetInst::contains | ( | const DiscreteVariable & | v | ) | const |
bool gum::SetInst::contains | ( | const DiscreteVariable * | v | ) | const |
Size gum::SetInst::domainSize | ( | ) | const |
|
virtual |
bool gum::SetInst::end | ( | ) | const |
void gum::SetInst::erase | ( | const DiscreteVariable & | v | ) |
Removes a variable from the SetInst.
v | The variable to erase. |
NotFound | Raised if v is not in this SetInst. |
OperationNotAllowed | Raised if the SetInst is a slave. |
bool gum::SetInst::inOverflow | ( | ) | const |
Indicates whether the current value of the tuple is correct or not.
SetInst& gum::SetInst::interVal | ( | const DiscreteVariable & | v, |
Idx | newVal | ||
) |
Does an intersection (binary and) between the old value and new value.
v | The variable whose value is assigned. |
newVal | The value intersected with the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
SetInst& gum::SetInst::interVal | ( | const DiscreteVariable * | v, |
Idx | newVal | ||
) |
Does an intersection (binary and) between the old value and new value.
v | The variable whose value is assigned. |
newVal | The value intersected with the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
Does an intersection (binary and) between the old value and new value.
varPos | The variable whose value is assigned. |
newVal | The value intersected with the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos. |
SetInst& gum::SetInst::interVals | ( | const DiscreteVariable & | v, |
const Size | newVal | ||
) |
Does an intersection (binary and) between the old value and new value.
v | The variable whose value is assigned. |
newVal | The value intersected with the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
SetInst& gum::SetInst::interVals | ( | const DiscreteVariable * | v, |
const Size | newVal | ||
) |
Does an intersection (binary and) between the old value and new value.
v | The variable whose value is assigned. |
newVal | The value intersected with the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
Does an intersection (binary and) between the old value and new value.
varPos | The variable whose value is assigned. |
newVal | The value intersected with the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos. |
Idx gum::SetInst::nbrDim | ( | ) | const |
Idx gum::SetInst::nbrOccurences | ( | const DiscreteVariable & | var | ) | const |
Returns the current value of the variable at position i.
var | the variable. |
NotFound | raised if the element cannot be found. |
Copy operator.
Idx gum::SetInst::pos | ( | const DiscreteVariable & | v | ) | const |
SetInst& gum::SetInst::remVal | ( | const DiscreteVariable & | v, |
Idx | newVal | ||
) |
Remove newVal from the variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The value removed to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
SetInst& gum::SetInst::remVal | ( | const DiscreteVariable * | v, |
Idx | newVal | ||
) |
Remove newVal from the variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The value removed to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
Remove newVal from the variable varPos in the SetInst.
varPos | The variable whose value is assigned. |
newVal | The value removed to the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos. |
SetInst& gum::SetInst::remVals | ( | const DiscreteVariable & | v, |
const Size | newVal | ||
) |
Remove newVal from the variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The value removed to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
SetInst& gum::SetInst::remVals | ( | const DiscreteVariable * | v, |
const Size | newVal | ||
) |
Remove newVal from the variable v in the SetInst.
v | The variable whose value is assigned. |
newVal | The value removed to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v. |
Remove newVal from the variable varPos in the SetInst.
varPos | The variable whose value is assigned. |
newVal | The value removed to the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos. |
bool gum::SetInst::rend | ( | ) | const |
void gum::SetInst::reorder | ( | const Sequence< const DiscreteVariable * > & | v | ) |
Reorder the variables given v.
v | The new order of variables in this SetInst. |
void gum::SetInst::reorder | ( | const SetInst & | i | ) |
Reorder the variables given i.
i | The new order of variables in this SetInst. |
|
protectedvirtual |
std::string gum::SetInst::toString | ( | ) | const |
void gum::SetInst::unsetEnd | ( | ) |
Alias for unsetOverflow().
void gum::SetInst::unsetOverflow | ( | ) |
Removes the flag overflow.
See full documentation for details. (Recommended).
Idx gum::SetInst::val | ( | const DiscreteVariable & | var | ) | const |
Idx gum::SetInst::val | ( | const DiscreteVariable * | var | ) | const |
Returns the current value of the variable at position i.
i | The index of the variable. |
NotFound | Raised if the element cannot be found. |
Size gum::SetInst::vals | ( | const DiscreteVariable & | var | ) | const |
Size gum::SetInst::vals | ( | const DiscreteVariable * | var | ) | const |
const DiscreteVariable& gum::SetInst::variable | ( | Idx | i | ) | const |
Returns the variable at position i in the tuple.
i | The index of the variable. |
NotFound | Raised if the element cannot be found. |
const Sequence< const DiscreteVariable* >& gum::SetInst::variablesSequence | ( | ) | const |
Returns the sequence of DiscreteVariable of this SetInst.
|
private |
|
private |