[8498] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
[9059] | 22 | using HeuristicLab.Collections;
|
---|
[8501] | 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
[8498] | 25 | using HeuristicLab.Optimization;
|
---|
[8501] | 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[8498] | 27 |
|
---|
| 28 | namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
|
---|
[8501] | 29 | [Item("DataTableHelper", "Helper class for creating datatables.")]
|
---|
| 30 | [StorableClass]
|
---|
| 31 | public class DataTableHelper : Item {
|
---|
[8498] | 32 |
|
---|
[8505] | 33 | [Storable]
|
---|
[8498] | 34 | private ResultCollection resultsCol;
|
---|
[8505] | 35 | [Storable]
|
---|
[8498] | 36 | private string chartName;
|
---|
[8505] | 37 | [Storable]
|
---|
[8797] | 38 | private string[] dataRowNames;
|
---|
[8505] | 39 | [Storable]
|
---|
[8797] | 40 | DataTable dt;
|
---|
[8498] | 41 |
|
---|
[8501] | 42 | [StorableConstructor]
|
---|
| 43 | private DataTableHelper(bool deserializing) : base(deserializing) { }
|
---|
| 44 | private DataTableHelper(DataTableHelper original, Cloner cloner)
|
---|
[8515] | 45 | : base(original, cloner) { }
|
---|
[8501] | 46 | public DataTableHelper() : base() { }
|
---|
[8498] | 47 |
|
---|
[8501] | 48 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 49 | return new DataTableHelper(this, cloner);
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[8797] | 52 | public void InitializeChart(ResultCollection results, string chartName, string[] dataRowNames) {
|
---|
[8498] | 53 | if (!results.ContainsKey(chartName)) {
|
---|
| 54 | this.resultsCol = results;
|
---|
| 55 | this.chartName = chartName;
|
---|
[8797] | 56 | this.dataRowNames = dataRowNames;
|
---|
[8498] | 57 |
|
---|
[8797] | 58 | dt = new DataTable(chartName);
|
---|
| 59 |
|
---|
| 60 | foreach (string dataRowName in dataRowNames) {
|
---|
| 61 | DataRow dtRow = new DataRow(dataRowName);
|
---|
| 62 | dt.Rows.Add(dtRow);
|
---|
| 63 | }
|
---|
| 64 |
|
---|
[8498] | 65 | results.Add(new Result(chartName, dt));
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[8797] | 69 | public void AddPoint(string dataRow, double point) {
|
---|
| 70 | dt.Rows[dataRow].Values.Add(point);
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[8498] | 73 | public void AddPoint(double point) {
|
---|
[8797] | 74 | // assume that there is only 1 row and therefore the name doesn't have to be provided
|
---|
| 75 | dt.Rows[dataRowNames[0]].Values.Add(point);
|
---|
[8498] | 76 | }
|
---|
[9059] | 77 |
|
---|
| 78 | public ObservableList<double> GetFirstDataRow() {
|
---|
| 79 | return dt.Rows[dataRowNames[0]].Values;
|
---|
| 80 | }
|
---|
[8498] | 81 | }
|
---|
| 82 | }
|
---|