Exemplo n.º 1
0
        public void Test_ReadWrite()
        {
            IChanceAbstraction[] chanceAbstractions = new IChanceAbstraction[]
            {
                new LeducHeChanceAbstraction(LeducHeChanceAbstraction.FractionalResult),
                new LeducHeChanceAbstraction(LeducHeChanceAbstraction.FractionalResult)
            };

            CtMcGen.Tree tree1 = CtMcGen.Generate(_leducHeGd, chanceAbstractions, false, 10000, (int)DateTime.Now.Ticks, null);
            ChanceTree   ct1   = tree1.ConvertToChanceTree();

            string fileName = Path.Combine(_outDir, "ctmcgen-tree.dat");

            tree1.Write(fileName);
            CtMcGen.Tree tree2 = new CtMcGen.Tree();
            tree2.Read(fileName);

            // Compare public data
            Assert.AreEqual(tree1.CalculateLeavesCount(), tree2.CalculateLeavesCount());
            Assert.AreEqual(tree1.SamplesCount, tree2.SamplesCount);
            Assert.AreEqual(tree1.Version, tree2.Version);

            ChanceTree ct2 = tree2.ConvertToChanceTree();

            // Compare two chance trees, they must be exactly the same.
            CompareChanceTrees cmp = new CompareChanceTrees();

            cmp.Compare(ct1, ct2);
            Assert.AreEqual(0, cmp.SumProbabDiff);
            for (int p = 0; p < chanceAbstractions.Length; ++p)
            {
                Assert.AreEqual(0, cmp.SumPotShareDiff[p]);
            }
        }
Exemplo n.º 2
0
        static int Main(string[] args)
        {
            if (!Parser.ParseArgumentsWithUsage(args, _cmdLine))
            {
                return(1);
            }

            if (_cmdLine.DebuggerLaunch)
            {
                Debugger.Launch();
            }

            CtMcGen.Tree input = new CtMcGen.Tree();
            input.Read(_cmdLine.Input);
            long leavesCount = input.CalculateLeavesCount();

            Console.WriteLine("Input file: leaves: {0:#,#}, samples: {1:#,#}, av. samples: {2:#,#}",
                              leavesCount, input.SamplesCount, input.SamplesCount / (ulong)leavesCount);

            ChanceTree ct = input.ConvertToChanceTree();

            ct.Write(_cmdLine.Output);

            return(0);
        }
Exemplo n.º 3
0
        static int Main(string[] args)
        {
            if (!Parser.ParseArgumentsWithUsage(args, _cmdLine))
            {
                return(1);
            }

            if (_cmdLine.DebuggerLaunch)
            {
                Debugger.Launch();
            }

            _reIncludeFiles = new Regex(_cmdLine.IncludeFiles, RegexOptions.Compiled);

            if (string.IsNullOrEmpty(_cmdLine.Output))
            {
                Console.WriteLine("Output file name is missing");
                return(1);
            }
            _targetTree = new CtMcGen.Tree();
            if (File.Exists(_cmdLine.Output))
            {
                _targetTree.Read(_cmdLine.Output);
            }


            DateTime startTime = DateTime.Now;

            foreach (string path in _cmdLine.InputPaths)
            {
                ProcessPath(path);
            }

            double time = (DateTime.Now - startTime).TotalSeconds;

            _targetTree.Write(_cmdLine.Output);


            Console.WriteLine("TOTAL: samples: {0:#,#}, time: {1:0.0} s, {2:#,#} sm/s",
                              _targetTree.SamplesCount, time, _targetTree.SamplesCount / time);

            long leavesCount = _targetTree.CalculateLeavesCount();

            Console.WriteLine("Target file: leaves: {0:#,#}, samples: {1:#,#}, av. samples: {2:#,#}, path: {3}",
                              leavesCount, _targetTree.SamplesCount,
                              _targetTree.SamplesCount / (ulong)leavesCount,
                              _cmdLine.Output);

            return(0);
        }