//------------------------------------------------------------------------------------------------ /// <summary> /// <para>Static method to generate the set of all subsets of the given discrete element.</para> /// <para>WARNING: DO NOT CALL THIS METHOD WITH AN ELEMENT TOO BIG (A HIGH NUMBER OF POSSIBLE /// STATES/WORLD) OR IT WILL HARM YOUR POOR COMPUTER.</para> /// </summary> /// <param name="e">The element to generate the set from.</param> /// <returns>Returns a new discrete set containing all the subsets of the given element.</returns> public static DiscreteSet GenerateSetOfSubsets(DiscreteElement e) { DiscreteSet toReturn = new DiscreteSet(); DiscreteElementEnumerator enumerator = new DiscreteElementEnumerator(e.Size); foreach (DiscreteElement el in enumerator) { if (el.IsASubset(e)) { toReturn.Add(el); } } return(toReturn); }
//------------------------------------------------------------------------------------------------ /// <summary> /// <para>Static method to generate a partial power set containing all the possible discrete elements /// of a given size (nbOfAtoms) with a specified maximal cardinal.</para> /// <para>WARNING: DO NOT CALL THIS METHOD WITH A NUMBER OF ATOMS TOO BIG OR IT WILL HARM YOUR POOR /// COMPUTER.</para> /// </summary> /// <param name="numberOfAtoms">The number of possible states/worlds defined in the frame /// of discernment.</param> /// <param name="maxCard">The maximal cardinal for the created elements.</param> /// <returns>Returns a new set </returns> public static DiscreteSet GeneratePartialPowerSet(int numberOfAtoms, int maxCard) { DiscreteSet s = new DiscreteSet(); DiscreteElementEnumerator enumerator = new DiscreteElementEnumerator(numberOfAtoms); foreach (DiscreteElement e in enumerator) { if (e.Card <= maxCard) { s.Add(e); } } return(s); }