public void Reevaluate(RunCollection runcollection, string filePath, double timeout)
        {
            string fileName = Path.GetFileName(filePath);

            foreach (var run in runcollection)
            {
                var model = run.Results[BESTTRAININGSOLUTION + ".Model"] as ISymbolicExpressionTree;
                foreach (var name in run.Results.Select(x => x.Key).Where(x => x.StartsWith(BESTTRAININGSOLUTION + ".") || x.Equals(BESTTRAININGSOLUTION)).ToList())
                {
                    run.Results.Remove(name);
                }

                var problemData   = run.Parameters["CFGProblemData"] as CFGPythonProblemData;
                var pythonProcess = run.Parameters["PythonProcess"] as PythonProcess;
                pythonProcess.DegreeOfParallelism = 1;
                if (problemData != null && pythonProcess != null)
                {
                    var solution = new CFGPythonSolution(model, problemData, timeout, pythonProcess);
                    run.Results.Add(BESTTRAININGSOLUTION, solution as ResultCollection);
                    foreach (var item in solution)
                    {
                        run.Results.Add(String.Format("{0}.{1}", BESTTRAININGSOLUTION, item.Name), item.Value);
                    }
                    pythonProcess.Dispose();
                }
                else
                {
                    Helper.printToConsole("Warning: Could not reevaluate solution.", fileName);
                }
            }
            Helper.printToConsole("Saving...", fileName);
            ContentManager.Save(runcollection, filePath, true);
            Helper.printToConsole("Saved", fileName);
        }
Example #2
0
        private static DataTable CalcAverage(RunCollection runs, string tableName)
        {
            DataTable temptable = new DataTable();

            var visibleRuns = runs.Where(r => r.Visible);

            var resultName = (string)tableName;

            var dataTables = visibleRuns.Where(r => r.Results.ContainsKey(resultName)).Select(r => (DataTable)r.Results[resultName]);

            if (dataTables.Count() != visibleRuns.Count())
            {
                throw new ArgumentException("Should not happen");
            }

            var dataRows = dataTables.SelectMany(dt => dt.Rows).GroupBy(r => r.Name, r => r);

            foreach (var row in dataRows)
            {
                var     averageValues = DataRowsAggregate(Enumerable.Average, row.Select(r => r.Values));
                DataRow averageRow    = new DataRow(row.Key, "Average of Values", averageValues);
                temptable.Rows.Add(averageRow);
            }
            return(temptable);
        }
Example #3
0
 private void itemsListView_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly)
         {
             if (RunCollection != null)
             {
                 RunCollection.RemoveRange(itemsListView.SelectedItems.Cast <ListViewItem>().Select(i => (IRun)i.Tag));
             }
             else
             {
                 foreach (ListViewItem item in itemsListView.SelectedItems)
                 {
                     Content.Remove((IRun)item.Tag);
                 }
             }
         }
     }
     else if (e.KeyData == (Keys.A | Keys.Control))
     {
         try {
             itemsListView.BeginUpdate();
             foreach (ListViewItem item in itemsListView.Items)
             {
                 item.Selected = true;
             }
         } finally { itemsListView.EndUpdate(); }
     }
 }
        private RunCollection GetAllRunsFromJob(RefreshableJob job)
        {
            if (job != null)
            {
                RunCollection runs = new RunCollection()
                {
                    OptimizerName = job.ItemName
                };

                foreach (HiveTask subTask in job.HiveTasks)
                {
                    if (subTask is OptimizerHiveTask)
                    {
                        OptimizerHiveTask ohTask = subTask as OptimizerHiveTask;
                        ohTask.ExecuteReadActionOnItemTask(new Action(delegate() {
                            runs.AddRange(ohTask.ItemTask.Item.Runs);
                        }));
                    }
                }
                return(runs);
            }
            else
            {
                return(null);
            }
        }
    public void Reevaluate(RunCollection runcollection, string filePath, double timeout) {
      string fileName = Path.GetFileName(filePath);

      foreach (var run in runcollection) {
        var model = run.Results[BESTTRAININGSOLUTION + ".Model"] as ISymbolicExpressionTree;
        foreach (var name in run.Results.Select(x => x.Key).Where(x => x.StartsWith(BESTTRAININGSOLUTION + ".") || x.Equals(BESTTRAININGSOLUTION)).ToList()) {
          run.Results.Remove(name);
        }

        var problemData = run.Parameters["CFGProblemData"] as CFGPythonProblemData;
        var pythonProcess = run.Parameters["PythonProcess"] as PythonProcess;
        pythonProcess.DegreeOfParallelism = 1;
        if (problemData != null && pythonProcess != null) {
          var solution = new CFGPythonSolution(model, problemData, timeout, pythonProcess);
          run.Results.Add(BESTTRAININGSOLUTION, solution as ResultCollection);
          foreach (var item in solution) {
            run.Results.Add(String.Format("{0}.{1}", BESTTRAININGSOLUTION, item.Name), item.Value);
          }
          pythonProcess.Dispose();
        } else {
          Helper.printToConsole("Warning: Could not reevaluate solution.", fileName);
        }
      }
      Helper.printToConsole("Saving...", fileName);
      ContentManager.Save(runcollection, filePath, true);
      Helper.printToConsole("Saved", fileName);
    }
Example #6
0
 public void AddRuns(IItem item)
 {
     if (InvokeRequired)
     {
         Invoke((Action <IItem>)AddRuns, item); return;
     }
     if (item is Experiment)
     {
         runs.AddRange((item as Experiment).Runs);
         DisplayRuns((item as Experiment).Runs);
     }
     else if (item is RunCollection)
     {
         runs.AddRange((item as RunCollection));
         DisplayRuns((item as RunCollection));
     }
     else if (item is IOptimizer)
     {
         runs.AddRange((item as IOptimizer).Runs);
         DisplayRuns((item as IOptimizer).Runs);
     }
     else if (item is IRun)
     {
         runs.Add(item as IRun);
         RunCollection tmp = new RunCollection();
         tmp.Add(item as IRun);
         DisplayRuns(tmp);
     }
     SetEnabledStateOfControls();
 }
Example #7
0
 private void itemsListView_DragDrop(object sender, DragEventArgs e)
 {
     if (e.Effect != DragDropEffects.None)
     {
         if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun)
         {
             IRun item = (IRun)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
             Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (IRun)item.Clone() : item);
         }
         else if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)
         {
             IEnumerable <IRun> items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast <IRun>();
             if (e.Effect.HasFlag(DragDropEffects.Copy))
             {
                 Cloner cloner = new Cloner();
                 items = items.Select(x => cloner.Clone(x));
             }
             if (RunCollection != null)
             {
                 RunCollection.AddRange(items);
             }
             else // the content is an IItemCollection<IRun>
             {
                 foreach (IRun item in items)
                 {
                     Content.Add(item);
                 }
             }
         }
     }
 }
        protected override void OnActiveViewChanged(object sender, EventArgs e)
        {
            IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;

            if (activeView == null)
            {
                ToolStripItem.Enabled = false;
                return;
            }

            var           content       = activeView.Content;
            RunCollection runCollection = content as RunCollection;

            if (runCollection == null && content is IOptimizer)
            {
                runCollection = ((IOptimizer)content).Runs;
            }

            if (runCollection == null)
            {
                ToolStripItem.Enabled = false;
                return;
            }

            ToolStripItem.Enabled = runCollection.Any(run => run.Parameters.Any(p => p.Value is IDataAnalysisProblemData));
        }
