/// Represents a set of variables.
-/** The variables in the set are sorted according to their labels.
- * \note A VarSet is implemented using a SmallSet<Var> instead
+/** \note A VarSet is implemented using a SmallSet<Var> instead
* of the more natural std::set<Var> because of efficiency reasons.
+ * That is, internally, the variables in the set are sorted according
+ * to their labels: the set of variables \f$\{x_l\}_{l\in L}\f$ is
+ * represented as a vector \f$(x_{l(0)},x_{l(1)},\dots,x_{l(|L|-1)})\f$
+ * where \f$l(0) < l(1) < \dots < l(|L|-1)\f$
+ * and \f$L = \{l(0),l(1),\dots,l(|L|-1)\}\f$.
*/
class VarSet : public SmallSet<Var> {
public:
/// Default constructor
VarSet() : SmallSet<Var>() {}
- /// Copy constructor
- VarSet( const VarSet &x ) : SmallSet<Var>(x) {}
-
- /// Assignment operator
- VarSet& operator=( const VarSet &x ) {
- if( this != &x ) {
- SmallSet<Var>::operator=( x );
- }
- return *this;
- }
-
/// Construct from SmallSet<Var>
VarSet( const SmallSet<Var> &x ) : SmallSet<Var>(x) {}
/** The number of states of the Cartesian product of the variables in this VarSet
* is simply the product of the number of states of each variable in this VarSet.
* If *this corresponds with the set \f$\{x_l\}_{l\in L}\f$,
- * where variable \f$x_l\f$ has label \f$l\f$, and denoting by \f$S_l\f$ the
- * number of possible values ("states") of variable \f$x_l\f$, the number of
+ * where variable \f$x_l\f$ has label \f$l\f$, and denoting by \f$S_l\f$ the
+ * number of possible values ("states") of variable \f$x_l\f$, the number of
* joint configurations of the variables in \f$\{x_l\}_{l\in L}\f$ is given by \f$\prod_{l\in L} S_l\f$.
*/
size_t nrStates() {
VarSet( const Var &n ) : SmallSet<Var>(n) {}
/// Construct a VarSet with two elements
- VarSet( const Var &n1, const Var &n2 ) : SmallSet<Var>(n1,n2) {}
+ VarSet( const Var &n1, const Var &n2 ) : SmallSet<Var>(n1,n2) {}
/// Construct a VarSet from a range.
/** \tparam VarIterator Iterates over instances of type Var.
* \return The linear index in the Cartesian product of the variables in *this
* corresponding with the joint assignment specified by \a states, where it is
* assumed that \a states[\a m]==0 for all \a m in *this which are not in \a states.
- *
+ *
* The linear index is calculated as follows. The variables in *this are
* ordered according to their label (in ascending order); say *this corresponds with
* the set \f$\{x_{l(0)},x_{l(1)},\dots,x_{l(n-1)}\}\f$ with \f$l(0) < l(1) < \dots < l(n-1)\f$,
* \f}
*
* \note If *this corresponds with \f$\{x_l\}_{l\in L}\f$, and \a states specifies a state
- * for each variable \f$x_l\f$ for \f$l\in L\f$, calcState(const std::map<Var,size_t> &) induces a mapping
+ * for each variable \f$x_l\f$ for \f$l\in L\f$, calcState(const std::map<Var,size_t> &) induces a mapping
* \f$\sigma : \prod_{l\in L} X_l \to \{0,1,\dots,\prod_{l\in L} S_l-1\}\f$ that
- * maps a joint state to a linear index; this is the inverse of the mapping
+ * maps a joint state to a linear index; this is the inverse of the mapping
* \f$\sigma^{-1}\f$ induced by calcStates(size_t).
*/
size_t calcState( const std::map<Var, size_t> &states ) {
* The variables in *this are ordered according to their label (in ascending order); say *this corresponds with
* the set \f$\{x_{l(0)},x_{l(1)},\dots,x_{l(n-1)}\}\f$ with \f$l(0) < l(1) < \dots < l(n-1)\f$,
* where variable \f$x_l\f$ has label \a l. Denote by \f$S_l\f$ the number of possible values
- * ("states") of variable \f$x_l\f$ with label \a l.
+ * ("states") of variable \f$x_l\f$ with label \a l.
* The mapping \a s returned by this function is defined as:
* \f{eqnarray*}
- * s(x_{l(i)}) = \left[\frac{S \mbox { mod } \prod_{j=0}^{i} S_{l(j)}}{\prod_{j=0}^{i-1} S_{l(j)}}\right] \qquad \mbox{for all $i=0,\dots,n-1$}.
+ * s(x_{l(i)}) = \left\lfloor\frac{S \mbox { mod } \prod_{j=0}^{i} S_{l(j)}}{\prod_{j=0}^{i-1} S_{l(j)}}\right\rfloor \qquad \mbox{for all $i=0,\dots,n-1$}.
* \f}
* where \f$S\f$ denotes the value of \a linearState.
*
- * \note If *this corresponds with \f$\{x_l\}_{l\in L}\f$, calcStates(size_t) induces a mapping
- * \f$\sigma^{-1} : \{0,1,\dots,\prod_{l\in L} S_l-1\} \to \prod_{l\in L} X_l \to \f$ that
- * maps a linear index to a joint state; this is the inverse of the mapping \f$\sigma\f$
+ * \note If *this corresponds with \f$\{x_l\}_{l\in L}\f$, calcStates(size_t) induces a mapping
+ * \f$\sigma^{-1} : \{0,1,\dots,\prod_{l\in L} S_l-1\} \to \prod_{l\in L} X_l\f$ that
+ * maps a linear index to a joint state; this is the inverse of the mapping \f$\sigma\f$
* induced by calcState(const std::map<Var,size_t> &).
*/
std::map<Var, size_t> calcStates( size_t linearState ) {