Example #1
0
        private static ZDDNode MakeChildNode(ZDDNode node, State state, int child_num, PseudoZDD zdd)
        {
            Mate mate = node.GetCopyMate(state);

            int c = mate.CheckTerminalPre(state, child_num);

            if (c == 0)
            {
                return(PseudoZDD.ZeroTerminal);
            }
            else if (c == 1)
            {
                return(PseudoZDD.OneTerminal);
            }

            mate.Update(state, child_num);

            c = mate.CheckTerminalPost(state);
            if (c == 0)
            {
                return(PseudoZDD.ZeroTerminal);
            }
            else if (c == 1)
            {
                return(PseudoZDD.OneTerminal);
            }
            else
            {
                return(new ZDDNode(mate));
            }
        }
        private static ZDDNode MakeChildNode(ZDDNode node, State state, int child_num, PseudoZDD zdd)
        {
            Mate mate = node.GetCopyMate(state);

            int c = mate.CheckTerminalPre(state, child_num);
            if (c == 0)
            {
                return PseudoZDD.ZeroTerminal;
            }
            else if (c == 1)
            {
                return PseudoZDD.OneTerminal;
            }

            mate.Update(state, child_num);

            c = mate.CheckTerminalPost(state);
            if (c == 0)
            {
                return PseudoZDD.ZeroTerminal;
            }
            else if (c == 1)
            {
                return PseudoZDD.OneTerminal;
            }
            else
            {
                return new ZDDNode(mate);
            }
        }
Example #3
0
 public static ZDDNode MakeInitialNode(State state)
 {
     ZDDNode node = new ZDDNode(-1);
     node.mate_ = state.MakeInitialMate();
     node.SetNextId();
     return node;
 }
Example #4
0
        public static ZDDNode MakeInitialNode(State state)
        {
            ZDDNode node = new ZDDNode(-1);

            node.mate_ = state.MakeInitialMate();
            node.SetNextId();
            return(node);
        }
Example #5
0
 public void SetChild(ZDDNode node, int child_num)
 {
     if (child_num == 0)
     {
         zero_child_ = node;
     }
     else
     {
         one_child_ = node;
     }
 }
Example #6
0
 public void SetChild(ZDDNode node, int child_num)
 {
     if (child_num == 0)
     {
         zero_child_ = node;
     }
     else
     {
         one_child_ = node;
     }
 }
Example #7
0
 public ZDDNode FindNodeFromNextLevel(ZDDNode child_node, State state)
 {
     ZDDNode value;
     if (node_hash_set_.TryGetValue(child_node, out value))
     {
         return value;
     }
     else
     {
         return null;
     }
 }
Example #8
0
        public ZDDNode FindNodeFromNextLevel(ZDDNode child_node, State state)
        {
            ZDDNode value;

            if (node_hash_set_.TryGetValue(child_node, out value))
            {
                return(value);
            }
            else
            {
                return(null);
            }
        }
Example #9
0
        public long GetNumberOfSolutions()
        {
            PseudoZDD.ZeroTerminal.SetNumberOfSolutions(0);
            PseudoZDD.OneTerminal.SetNumberOfSolutions(1);

            for (int i = node_list_list_.Count - 1; i >= 0; --i)
            {
                for (int j = 0; j < node_list_list_[i].Count; ++j)
                {
                    ZDDNode lo_node = node_list_list_[i][j].GetChild(0);
                    ZDDNode hi_node = node_list_list_[i][j].GetChild(1);
                    node_list_list_[i][j].SetNumberOfSolutions(
                        lo_node.GetNumberOfSolutions() + hi_node.GetNumberOfSolutions());
                }
            }
            return(node_list_list_[0][0].GetNumberOfSolutions());
        }
Example #10
0
        public static PseudoZDD Construct(State state)
        {
            PseudoZDD zdd = new PseudoZDD();

            zdd.CreateRootNode(state);

            for (int edge = 1; edge <= state.GetNumberOfEdges(); ++edge)
            {
                state.Update();

                zdd.SetLevelStart();

                for (int i = 0; i < zdd.GetCurrentLevelSize(); ++i)
                {
                    ZDDNode node = zdd.GetCurrentLevelNode(i);

                    for (int child_num = 0; child_num < 2; ++child_num)
                    {
                        ZDDNode child_node = MakeChildNode(node, state, child_num, zdd);

                        if (child_node != PseudoZDD.ZeroTerminal && child_node != PseudoZDD.OneTerminal)
                        {
                            ZDDNode cand_node = zdd.FindNodeFromNextLevel(child_node, state);
                            if (cand_node != null)
                            {
                                child_node = cand_node;
                            }
                            else
                            {
                                child_node.SetNextId();
                                zdd.AddNodeToNextLevel(child_node, state);
                            }
                        }
                        zdd.SetChildNode(node, child_node, child_num);
                    }
                }
            }
            return(zdd);
        }
Example #11
0
 public void SetChildNode(ZDDNode node, ZDDNode child_node, int child_num)
 {
     node.SetChild(child_node, child_num);
 }
Example #12
0
 public void AddNodeToNextLevel(ZDDNode child_node, State state)
 {
     node_list_list_[current_level_ + 1].Add(child_node);
     node_hash_set_.Add(child_node, child_node);
 }
Example #13
0
 public void CreateRootNode(State state)
 {
     node_list_list_.Add(new List <ZDDNode>());
     node_list_list_[0].Add(ZDDNode.MakeInitialNode(state));
 }
Example #14
0
 public void SetChildNode(ZDDNode node, ZDDNode child_node, int child_num)
 {
     node.SetChild(child_node, child_num);
 }
Example #15
0
 public void AddNodeToNextLevel(ZDDNode child_node, State state)
 {
     node_list_list_[current_level_ + 1].Add(child_node);
     node_hash_set_.Add(child_node, child_node);
 }