Example #9
0
        private ManualResetEventSlim allAlgorithmsFinished; // this indicates that all started algorithms have been paused or stopped

        public CrossValidation()
            : base()
        {
            name        = ItemName;
            description = ItemDescription;

            executionState = ExecutionState.Stopped;
            runs           = new RunCollection {
                OptimizerName = name
            };
            runsCounter = 0;

            algorithm        = null;
            clonedAlgorithms = new ItemCollection <IAlgorithm>();
            results          = new ResultCollection();

            folds                   = new IntValue(2);
            numberOfWorkers         = new IntValue(1);
            samplesStart            = new IntValue(0);
            samplesEnd              = new IntValue(0);
            shuffleSamples          = new BoolValue(false);
            storeAlgorithmInEachRun = false;

            RegisterEvents();
            if (Algorithm != null)
            {
                RegisterAlgorithmEvents();
            }
        }
    /// <summary>
    /// </summary>
    /// <param name="filePath"></param>
    /// <returns>0 == everything ok; 1 == seed problem; 2 == probably timeout</returns>
    private int Check(RunCollection coll, string filePath) {
      string fileName = Path.GetFileName(filePath);


      List<int> seeds = Enumerable.Range(1, 100).ToList();

      int count = 0;
      foreach (var run in coll) {
        if (!seeds.Remove(((IntValue)run.Parameters["Seed"]).Value)) {
          Helper.printToConsole("Seed problem", fileName);
          return 1;
        }
        double test = ((DoubleValue)run.Results["Best training solution.Test Quality"]).Value;
        if (double.IsNaN(test)) {
          Helper.printToConsole("Probably timeout", fileName);
          return 2;
        } else if (test < 0.000000001) {
          count++;
        }
      }

      if (seeds.Count > 0) {
        Helper.printToConsole("Too few runs", fileName);
        return 1;
      }

      Helper.printToConsole(string.Format("Successful: {0} of {1}", count, coll.Count), fileName);

      return 0;
    }
 public OKBAlgorithm()
     : base()
 {
     algorithmId = -1;
     algorithm   = new EmptyAlgorithm("No algorithm selected. Please choose an algorithm from the OKB.");
     RegisterAlgorithmEvents();
     runs = new RunCollection();
     storeRunsAutomatically = true;
     RegisterRunsEvents();
 }
Example #12
0
 private void OnRunAdded(ProjectInfo pi, RunCollection runs, Run run, int nIndex)
 {
     foreach (TreeNode tn in _tvProjects.Nodes)
     {
         if (tn.Tag == pi)
         {
             AddRunNode(tn, run);
         }
     }
 }
        private void UpdateBubbleChart()
        {
            if (Content == null)
            {
                return;
            }
            var selectedXAxis = bubbleChartView.SelectedXAxis;
            var selectedYAxis = bubbleChartView.SelectedYAxis;

            var problemData = Content.ProblemData;
            var ds          = problemData.Dataset;
            var runs        = new RunCollection();
            // determine relevant variables (at least two different values)
            var doubleVars   = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Distinct().Skip(1).Any()).ToArray();
            var stringVars   = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray();
            var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray();

            // produce training and test values separately as they might overlap (e.g. for ensembles)
            var predictedValuesTrain = Content.EstimatedTrainingValues.ToArray();
            int j = 0; // idx for predictedValues array

            foreach (var i in problemData.TrainingIndices)
            {
                var run         = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
                var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
                AddErrors(run, predictedValuesTrain[j++], targetValue);
                run.Results.Add(PartitionLabel, new StringValue("Training"));
                run.Color = Color.Gold;
                runs.Add(run);
            }
            var predictedValuesTest = Content.EstimatedTestValues.ToArray();

            j = 0;
            foreach (var i in problemData.TestIndices)
            {
                var run         = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
                var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
                AddErrors(run, predictedValuesTest[j++], targetValue);
                run.Results.Add(PartitionLabel, new StringValue("Test"));
                run.Color = Color.Red;
                runs.Add(run);
            }
            if (string.IsNullOrEmpty(selectedXAxis))
            {
                selectedXAxis = "Index";
            }
            if (string.IsNullOrEmpty(selectedYAxis))
            {
                selectedYAxis = "Residual";
            }

            bubbleChartView.Content       = runs;
            bubbleChartView.SelectedXAxis = selectedXAxis;
            bubbleChartView.SelectedYAxis = selectedYAxis;
        }
Example #14
0
        private void Collect(string filePath)
        {
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            string[] lines = File.ReadAllLines(filePath);
            int      pos   = lines.Length - 1;

            while (!lines[pos].Contains(LOADINGCOMPLETE) && pos >= 0)
            {
                pos--;
            }

            if (pos < 0)
            {
                Console.WriteLine("Could not find a successfully loaded file.");
                return;
            }

            pos++;
            var namePos = lines[pos].IndexOf(CONTENTLOADED) + CONTENTLOADED.Length;
            var name    = lines[pos].Substring(namePos, lines[pos].Length - namePos);

            pos++;
            int           pathPos  = -1;
            List <string> tmpPaths = new List <string>();

            while (pos < lines.Length && (pathPos = lines[pos].IndexOf(SAVEPATH)) >= 0)
            {
                pathPos += SAVEPATH.Length;
                tmpPaths.Add(lines[pos].Substring(pathPos, lines[pos].Length - pathPos));
                pos++;
            }

            Helper.printToConsole("Saving...", fileName);
            RunCollection collectedRuns = new RunCollection();

            foreach (var path in tmpPaths.Where(x => File.Exists(x) && new FileInfo(x).Length > 0))
            {
                try {
                    var runCollection = ContentManager.Load(path) as RunCollection;
                    if (runCollection != null)
                    {
                        collectedRuns.AddRange(runCollection);
                    }
                    else
                    {
                        Helper.printToConsole(String.Format("WARNING: {0} is not a run collection.", path), fileName);
                    }
                } catch (Exception e) {
                    Helper.printToConsole("Exception while collecting: " + e.Message, fileName);
                }
            }

            ContentManager.Save(collectedRuns, name + "-Results.hl", true);
        }
 private OKBAlgorithm(OKBAlgorithm original, Cloner cloner)
     : base(original, cloner)
 {
     algorithmId = original.algorithmId;
     algorithm   = cloner.Clone(original.algorithm);
     RegisterAlgorithmEvents();
     runs = cloner.Clone(original.runs);
     storeRunsAutomatically = original.storeRunsAutomatically;
     UserId = original.UserId;
     RegisterRunsEvents();
 }
        private void EvaluateModifications()
        {
            if (RunCollection == null)
            {
                return;
            }
            ReadOnly = true;

            try {
                RunCollection.UpdateOfRunsInProgress = true;
                RunCollection.Modify();
            } finally {
                ReadOnly = false;
                RunCollection.UpdateOfRunsInProgress = false;
            }
        }
