示例#1
0
        static void Main(string[] args)
        {
            Core core = new Core();

            Experiment experiment = new Experiment();
            experiment.StartFrom("experiment/initial")
                .Then(core.Algorithm("RepresentationCheck").InitFromFolder("experiment/alg1/input/"))
                .Then(core.Algorithm("Statistics").InitFromFolder("experiment/alg2/input/"));

            Console.WriteLine("Starting experiment");
            experiment.Run();
            Console.WriteLine("Experiment finished");
            Console.ReadKey();
        }
示例#2
0
        public void PrepareAlgorithmNode(AlgorithmNodeControl node, Experiment experiment)
        {
            DataTable algParams = node.ParamsTable.Copy();

            foreach (DataRow row in algParams.Rows)
            {
                if (node.VarLoop.Keys.Contains(row["Name"].ToString()))
                    row["Value"] = node.VarLoop[row["Name"].ToString()].RunValue;
            }

            if (string.IsNullOrEmpty(node.InitPath))
            {
                experiment.Then(hydrologyCore.Algorithm(node.AlgorithmType.Name).SetParams(algParams));
            }
            else
            {
                if (Directory.Exists(node.InitPath))
                {
                    experiment.Then(hydrologyCore.Algorithm(node.AlgorithmType.Name).InitFromFolder(node.InitPath).SetParams(algParams));
                }
                else
                {
                    MessageBox.Show(string.Format("Путь {0}, указанный для алгоритма {1} не существует", node.InitPath, node.AlgorithmType.Name),
                        "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
        }
示例#3
0
 public void PrepareRunProcessNode(RunProcessNodeControl node, Experiment experiment)
 {
     experiment.Then(CreateExperimentNode(node));
 }
示例#4
0
        public void PrepareLoop(LoopControl loop, Experiment experiment, BackgroundWorker worker, DoWorkEventArgs e, double p)
        {
            var chain = loop.LoopBody.CreateExecutionChain();

            double percentInc = 100.0 * p / chain.Count;
            percent += percentInc / 2;
            worker.ReportProgress((int)percent);

            for (loop.ResetValue(); loop.IsLoop(); loop.StepValue())
            {
                for (int i = 0; i < chain.Count; i++)
                {
                    if (chain[i] is InitNodeControl)
                        PrepareInitNode(chain[i] as InitNodeControl, experiment);
                    else if (chain[i] is AlgorithmNodeControl)
                        PrepareAlgorithmNode(chain[i] as AlgorithmNodeControl, experiment);
                    else if (chain[i] is RunProcessNodeControl)
                        PrepareRunProcessNode(chain[i] as RunProcessNodeControl, experiment);
                    else if (chain[i] is LoopControl)
                        PrepareLoop(chain[i] as LoopControl, experiment, worker, e, percentInc);

                    if (worker.CancellationPending == true)
                    {
                        e.Cancel = true;
                        return;
                    }
                    percent += percentInc;
                    worker.ReportProgress((int)percent);
                }

                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    return;
                }
                percent += percentInc;
                worker.ReportProgress((int)percent);
            }
        }
示例#5
0
 public void PrepareInitNode(InitNodeControl node, Experiment experiment)
 {
     experiment.StartFrom(node.InitPath);
 }
示例#6
0
        public void PrepareExperiment(BackgroundWorker worker, DoWorkEventArgs e)
        {
            experiment = new Experiment();

            var chain = experimentGraph.CreateExecutionChain();

            double percentInc = 100.0 / chain.Count;
            percent += percentInc / 2;
            worker.ReportProgress((int)percent);

            for (int i = 0; i < chain.Count; i++)
            {
                if (chain[i] is InitNodeControl)
                    PrepareInitNode(chain[i] as InitNodeControl, experiment);
                else
                    experiment.Then(CreateExperimentNode(chain[i]));

                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    return;
                }
                percent += percentInc;
                worker.ReportProgress((int)percent);
            }
        }