Exemplo n.º 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();
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 3
0
 public void PrepareRunProcessNode(RunProcessNodeControl node, Experiment experiment)
 {
     experiment.Then(CreateExperimentNode(node));
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 5
0
 public void PrepareInitNode(InitNodeControl node, Experiment experiment)
 {
     experiment.StartFrom(node.InitPath);
 }
Exemplo n.º 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);
            }
        }