Example #17
0
        private void DisplayRuns(RunCollection runs)
        {
            if (RunCreationClient.Instance.Algorithms == null || RunCreationClient.Instance.Algorithms.Count() == 0)
            {
                Action a = new Action(delegate {
                    RunCreationClient.Instance.Refresh();
                    CreateUI(runs);
                });

                Task.Factory.StartNew(a).ContinueWith((t) => { DisplayError(t.Exception); }, TaskContinuationOptions.OnlyOnFaulted);
            }
            else
            {
                CreateUI(runs);
            }
        }
Example #18
0
        public void Start(Options options)
        {
            var reeval = new ReevaluateCFGPythonSolutionsInResultCollection();

            foreach (var filePath in options.InputFiles)
            {
                RunCollection coll = Helper.LoadRunCollection(filePath);
                if (Check(coll, filePath) == 2)
                {
                    reeval.Reevaluate(coll, filePath, options.Timeout);
                    Helper.printToConsole("Check again", Path.GetFileName(filePath));
                    coll = Helper.LoadRunCollection(filePath);
                    Check(coll, filePath);
                }
            }
        }
Example #19
0
        public void CheckDMLTextEffect()
        {
            //ExStart:CheckDMLTextEffect
            Document doc = new Document(MyDir + "DrawingML text effects.docx");

            RunCollection runs    = doc.FirstSection.Body.FirstParagraph.Runs;
            Font          runFont = runs[0].Font;

            // One run might have several Dml text effects applied.
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Shadow));
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Effect3D));
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Reflection));
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Outline));
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Fill));
            //ExEnd:CheckDMLTextEffect
        }
Example #20
0
        public void InlineRevisions()
        {
            //ExStart
            //ExFor:Inline
            //ExFor:Inline.IsDeleteRevision
            //ExFor:Inline.IsFormatRevision
            //ExFor:Inline.IsInsertRevision
            //ExFor:Inline.IsMoveFromRevision
            //ExFor:Inline.IsMoveToRevision
            //ExFor:Inline.ParentParagraph
            //ExFor:Paragraph.Runs
            //ExFor:Revision.ParentNode
            //ExFor:RunCollection
            //ExFor:RunCollection.Item(Int32)
            //ExFor:RunCollection.ToArray
            //ExSummary:Shows how to process revision-related properties of Inline nodes.
            Document doc = new Document(MyDir + "Inline.Revisions.docx");

            // This document has 6 revisions
            Assert.AreEqual(6, doc.Revisions.Count);

            // The parent node of a revision is the run that the revision concerns, which is an Inline node
            Run run = (Run)doc.Revisions[0].ParentNode;

            // Get the parent paragraph
            Paragraph     firstParagraph = run.ParentParagraph;
            RunCollection runs           = firstParagraph.Runs;

            Assert.AreEqual(6, runs.ToArray().Length);

            // The text in the run at index #2 was typed after revisions were tracked, so it will count as an insert revision
            // The font was changed, so it will also be a format revision
            Assert.IsTrue(runs[2].IsInsertRevision);
            Assert.IsTrue(runs[2].IsFormatRevision);

            // If one node was moved from one place to another while changes were tracked,
            // the node will be placed at the departure location as a "move to revision",
            // and a "move from revision" node will be left behind at the origin, in case we want to reject changes
            // Highlighting text and dragging it to another place with the mouse and cut-and-pasting (but not copy-pasting) both count as "move revisions"
            // The node with the "IsMoveToRevision" flag is the arrival of the move operation, and the node with the "IsMoveFromRevision" flag is the departure point
            Assert.IsTrue(runs[1].IsMoveToRevision);
            Assert.IsTrue(runs[4].IsMoveFromRevision);

            // If an Inline node gets deleted while changes are being tracked, it will leave behind a node with the IsDeleteRevision flag set to true until changes are accepted
            Assert.IsTrue(runs[5].IsDeleteRevision);
            //ExEnd
        }
    private static void ManipulatorCalc(RunCollection runs, string filename) {
      DataTable parent = CalcAverage(runs, "Manipulator Actual CutPoint Parent");

      DataTable removedLength = CalcAverage(runs, "ManipulatorActualRemovedMaterialLength");
      DataTable removedDepth = CalcAverage(runs, "ManipulatorActualRemovedMaterialDepth");
      DataTable addedLength = CalcAverage(runs, "ManipulatorActualAddedMaterialLength");
      DataTable addedDepth = CalcAverage(runs, "ManipulatorActualAddedMaterialDepth");

      var cummulativeAverageRemovedLength = CalcCummulativeAverage(parent, removedLength);
      var cummulativeAverageRemovedDepth = CalcCummulativeAverage(parent, removedDepth);
      var cummulativeAverageAddedLength = CalcCummulativeAverage(parent, addedLength);
      var cummulativeAverageAddedDepth = CalcCummulativeAverage(parent, addedDepth);

      WriteToCSV(new List<IEnumerable<double>>() { cummulativeAverageRemovedLength, cummulativeAverageRemovedDepth, cummulativeAverageAddedLength, cummulativeAverageAddedDepth },
        new List<string>() { "RemovedLenghtXO", "RemovedDepthXO", "AddedLenghtXO", "AddedDepthXO" }, filename + "_(MO).csv");

    }
