/// <summary> /// Returns an array of valid solutions to the given problem. Notice that the result is /// ordered based on when Fdd's are declared. An error will occur if the function cannot /// uphold the maxvalue passed into the function as the second parameter. /// </summary> /// <param name="root">The Bdd result</param> /// <param name="MaxValue">The function will uphold any max value passed via this function</param> /// <returns></returns> public static int[] AnySat(Bdd root, int MaxValue) { int[] result = new int[FddDictionary.Count]; string s = Kernel.CompactAnySat(root); //returns a big bitpattern "100110001110010101010101" if (s.Contains("Error") || "".CompareTo(s) == 0) { return(new int[0]); } int i = 0; foreach (KeyValuePair <int, int> entry in FddDictionary) { if (RestrictDictionary.ContainsKey(entry.Key)) { result[i] = RestrictDictionary[entry.Key]; } else { while (entry.Key + entry.Value > s.Length) //should be fixed in CompactAnySat. { s += "0"; } result[i] = ToValue(s.Substring(entry.Key, entry.Value)); } if (result[i] > MaxValue) { return(new int[0]); //no valid solution } i++; } return(result); }