Esempio n. 1
0
        /// <summary>
        /// Crteate a Boolean decision tree.
        /// References to solver and domain are not saved in the resulting decision tree.
        /// </summary>
        /// <param name="solver">character alberbra</param>
        /// <param name="domain">elements that map to true</param>
        /// <param name="precomputeLimit">upper limit for block ids for characters to be precomputed in an array (default is 0xFF, i.e. extended ASCII)</param>
        /// <returns></returns>
        internal static BooleanDecisionTree Create(CharSetSolver solver, BDD domain, ushort precomputeLimit = 0xFF)
        {
            BDD domain_compl = solver.MkNot(domain);
            var partition    = new BDD[] { domain_compl, domain };

            if (precomputeLimit == 0)
            {
                return(new BooleanDecisionTree(new bool[] { }, MkBST(new DecisionTree.PartitionCut(solver, partition), 0, 0xFFFF)));
            }

            bool[]           precomp = Precompute(solver, domain, precomputeLimit);
            DecisionTree.BST bst     = null;
            if (precomputeLimit < ushort.MaxValue)
            {
                bst = MkBST(new DecisionTree.PartitionCut(solver, partition), precomputeLimit + 1, ushort.MaxValue);
            }

            return(new BooleanDecisionTree(precomp, bst));
        }
Esempio n. 2
0
 internal BooleanDecisionTree(bool[] precomputed, DecisionTree.BST bst)
 {
     this.precomputed = precomputed;
     this.bst         = bst;
 }
Esempio n. 3
0
 /// <summary>
 /// Deserialize
 /// </summary>
 public BooleanDecisionTree(SerializationInfo info, StreamingContext context)
 {
     precomputed = DeserializePrecomputed(info.GetString("p"));
     this.bst    = DecisionTree.BST.Deserialize(info.GetString("b"));
 }