Example #22
0
 private void removeButton_Click(object sender, EventArgs e)
 {
     if (itemsListView.SelectedItems.Count > 0)
     {
         if (RunCollection != null)
         {
             RunCollection.RemoveRange(itemsListView.SelectedItems.Cast <ListViewItem>().Select(i => (IRun)i.Tag));
         }
         else
         {
             foreach (ListViewItem item in itemsListView.SelectedItems)
             {
                 Content.Remove((IRun)item.Tag);
             }
         }
         itemsListView.SelectedItems.Clear();
     }
 }
    private void Collect(string filePath) {
      string fileName = Path.GetFileNameWithoutExtension(filePath);
      string[] lines = File.ReadAllLines(filePath);
      int pos = lines.Length - 1;
      while (!lines[pos].Contains(LOADINGCOMPLETE) && pos >= 0) {
        pos--;
      }

      if (pos < 0) {
        Console.WriteLine("Could not find a successfully loaded file.");
        return;
      }

      pos++;
      var namePos = lines[pos].IndexOf(CONTENTLOADED) + CONTENTLOADED.Length;
      var name = lines[pos].Substring(namePos, lines[pos].Length - namePos);

      pos++;
      int pathPos = -1;
      List<string> tmpPaths = new List<string>();
      while (pos < lines.Length && (pathPos = lines[pos].IndexOf(SAVEPATH)) >= 0) {
        pathPos += SAVEPATH.Length;
        tmpPaths.Add(lines[pos].Substring(pathPos, lines[pos].Length - pathPos));
        pos++;
      }

      Helper.printToConsole("Saving...", fileName);
      RunCollection collectedRuns = new RunCollection();
      foreach (var path in tmpPaths.Where(x => File.Exists(x) && new FileInfo(x).Length > 0)) {
        try {
          var runCollection = ContentManager.Load(path) as RunCollection;
          if (runCollection != null) {
            collectedRuns.AddRange(runCollection);
          } else {
            Helper.printToConsole(String.Format("WARNING: {0} is not a run collection.", path), fileName);
          }
        } catch (Exception e) {
          Helper.printToConsole("Exception while collecting: " + e.Message, fileName);
        }
      }

      ContentManager.Save(collectedRuns, name + "-Results.hl", true);
    }
 public BenchmarkAlgorithm()
 {
     name                    = ItemName;
     description             = ItemDescription;
     parameters              = new ParameterCollection();
     readOnlyParameters      = null;
     executionState          = ExecutionState.Stopped;
     executionTime           = TimeSpan.Zero;
     storeAlgorithmInEachRun = false;
     runsCounter             = 0;
     Runs                    = new RunCollection()
     {
         OptimizerName = name
     };
     results = new ResultCollection();
     CreateParameters();
     DiscoverBenchmarks();
     Prepare();
 }
        /// <summary>
        /// Parses the run numbers out of runs and renames the run to the next number
        /// </summary>
        private static string GetNewRunName(IRun run, RunCollection runs)
        {
            int idx = run.Name.IndexOf("Run ") + 4;

            if (idx == 3 || runs.Count == 0)
            {
                return(run.Name);
            }

            int maxRunNumber = int.MinValue;

            foreach (IRun r in runs)
            {
                int number = GetRunNumber(r.Name);
                maxRunNumber = Math.Max(maxRunNumber, number);
            }

            return(run.Name.Substring(0, idx) + (maxRunNumber + 1).ToString());
        }
        public static void Run()
        {
            // ExStart:CheckDMLTextEffect
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithDocument();

            // Initialize document.
            Document      doc  = new Document(dataDir + "Document.doc");
            RunCollection runs = doc.FirstSection.Body.FirstParagraph.Runs;

            Font runFont = runs[0].Font;

            // One run might have several Dml text effects applied.
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Shadow));
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Effect3D));
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Reflection));
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Outline));
            Console.WriteLine(runFont.HasDmlEffect(TextDmlEffect.Fill));
            // ExEnd:CheckDMLTextEffect
        }
 private void itemsListView_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly)
         {
             if (RunCollection != null)
             {
                 RunCollection.RemoveRange(itemsListView.SelectedItems.Cast <ListViewItem>().Select(i => (IRun)i.Tag));
             }
             else
             {
                 foreach (ListViewItem item in itemsListView.SelectedItems)
                 {
                     Content.Remove((IRun)item.Tag);
                 }
             }
         }
     }
 }
Example #28
0
        private void guidComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string value     = e.AddedItems[0] as string;
            int    selection = 0;

            for (int i = 0; i < runNames.Count; i++)
            {
                if (value == runNames[i])
                {
                    selection = i;
                }
            }
            RunCollection rc = runCollections[selection];

            selectedRC = rc;
            runs       = selectedRC.Runs;

            runComboBox.ItemsSource       = runs;
            runComboBox.DisplayMemberPath = "RunName";
            runComboBox.SelectedIndex     = 0;
        }
        private void SaveRuns(List <HLRunInfo> tasks, string filePath, string fileName)
        {
            Helper.printToConsole("Saving...", fileName);
            RunCollection allRuns;
            string        saveFile = Path.GetFileNameWithoutExtension(filePath) + "-Results.hl";

            if (File.Exists(saveFile))
            {
                allRuns = Load <RunCollection>(saveFile);
                if (allRuns == null)
                {
                    Console.WriteLine(String.Format("{0} exists but it does not contain a RunCollection. File will be overwritten.", saveFile));
                }
            }
            else
            {
                allRuns = new RunCollection();
            }

            foreach (var task in tasks)
            {
                if (!File.Exists(task.SavePath))
                {
                    Helper.printToConsole(String.Format("WARNING: {0} does not exist. {0} has probably not been saved.", task.SavePath), fileName);
                    continue;
                }
                var runCollection = ContentManager.Load(task.SavePath) as RunCollection;
                if (runCollection != null)
                {
                    allRuns.AddRange(runCollection);
                }
                else
                {
                    Helper.printToConsole(String.Format("WARNING: {0} is not a run collection.", task.SavePath), fileName);
                }
            }

            ContentManager.Save(allRuns, Path.Combine(Path.GetDirectoryName(filePath), saveFile), true);
            Helper.printToConsole(FINISHEDSAVING, fileName);
        }
Example #30
0
        /// <summary>
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns>0 == everything ok; 1 == seed problem; 2 == probably timeout</returns>
        private int Check(RunCollection coll, string filePath)
        {
            string fileName = Path.GetFileName(filePath);


            List <int> seeds = Enumerable.Range(1, 100).ToList();

            int count = 0;

            foreach (var run in coll)
            {
                if (!seeds.Remove(((IntValue)run.Parameters["Seed"]).Value))
                {
                    Helper.printToConsole("Seed problem", fileName);
                    return(1);
                }
                double test = ((DoubleValue)run.Results["Best training solution.Test Quality"]).Value;
                if (double.IsNaN(test))
                {
                    Helper.printToConsole("Probably timeout", fileName);
                    return(2);
                }
                else if (test < 0.000000001)
                {
                    count++;
                }
            }

            if (seeds.Count > 0)
            {
                Helper.printToConsole("Too few runs", fileName);
                return(1);
            }

            Helper.printToConsole(string.Format("Successful: {0} of {1}", count, coll.Count), fileName);

            return(0);
        }
