コード例 #1
0
ファイル: Program.cs プロジェクト: AlexBaklaev/percolation
        static void Calc(string[] userinput, double averageLinkCount)
        {
            string      netType    = Properties.Settings.Default.NetType;
            INetCreator Netcreator = null;
            IProcessor  processor;

            var path = Directory.GetCurrentDirectory() + @"\Results\";

            Directory.CreateDirectory(path);
            CalculationTask calculationTask;

            #region Select CalculationTask

            ComaSepareteFileWriter writer = null;
            switch (userinput[0])
            {
            case "4":
            {
                calculationTask = new CalculationTask(0, Nodecount, netType, Minlink, Addtomaxlinkcount, MaxVirus, PofInfective, Granica, Segmentcont, Adressdiffstrategy, Virussendstrategy, Isappend, Isadresdiff,
                                                      Iterationcount, path, percentbackupchannel);
                processor = new TrueProcessor();
                break;
            }

            case "TrueReferenceProcessor":
            {
                calculationTask = new CalculationTask(0, Nodecount, netType, Minlink, (int)averageLinkCount, MaxVirus, PofInfective, Granica, Segmentcont, Adressdiffstrategy, Virussendstrategy, Isappend, Isadresdiff,
                                                      Iterationcount, path, percentbackupchannel);
                processor = new TrueReferenceProcessor();
                break;
            }

            case "ReferenceProcessor":
            {
                calculationTask = CalculationTaskCreator.CreateForReferencesCalculator(path, Iterationcount, netType);
                var weight = FileNetLoad.ReadWeight(userinput[3], Properties.Settings.Default.DefaultConnectionWeight);

                var st = userinput[3];
                for (int i = 4; i < userinput.Length; i++)
                {
                    weight = FileNetLoad.MultiplyWeight(weight, FileNetLoad.ReadWeight(userinput[i], Properties.Settings.Default.DefaultConnectionWeight));
                    st    += "-" + userinput[i];
                }
                processor = new ReferencesProcessor(weight);
                writer    = new ComaSepareteFileWriter(Path.Combine(path, st + "_" + Properties.Settings.Default.DefaultConnectionWeight));
                break;
            }

            default:
            {
                Console.WriteLine(@"Input is not correct");
                return;
            }
            }
            #endregion
            #region Select NetBuilder
            switch (userinput[1])
            {
            case "NetBuilder":
            {
                Netcreator = new NetBuilder(calculationTask);
                break;
            }

            case "HoleNetCreator":
            {
                Netcreator = new HoleNetCreator(new NetBuilder(calculationTask), averageLinkCount);
                break;
            }

            case "FileNetLoad":
            {
                Netcreator = new FileNetLoad(userinput[2]);
                break;
            }

            default:
            {
                Console.WriteLine(@"Input is not correct");
                return;
            }
            }
            #endregion

            if (writer == null)
            {
                writer =
                    new ComaSepareteFileWriter(Path.Combine(path, calculationTask.NetType + "_" + averageLinkCount.ToString("0.00")));
            }
            var d = new SimpleKernel(processor, calculationTask, Netcreator, writer, Experementcount);
        }
コード例 #2
0
 public TrueProcessorTest()
 {
     _target = new TrueProcessor();
 }