Example #31
0
        public void NodeCollection()
        {
            //ExStart
            //ExFor:NodeCollection.Contains(Node)
            //ExFor:NodeCollection.Insert(Int32,Node)
            //ExFor:NodeCollection.Remove(Node)
            //ExSummary:Shows how to work with a NodeCollection.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Add text to the document by inserting Runs using a DocumentBuilder.
            builder.Write("Run 1. ");
            builder.Write("Run 2. ");

            // Every invocation of the "Write" method creates a new Run,
            // which then appears in the parent Paragraph's RunCollection.
            RunCollection runs = doc.FirstSection.Body.FirstParagraph.Runs;

            Assert.AreEqual(2, runs.Count);

            // We can also insert a node into the RunCollection manually.
            Run newRun = new Run(doc, "Run 3. ");

            runs.Insert(3, newRun);

            Assert.True(runs.Contains(newRun));
            Assert.AreEqual("Run 1. Run 2. Run 3.", doc.GetText().Trim());

            // Access individual runs and remove them to remove their text from the document.
            Run run = runs[1];

            runs.Remove(run);

            Assert.AreEqual("Run 1. Run 3.", doc.GetText().Trim());
            Assert.NotNull(run);
            Assert.False(runs.Contains(run));
            //ExEnd
        }
Example #32
0
        private static void ManipulatorCalc(RunCollection runs, string filename)
        {
            DataTable parent = CalcAverage(runs, "Manipulator Actual CutPoint Parent");

            DataTable removedLength = CalcAverage(runs, "ManipulatorActualRemovedMaterialLength");
            DataTable removedDepth  = CalcAverage(runs, "ManipulatorActualRemovedMaterialDepth");
            DataTable addedLength   = CalcAverage(runs, "ManipulatorActualAddedMaterialLength");
            DataTable addedDepth    = CalcAverage(runs, "ManipulatorActualAddedMaterialDepth");

            var cummulativeAverageRemovedLength = CalcCummulativeAverage(parent, removedLength);
            var cummulativeAverageRemovedDepth  = CalcCummulativeAverage(parent, removedDepth);
            var cummulativeAverageAddedLength   = CalcCummulativeAverage(parent, addedLength);
            var cummulativeAverageAddedDepth    = CalcCummulativeAverage(parent, addedDepth);

            WriteToCSV(new List <IEnumerable <double> >()
            {
                cummulativeAverageRemovedLength, cummulativeAverageRemovedDepth, cummulativeAverageAddedLength, cummulativeAverageAddedDepth
            },
                       new List <string>()
            {
                "RemovedLenghtXO", "RemovedDepthXO", "AddedLenghtXO", "AddedDepthXO"
            }, filename + "_(MO).csv");
        }
        public void NodeCollection()
        {
            //ExStart
            //ExFor:NodeCollection.Contains(Node)
            //ExFor:NodeCollection.Insert(Int32,Node)
            //ExFor:NodeCollection.Remove(Node)
            //ExSummary:Shows how to work with a NodeCollection.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // The normal way to insert Runs into a document is to add text using a DocumentBuilder
            builder.Write("Run 1. ");
            builder.Write("Run 2. ");

            // Every .Write() invocation creates a new Run, which is added to the parent Paragraph's RunCollection
            RunCollection runs = doc.FirstSection.Body.FirstParagraph.Runs;

            Assert.AreEqual(2, runs.Count);

            // We can insert a node into the RunCollection manually to achieve the same effect
            Run newRun = new Run(doc, "Run 3. ");

            runs.Insert(3, newRun);

            Assert.True(runs.Contains(newRun));
            Assert.AreEqual("Run 1. Run 2. Run 3.", doc.GetText().Trim());

            // Text can also be deleted from the document by accessing individual Runs via the RunCollection and editing or removing them
            Run run = runs[1];

            runs.Remove(run);
            Assert.AreEqual("Run 1. Run 3.", doc.GetText().Trim());

            Assert.NotNull(run);
            Assert.False(runs.Contains(run));
            //ExEnd
        }
Example #34
0
 public BatchRun()
   : base() {
   name = ItemName;
   description = ItemDescription;
   executionState = ExecutionState.Stopped;
   executionTime = TimeSpan.Zero;
   runsExecutionTime = TimeSpan.Zero;
   repetitions = 10;
   repetitionsCounter = 0;
   Runs = new RunCollection { OptimizerName = Name };
 }
 public RunCollectionEqualityConstraint(RunCollection constrainedValue, ConstraintOperation constraintOperation, string constraintData, bool active)
   : base(constrainedValue, constraintOperation, constraintData, active) {
 }
    private void DisplayRuns(RunCollection runs) {
      if (RunCreationClient.Instance.Algorithms == null || RunCreationClient.Instance.Algorithms.Count() == 0) {
        Action a = new Action(delegate {
          RunCreationClient.Instance.Refresh();
          CreateUI(runs);
        });

        Task.Factory.StartNew(a).ContinueWith((t) => { DisplayError(t.Exception); }, TaskContinuationOptions.OnlyOnFaulted);
      } else {
        CreateUI(runs);
      }
    }
 public RunCollectionComparisonConstraint(RunCollection constrainedValue, ConstraintOperation constraintOperation, object constraintData, bool active)
   : base(constrainedValue, constraintOperation, constraintData, active) {
 }
Example #38
0
    private void LoadResultsAsync(int batchSize) {
      bool includeBinaryValues = includeBinaryValuesCheckBox.Checked;
      IEnumerable<ValueName> valueNames = constraintsCheckedListBox.CheckedItems.Cast<ValueName>();

      Cursor = Cursors.AppStarting;
      resultsInfoLabel.Text = "Loading Results ...";
      resultsProgressBar.Value = 0;
      resultsProgressBar.Step = batchSize;
      abortButton.Enabled = true;
      resultsInfoPanel.Visible = true;
      splitContainer.Enabled = false;
      cancellationTokenSource = new CancellationTokenSource();
      CancellationToken cancellationToken = cancellationTokenSource.Token;

      Task task = Task.Factory.StartNew(() => {
        var ids = QueryClient.Instance.GetRunIds(combinedFilterView.Content);
        int idsCount = ids.Count();

        Invoke(new Action(() => {
          resultsInfoLabel.Text = "Loaded 0 of " + idsCount.ToString() + " Results ...";
          resultsProgressBar.Maximum = idsCount;
        }));

        RunCollection runs = new RunCollection();
        runCollectionView.Content = runs;
        while (ids.Count() > 0) {
          cancellationToken.ThrowIfCancellationRequested();
          if (AllValueNamesChecked()) {
            runs.AddRange(QueryClient.Instance.GetRuns(ids.Take(batchSize), includeBinaryValues).Select(x => ConvertToOptimizationRun(x)));
          } else {
            runs.AddRange(QueryClient.Instance.GetRunsWithValues(ids.Take(batchSize), includeBinaryValues, valueNames).Select(x => ConvertToOptimizationRun(x)));
          }
          ids = ids.Skip(batchSize);
          Invoke(new Action(() => {
            resultsInfoLabel.Text = "Loaded " + runs.Count + " of " + idsCount.ToString() + " Results ...";
            resultsProgressBar.PerformStep();
          }));
        }
      }, cancellationToken);
      task.ContinueWith(t => {
        Invoke(new Action(() => {
          cancellationTokenSource.Dispose();
          cancellationTokenSource = null;
          resultsInfoPanel.Visible = false;
          splitContainer.Enabled = true;
          this.Cursor = Cursors.Default;
          SetEnabledStateOfControls();
          try {
            t.Wait();
          }
          catch (AggregateException ex) {
            try {
              ex.Flatten().Handle(x => x is OperationCanceledException);
            }
            catch (AggregateException remaining) {
              if (remaining.InnerExceptions.Count == 1) ErrorHandling.ShowErrorDialog(this, "Refresh results failed.", remaining.InnerExceptions[0]);
              else ErrorHandling.ShowErrorDialog(this, "Refresh results failed.", remaining);
            }
          }
        }));
      });
    }
 public RunCollectionContentConstraint(RunCollection constrainedValue, IObservableSet<IRun> constraintData, bool active)
   : base(constrainedValue, ConstraintOperation.Equal, constraintData, active) {
 }
Example #40
0
 protected Algorithm()
   : base() {
   executionState = ExecutionState.Stopped;
   executionTime = TimeSpan.Zero;
   storeAlgorithmInEachRun = false;
   runsCounter = 0;
   Runs = new RunCollection { OptimizerName = Name };
 }
    protected override void Run(CancellationToken cancellationToken) {
      // Set up the algorithm
      if (SetSeedRandomly) Seed = new System.Random().Next();
      var rand = new MersenneTwister((uint)Seed);

      // Set up the results display
      var iterations = new IntValue(0);
      Results.Add(new Result("Iterations", iterations));

      var table = new DataTable("Qualities");
      table.Rows.Add(new DataRow("R² (train)"));
      table.Rows.Add(new DataRow("R² (test)"));
      Results.Add(new Result("Qualities", table));
      var curLoss = new DoubleValue();
      var curTestLoss = new DoubleValue();
      Results.Add(new Result("R² (train)", curLoss));
      Results.Add(new Result("R² (test)", curTestLoss));
      var runCollection = new RunCollection();
      if (StoreRuns)
        Results.Add(new Result("Runs", runCollection));

      // init
      var problemData = Problem.ProblemData;
      var targetVarName = problemData.TargetVariable;
      var activeVariables = problemData.AllowedInputVariables.Concat(new string[] { problemData.TargetVariable });
      var modifiableDataset = new ModifiableDataset(
        activeVariables,
        activeVariables.Select(v => problemData.Dataset.GetDoubleValues(v).ToList()));

      var trainingRows = problemData.TrainingIndices;
      var testRows = problemData.TestIndices;
      var yPred = new double[trainingRows.Count()];
      var yPredTest = new double[testRows.Count()];
      var y = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).ToArray();
      var curY = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).ToArray();

      var yTest = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TestIndices).ToArray();
      var curYTest = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TestIndices).ToArray();
      var nu = Nu;
      var mVars = (int)Math.Ceiling(M * problemData.AllowedInputVariables.Count());
      var rRows = (int)Math.Ceiling(R * problemData.TrainingIndices.Count());
      var alg = RegressionAlgorithm;
      List<IRegressionModel> models = new List<IRegressionModel>();
      try {

        // Loop until iteration limit reached or canceled.
        for (int i = 0; i < Iterations; i++) {
          cancellationToken.ThrowIfCancellationRequested();

          modifiableDataset.RemoveVariable(targetVarName);
          modifiableDataset.AddVariable(targetVarName, curY.Concat(curYTest));

          SampleTrainingData(rand, modifiableDataset, rRows, problemData.Dataset, curY, problemData.TargetVariable, problemData.TrainingIndices); // all training indices from the original problem data are allowed 
          var modifiableProblemData = new RegressionProblemData(modifiableDataset,
            problemData.AllowedInputVariables.SampleRandomWithoutRepetition(rand, mVars),
            problemData.TargetVariable);
          modifiableProblemData.TrainingPartition.Start = 0;
          modifiableProblemData.TrainingPartition.End = rRows;
          modifiableProblemData.TestPartition.Start = problemData.TestPartition.Start;
          modifiableProblemData.TestPartition.End = problemData.TestPartition.End;

          if (!TrySetProblemData(alg, modifiableProblemData))
            throw new NotSupportedException("The algorithm cannot be used with GBM.");

          IRegressionModel model;
          IRun run;

          // try to find a model. The algorithm might fail to produce a model. In this case we just retry until the iterations are exhausted
          if (TryExecute(alg, rand.Next(), RegressionAlgorithmResult, out model, out run)) {
            int row = 0;
            // update predictions for training and test
            // update new targets (in the case of squared error loss we simply use negative residuals)
            foreach (var pred in model.GetEstimatedValues(problemData.Dataset, trainingRows)) {
              yPred[row] = yPred[row] + nu * pred;
              curY[row] = y[row] - yPred[row];
              row++;
            }
            row = 0;
            foreach (var pred in model.GetEstimatedValues(problemData.Dataset, testRows)) {
              yPredTest[row] = yPredTest[row] + nu * pred;
              curYTest[row] = yTest[row] - yPredTest[row];
              row++;
            }
            // determine quality
            OnlineCalculatorError error;
            var trainR = OnlinePearsonsRCalculator.Calculate(yPred, y, out error);
            var testR = OnlinePearsonsRCalculator.Calculate(yPredTest, yTest, out error);

            // iteration results
            curLoss.Value = error == OnlineCalculatorError.None ? trainR * trainR : 0.0;
            curTestLoss.Value = error == OnlineCalculatorError.None ? testR * testR : 0.0;

            models.Add(model);


          }

          if (StoreRuns)
            runCollection.Add(run);
          table.Rows["R² (train)"].Values.Add(curLoss.Value);
          table.Rows["R² (test)"].Values.Add(curTestLoss.Value);
          iterations.Value = i + 1;
        }

        // produce solution 
        if (CreateSolution) {
          // when all our models are symbolic models we can easily combine them to a single model
          if (models.All(m => m is ISymbolicRegressionModel)) {
            Results.Add(new Result("Solution", CreateSymbolicSolution(models, Nu, (IRegressionProblemData)problemData.Clone())));
          }
          // just produce an ensemble solution for now (TODO: correct scaling or linear regression for ensemble model weights)

          var ensembleSolution = CreateEnsembleSolution(models, (IRegressionProblemData)problemData.Clone());
          Results.Add(new Result("EnsembleSolution", ensembleSolution));
        }
      }
      finally {
        // reset everything
        alg.Prepare(true);
      }
    }
Example #42
0
 protected Algorithm(Algorithm original, Cloner cloner)
   : base(original, cloner) {
   if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));
   executionState = original.executionState;
   executionTime = original.executionTime;
   problem = cloner.Clone(original.problem);
   storeAlgorithmInEachRun = original.storeAlgorithmInEachRun;
   runsCounter = original.runsCounter;
   runs = cloner.Clone(original.runs);
   Initialize();
 }
Example #43
0
 protected Algorithm(string name, string description, ParameterCollection parameters)
   : base(name, description, parameters) {
   executionState = ExecutionState.Stopped;
   executionTime = TimeSpan.Zero;
   storeAlgorithmInEachRun = false;
   runsCounter = 0;
   Runs = new RunCollection { OptimizerName = Name };
 }
Example #44
0
    private TimeLimitRun(TimeLimitRun original, Cloner cloner)
      : base(original, cloner) {
      maximumExecutionTime = original.maximumExecutionTime;
      snapshotTimes = new ObservableList<TimeSpan>(original.snapshotTimes);
      snapshotTimesIndex = original.snapshotTimesIndex;
      snapshots = cloner.Clone(original.snapshots);
      storeAlgorithmInEachSnapshot = original.storeAlgorithmInEachSnapshot;
      algorithm = cloner.Clone(original.algorithm);
      runs = cloner.Clone(original.runs);

      Initialize();
    }
    private RunCollection GetAllRunsFromJob(RefreshableJob job) {
      if (job != null) {
        RunCollection runs = new RunCollection() { OptimizerName = job.ItemName };

        foreach (HiveTask subTask in job.HiveTasks) {
          if (subTask is OptimizerHiveTask) {
            OptimizerHiveTask ohTask = subTask as OptimizerHiveTask;
            ohTask.ExecuteReadActionOnItemTask(new Action(delegate() {
              runs.AddRange(ohTask.ItemTask.Item.Runs);
            }));
          }
        }
        return runs;
      } else {
        return null;
      }
    }
Example #46
0
 public TimeLimitRun()
   : base() {
   name = ItemName;
   description = ItemDescription;
   maximumExecutionTime = TimeSpan.FromMinutes(.5);
   snapshotTimes = new ObservableList<TimeSpan>(new[] {
       TimeSpan.FromSeconds(5),
       TimeSpan.FromSeconds(10),
       TimeSpan.FromSeconds(15) });
   snapshotTimesIndex = 0;
   snapshots = new RunCollection();
   Runs = new RunCollection { OptimizerName = Name };
   Initialize();
 }
Example #47
0
 public BatchRun(string name, string description)
   : base(name, description) {
   executionState = ExecutionState.Stopped;
   executionTime = TimeSpan.Zero;
   runsExecutionTime = TimeSpan.Zero;
   repetitions = 10;
   repetitionsCounter = 0;
   Runs = new RunCollection { OptimizerName = Name };
 }
 public RunCollectionTypeCompatibilityConstraint(RunCollection constrainedValue, ConstraintOperation constraintOperation, Type constraintData, bool active)
   : base(constrainedValue, constraintOperation, constraintData, active) {
 }
Example #49
0
 private BatchRun(BatchRun original, Cloner cloner)
   : base(original, cloner) {
   executionState = original.executionState;
   executionTime = original.executionTime;
   runsExecutionTime = original.runsExecutionTime;
   optimizer = cloner.Clone(original.optimizer);
   repetitions = original.repetitions;
   repetitionsCounter = original.repetitionsCounter;
   runs = cloner.Clone(original.runs);
   batchRunAction = original.batchRunAction;
   Initialize();
 }
Example #50
0
 public OKBAlgorithm()
   : base() {
   algorithmId = -1;
   algorithm = new EmptyAlgorithm("No algorithm selected. Please choose an algorithm from the OKB.");
   RegisterAlgorithmEvents();
   runs = new RunCollection();
   storeRunsAutomatically = true;
   RegisterRunsEvents();
 }
Example #51
0
    private Experiment(Experiment original, Cloner cloner)
      : base(original, cloner) {
      executionState = original.executionState;
      executionTime = original.executionTime;
      optimizers = cloner.Clone(original.optimizers);
      runs = cloner.Clone(original.runs);

      experimentStarted = original.experimentStarted;
      experimentStopped = original.experimentStopped;
      Initialize();
    }
Example #52
0
 public TimeLimitRun(string name, string description)
   : base(name, description) {
   maximumExecutionTime = TimeSpan.FromMinutes(.5);
   snapshotTimes = new ObservableList<TimeSpan>(new[] {
       TimeSpan.FromSeconds(5),
       TimeSpan.FromSeconds(10),
       TimeSpan.FromSeconds(15) });
   snapshotTimesIndex = 0;
   Runs = new RunCollection { OptimizerName = Name };
   Initialize();
 }
 public BenchmarkAlgorithm() {
   name = ItemName;
   description = ItemDescription;
   parameters = new ParameterCollection();
   readOnlyParameters = null;
   executionState = ExecutionState.Stopped;
   executionTime = TimeSpan.Zero;
   storeAlgorithmInEachRun = false;
   runsCounter = 0;
   Runs = new RunCollection() { OptimizerName = name };
   results = new ResultCollection();
   CreateParameters();
   DiscoverBenchmarks();
   Prepare();
 }
Example #54
0
        private void CreateUI(RunCollection runs)
        {
            if (InvokeRequired)
            {
                Invoke((Action <RunCollection>)CreateUI, runs); return;
            }
            if (problems.Count == 0)
            {
                problems.AddRange(RunCreationClient.Instance.Problems);
            }
            if (algorithms.Count == 0)
            {
                algorithms.AddRange(RunCreationClient.Instance.Algorithms);
            }

            IItem algorithmType;
            IItem problemType;
            IItem algorithmName;
            IItem problemName;

            OKBAlgorithmColumn.DataSource = algorithms;
            OKBProblemColumn.DataSource   = problems;

            foreach (IRun run in runs)
            {
                int             idx    = dataGridView.Rows.Add(run.Name);
                DataGridViewRow curRow = dataGridView.Rows[idx];
                curRow.Tag = run;

                HeuristicLab.Data.StringValue algStr = null, algTypeStr = null, prbStr = null, prbTypeStr = null;
                if (run.Parameters.TryGetValue(AlgorithmNameParameterName, out algorithmName))
                {
                    algStr = algorithmName as HeuristicLab.Data.StringValue;
                    if (algStr != null)
                    {
                        curRow.Cells[AlgorithmNameColumn.Name].Value = algStr;
                    }
                }

                if (run.Parameters.TryGetValue(AlgorithmTypeParameterName, out algorithmType))
                {
                    algTypeStr = algorithmType as HeuristicLab.Data.StringValue;
                    if (algTypeStr != null)
                    {
                        curRow.Cells[AlgorithmTypeColumn.Name].Value = algTypeStr;
                    }
                }

                var uploadOk = false;
                if (algStr != null && algTypeStr != null)
                {
                    var alg = algorithms.FirstOrDefault(x => x.DataType.Name == algTypeStr.Value && x.Name == algStr.Value);
                    if (alg != null)
                    {
                        curRow.Cells[OKBAlgorithmColumn.Name].Value = alg.Name;
                        uploadOk = true;
                    }
                }

                if (run.Parameters.TryGetValue(ProblemNameParameterName, out problemName))
                {
                    prbStr = problemName as HeuristicLab.Data.StringValue;
                    if (prbStr != null)
                    {
                        curRow.Cells[ProblemNameColumn.Name].Value = prbStr;
                    }
                }

                if (run.Parameters.TryGetValue(ProblemTypeParameterName, out problemType))
                {
                    prbTypeStr = problemType as HeuristicLab.Data.StringValue;
                    if (prbTypeStr != null)
                    {
                        curRow.Cells[ProblemTypeColumn.Name].Value = prbTypeStr;
                    }
                }

                if (prbStr != null && prbTypeStr != null)
                {
                    var prb = problems.FirstOrDefault(x => x.DataType.Name == prbTypeStr.Value && x.Name == prbStr.Value);
                    if (prb != null)
                    {
                        curRow.Cells[OKBProblemColumn.Name].Value = prb.Name;
                    }
                    else
                    {
                        uploadOk = false;
                    }
                }

                curRow.Cells[UploadColumn.Name].Value = uploadOk;
            }
        }
Example #55
0
 private OKBAlgorithm(OKBAlgorithm original, Cloner cloner)
   : base(original, cloner) {
   algorithmId = original.algorithmId;
   algorithm = cloner.Clone(original.algorithm);
   RegisterAlgorithmEvents();
   runs = cloner.Clone(original.runs);
   storeRunsAutomatically = original.storeRunsAutomatically;
   UserId = original.UserId;
   RegisterRunsEvents();
 }
Example #56
0
 public Experiment(string name, string description)
   : base(name, description) {
   executionState = ExecutionState.Stopped;
   executionTime = TimeSpan.Zero;
   optimizers = new OptimizerList();
   Runs = new RunCollection { OptimizerName = Name };
   Initialize();
 }
    private static DataTable CalcAverage(RunCollection runs, string tableName) {
      DataTable temptable = new DataTable();

      var visibleRuns = runs.Where(r => r.Visible);

      var resultName = (string)tableName;

      var dataTables = visibleRuns.Where(r => r.Results.ContainsKey(resultName)).Select(r => (DataTable)r.Results[resultName]);
      if (dataTables.Count() != visibleRuns.Count()) {
        throw new ArgumentException("Should not happen");
      }

      var dataRows = dataTables.SelectMany(dt => dt.Rows).GroupBy(r => r.Name, r => r);

      foreach (var row in dataRows) {
        var averageValues = DataRowsAggregate(Enumerable.Average, row.Select(r => r.Values));
        DataRow averageRow = new DataRow(row.Key, "Average of Values", averageValues);
        temptable.Rows.Add(averageRow);
      }
      return temptable;
    }
Example #58
0
 public Experiment()
   : base() {
   name = ItemName;
   description = ItemDescription;
   executionState = ExecutionState.Stopped;
   executionTime = TimeSpan.Zero;
   optimizers = new OptimizerList();
   Runs = new RunCollection { OptimizerName = Name };
   Initialize();
 }
 public void AddRuns(IItem item) {
   if (InvokeRequired) { Invoke((Action<IItem>)AddRuns, item); return; }
   if (item is Experiment) {
     runs.AddRange((item as Experiment).Runs);
     DisplayRuns((item as Experiment).Runs);
   } else if (item is RunCollection) {
     runs.AddRange((item as RunCollection));
     DisplayRuns((item as RunCollection));
   } else if (item is IOptimizer) {
     runs.AddRange((item as IOptimizer).Runs);
     DisplayRuns((item as IOptimizer).Runs);
   } else if (item is IRun) {
     runs.Add(item as IRun);
     RunCollection tmp = new RunCollection();
     tmp.Add(item as IRun);
     DisplayRuns(tmp);
   }
   SetEnabledStateOfControls();
 }
    private void CreateUI(RunCollection runs) {
      if (InvokeRequired) { Invoke((Action<RunCollection>)CreateUI, runs); return; }
      if (problems.Count == 0)
        problems.AddRange(RunCreationClient.Instance.Problems);
      if (algorithms.Count == 0)
        algorithms.AddRange(RunCreationClient.Instance.Algorithms);

      IItem algorithmType;
      IItem problemType;
      IItem algorithmName;
      IItem problemName;

      OKBAlgorithmColumn.DataSource = algorithms;
      OKBProblemColumn.DataSource = problems;

      foreach (IRun run in runs) {
        int idx = dataGridView.Rows.Add(run.Name);
        DataGridViewRow curRow = dataGridView.Rows[idx];
        curRow.Tag = run;

        HeuristicLab.Data.StringValue algStr = null, algTypeStr = null, prbStr = null, prbTypeStr = null;
        if (run.Parameters.TryGetValue(AlgorithmNameParameterName, out algorithmName)) {
          algStr = algorithmName as HeuristicLab.Data.StringValue;
          if (algStr != null) {
            curRow.Cells[AlgorithmNameColumn.Name].Value = algStr;
          }
        }

        if (run.Parameters.TryGetValue(AlgorithmTypeParameterName, out algorithmType)) {
          algTypeStr = algorithmType as HeuristicLab.Data.StringValue;
          if (algTypeStr != null) {
            curRow.Cells[AlgorithmTypeColumn.Name].Value = algTypeStr;
          }
        }

        var uploadOk = false;
        if (algStr != null && algTypeStr != null) {
          var alg = algorithms.FirstOrDefault(x => x.DataType.Name == algTypeStr.Value && x.Name == algStr.Value);
          if (alg != null) {
            curRow.Cells[OKBAlgorithmColumn.Name].Value = alg.Name;
            uploadOk = true;
          }
        }

        if (run.Parameters.TryGetValue(ProblemNameParameterName, out problemName)) {
          prbStr = problemName as HeuristicLab.Data.StringValue;
          if (prbStr != null) {
            curRow.Cells[ProblemNameColumn.Name].Value = prbStr;
          }
        }

        if (run.Parameters.TryGetValue(ProblemTypeParameterName, out problemType)) {
          prbTypeStr = problemType as HeuristicLab.Data.StringValue;
          if (prbTypeStr != null) {
            curRow.Cells[ProblemTypeColumn.Name].Value = prbTypeStr;
          }
        }

        if (prbStr != null && prbTypeStr != null) {
          var prb = problems.FirstOrDefault(x => x.DataType.Name == prbTypeStr.Value && x.Name == prbStr.Value);
          if (prb != null) {
            curRow.Cells[OKBProblemColumn.Name].Value = prb.Name;
          } else uploadOk = false;
        }

        curRow.Cells[UploadColumn.Name].Value = uploadOk;
      }
    }