Changeset 10402 for branches/Sliding Window GP
- Timestamp:
- 01/27/14 14:14:42 (11 years ago)
- Location:
- branches/Sliding Window GP
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/Sliding Window/GenerationalClassificationSlidingWindowAnalyzer.cs
r10396 r10402 1 using HeuristicLab.Common; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 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 22 using HeuristicLab.Common; 2 23 using HeuristicLab.Core; 3 24 using HeuristicLab.Optimization; … … 21 42 } 22 43 #endregion 23 24 44 [StorableConstructor] 25 45 protected GenerationalClassificationSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { } 46 [StorableHook(HookType.AfterDeserialization)] 47 private void AfterDeserialization() { } 26 48 protected GenerationalClassificationSlidingWindowAnalyzer(GenerationalClassificationSlidingWindowAnalyzer original, Cloner cloner) 27 49 : base(original, cloner) { … … 30 52 return new GenerationalClassificationSlidingWindowAnalyzer(this, cloner); 31 53 } 32 [StorableHook(HookType.AfterDeserialization)]33 private void AfterDeserialization() {34 }35 36 54 public GenerationalClassificationSlidingWindowAnalyzer() { 37 55 Parameters.Add(new LookupParameter<ISymbolicClassificationModelCreator>(ModelCreatorParameterName)); 38 56 } 39 40 57 public override IOperation Apply() { 41 58 if (!ResultCollection.ContainsKey("Best Solutions")) { -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/Sliding Window/OffspringSelectionClassificationSlidingWindowAnalyzer.cs
r10396 r10402 1 using HeuristicLab.Common; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 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 22 using HeuristicLab.Common; 2 23 using HeuristicLab.Core; 3 24 using HeuristicLab.Optimization; … … 7 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { 8 29 [StorableClass] 9 [Item("Offspring SelectionClassificationSlidingWindowAnalyzer", "")]30 [Item("Offspring Selection Classification Sliding Window Analyzer", "")] 10 31 public class OffspringSelectionClassificationSlidingWindowAnalyzer : OffspringSelectionSlidingWindowAnalyzer { 11 32 private const string ModelCreatorParameterName = "ModelCreator"; … … 21 42 } 22 43 #endregion 23 44 [StorableConstructor] 45 protected OffspringSelectionClassificationSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { } 46 [StorableHook(HookType.AfterDeserialization)] 47 private void AfterDeserialization() { } 24 48 protected OffspringSelectionClassificationSlidingWindowAnalyzer(OffspringSelectionClassificationSlidingWindowAnalyzer original, Cloner cloner) 25 49 : base(original, cloner) { … … 28 52 return new OffspringSelectionClassificationSlidingWindowAnalyzer(this, cloner); 29 53 } 30 [StorableConstructor]31 protected OffspringSelectionClassificationSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { }32 33 54 public OffspringSelectionClassificationSlidingWindowAnalyzer() { 34 55 Parameters.Add(new LookupParameter<ISymbolicClassificationModelCreator>(ModelCreatorParameterName)); 35 56 } 36 37 [StorableHook(HookType.AfterDeserialization)]38 private void AfterDeserialization() {39 }40 41 57 public override IOperation Apply() { 42 58 if (!ResultCollection.ContainsKey("Best Solutions")) { -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/Sliding Window/SlidingWindowBestClassificationSolutionsCollection.cs
r10396 r10402 1 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 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 2 22 using HeuristicLab.Common; 3 23 using HeuristicLab.Core; … … 7 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { 8 28 [StorableClass] 9 [Item(" ", "")]29 [Item("Sliding Window Best Classification Solutions Collection", "A collection of best sliding window solutions for symbolic classification.")] 10 30 public class SlidingWindowBestClassificationSolutionsCollection : SlidingWindowBestSolutionsCollection { 31 public new IClassificationProblemData ProblemData { 32 get { return (IClassificationProblemData)base.ProblemData; } 33 set { base.ProblemData = value; } 34 } 35 public ISymbolicClassificationModelCreator ModelCreator { get; set; } 36 [StorableConstructor] 37 protected SlidingWindowBestClassificationSolutionsCollection(bool deserializing) : base(deserializing) { } 38 [StorableHook(HookType.AfterDeserialization)] 39 private void AfterDeserialization() { } 11 40 public SlidingWindowBestClassificationSolutionsCollection(SlidingWindowBestClassificationSolutionsCollection original, Cloner cloner) 12 41 : base(original, cloner) { … … 15 44 return new SlidingWindowBestClassificationSolutionsCollection(this, cloner); 16 45 } 17 18 public new IClassificationProblemData ProblemData { 19 get { return (IClassificationProblemData)base.ProblemData; } 20 set { base.ProblemData = value; } 21 } 22 23 public ISymbolicClassificationModelCreator ModelCreator { get; set; } 24 25 public SlidingWindowBestClassificationSolutionsCollection() { 26 27 } 28 46 public SlidingWindowBestClassificationSolutionsCollection() { } 29 47 public override ISymbolicDataAnalysisModel CreateModel(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, 30 48 double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue) { … … 33 51 return model; 34 52 } 35 36 53 public override ISymbolicDataAnalysisSolution CreateSolution(ISymbolicDataAnalysisModel model, IDataAnalysisProblemData problemData) { 37 54 return new SymbolicClassificationSolution((ISymbolicClassificationModel)model, (IClassificationProblemData)problemData); -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SlidingWindow/GenerationalRegressionSlidingWindowAnalyzer.cs
r10396 r10402 1 using HeuristicLab.Common; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 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 22 using HeuristicLab.Common; 2 23 using HeuristicLab.Core; 3 24 using HeuristicLab.Optimization; … … 10 31 [StorableConstructor] 11 32 protected GenerationalRegressionSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { } 33 [StorableHook(HookType.AfterDeserialization)] 34 private void AfterDeserialization() { } 12 35 protected GenerationalRegressionSlidingWindowAnalyzer(GenerationalRegressionSlidingWindowAnalyzer original, Cloner cloner) 13 36 : base(original, cloner) { … … 16 39 return new GenerationalRegressionSlidingWindowAnalyzer(this, cloner); 17 40 } 18 [StorableHook(HookType.AfterDeserialization)] 19 private void AfterDeserialization() { 20 } 41 public GenerationalRegressionSlidingWindowAnalyzer() { } 21 42 public override IOperation Apply() { 22 43 if (!ResultCollection.ContainsKey("Best Solutions")) { -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SlidingWindow/OffspringSelectionRegressionSlidingWindowAnalyzer.cs
r10396 r10402 1 using HeuristicLab.Common; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 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 22 using HeuristicLab.Common; 2 23 using HeuristicLab.Core; 3 24 using HeuristicLab.Optimization; … … 8 29 [Item("OffspringSelectionRegressionSlidingWindowAnalyzer", "")] 9 30 public class OffspringSelectionRegressionSlidingWindowAnalyzer : OffspringSelectionSlidingWindowAnalyzer { 31 [StorableConstructor] 32 protected OffspringSelectionRegressionSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { } 33 [StorableHook(HookType.AfterDeserialization)] 34 private void AfterDeserialization() { } 10 35 protected OffspringSelectionRegressionSlidingWindowAnalyzer(OffspringSelectionRegressionSlidingWindowAnalyzer original, Cloner cloner) 11 36 : base(original, cloner) { … … 14 39 return new OffspringSelectionRegressionSlidingWindowAnalyzer(this, cloner); 15 40 } 16 [StorableConstructor]17 protected OffspringSelectionRegressionSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { }18 41 public OffspringSelectionRegressionSlidingWindowAnalyzer() { } 19 20 [StorableHook(HookType.AfterDeserialization)]21 private void AfterDeserialization() {22 }23 24 42 public override IOperation Apply() { 25 43 if (!ResultCollection.ContainsKey("Best Solutions")) { -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SlidingWindow/SlidingWindowBestRegressionSolutionsCollection.cs
r10396 r10402 1 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 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 2 22 using HeuristicLab.Common; 3 23 using HeuristicLab.Core; … … 7 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 8 28 [StorableClass] 9 [Item(" ", "")]29 [Item("SlidingWindowBestRegressionSolutionsCollection", "A collection of best sliding window solutions for symbolic regression.")] 10 30 public class SlidingWindowBestRegressionSolutionsCollection : SlidingWindowBestSolutionsCollection { 31 public new IRegressionProblemData ProblemData { 32 get { return (IRegressionProblemData)base.ProblemData; } 33 set { base.ProblemData = value; } 34 } 35 [StorableConstructor] 36 protected SlidingWindowBestRegressionSolutionsCollection(bool deserializing) : base(deserializing) { } 37 [StorableHook(HookType.AfterDeserialization)] 38 private void AfterDeserialization() { } 11 39 public SlidingWindowBestRegressionSolutionsCollection(SlidingWindowBestRegressionSolutionsCollection original, Cloner cloner) 12 40 : base(original, cloner) { … … 15 43 return new SlidingWindowBestRegressionSolutionsCollection(this, cloner); 16 44 } 17 18 public new IRegressionProblemData ProblemData { 19 get { return (IRegressionProblemData)base.ProblemData; } 20 set { base.ProblemData = value; } 21 } 22 23 public SlidingWindowBestRegressionSolutionsCollection() { 24 25 } 26 45 public SlidingWindowBestRegressionSolutionsCollection() { } 27 46 public override ISymbolicDataAnalysisModel CreateModel(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, 28 47 double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue) { 29 48 return new SymbolicRegressionModel(tree, interpreter, lowerEstimationLimit, upperEstimationLimit); 30 49 } 31 32 50 public override ISymbolicDataAnalysisSolution CreateSolution(ISymbolicDataAnalysisModel model, IDataAnalysisProblemData problemData) { 33 51 return new SymbolicRegressionSolution((ISymbolicRegressionModel)model, (IRegressionProblemData)problemData); -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SlidingWindowBestSolutionsCollectionView.cs
r10396 r10402 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 43 64 var dataGridView = (DataGridView)sender; 44 65 var cell = dataGridView.SelectedCells[0]; 45 var tree = Content.BestSolutions[cell.RowIndex]; 66 var bestSolutions = Content.BestSolutions.ToList(); 67 var tree = bestSolutions[cell.RowIndex]; 46 68 var model = Content.CreateModel(tree, Content.Interpreter); 47 69 var solution = Content.CreateSolution(model, Content.ProblemData); … … 93 115 94 116 private void UpdateQualitiesMap() { 95 var qualitiesMap = new DoubleMatrix(Content.BestSolutions.Count, Content.SlidingWindowPositions.Count + 1); 117 var bestSolutions = Content.BestSolutions.ToList(); 118 var swPositions = Content.SlidingWindowPositions.ToList(); 119 var qualitiesMap = new DoubleMatrix(bestSolutions.Count, swPositions.Count + 1); 96 120 qualitiesMap.ColumnNames = Content.SlidingWindowPositions.Select(x => x.Start + "-" + x.End).Concat(new List<string> { "Training" }); 97 qualitiesMap.RowNames = Enumerable.Range(1, Content.BestSolutions.Count).Select(x => "M" + x);121 qualitiesMap.RowNames = Enumerable.Range(1, bestSolutions.Count).Select(x => "M" + x); 98 122 double min = 0, max = 0; 99 123 100 124 for (int i = 0; i < qualitiesMap.Columns - 1; ++i) { 101 var pos = Content.SlidingWindowPositions[i];125 var pos = swPositions[i]; 102 126 var rows = Enumerable.Range(pos.Start, pos.End - pos.Start).ToList(); 103 127 104 128 for (int j = 0; j < qualitiesMap.Rows; ++j) { 105 var tree = Content.BestSolutions[j];129 var tree = bestSolutions[j]; 106 130 var q = CalculateQuality(tree, rows); 107 131 if (min > q) min = q; … … 112 136 // deal separately with the last column which represents the whole training partition interval 113 137 for (int j = 0; j < qualitiesMap.Rows; ++j) { 114 var tree = Content.BestSolutions[j];138 var tree = bestSolutions[j]; 115 139 var q = CalculateQuality(tree, Content.ProblemData.TrainingIndices); 116 140 if (min > q) min = q; -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowBestSolutionsCollection.cs
r10398 r10402 31 31 [Item("SlidingWindowBestSolutionsCollection", "An object holding a collection of the best sliding window solutions.")] 32 32 public abstract class SlidingWindowBestSolutionsCollection : Item { 33 34 private List<ISymbolicExpressionTree> bestSolutions; 33 35 [Storable] 34 private List<ISymbolicExpressionTree> bestSolutions; 35 public List<ISymbolicExpressionTree> BestSolutions { 36 public IEnumerable<ISymbolicExpressionTree> BestSolutions { 36 37 get { return bestSolutions; } 38 set { bestSolutions = new List<ISymbolicExpressionTree>(value); } 37 39 } 38 40 41 private List<IntRange> slidingWindowPositions; 39 42 [Storable] 40 private List<IntRange> slidingWindowPositions; 41 public List<IntRange> SlidingWindowPositions { 43 public IEnumerable<IntRange> SlidingWindowPositions { 42 44 get { return slidingWindowPositions; } 45 set { slidingWindowPositions = new List<IntRange>(value); } 43 46 } 44 47 … … 56 59 set { interpreter = value; } 57 60 } 61 [StorableHook(HookType.AfterDeserialization)] 62 private void AfterDeserialization() { 63 } 58 64 65 [StorableConstructor] 66 protected SlidingWindowBestSolutionsCollection(bool deserializing) : base(deserializing) { } 59 67 protected SlidingWindowBestSolutionsCollection(SlidingWindowBestSolutionsCollection original, Cloner cloner) 60 68 : base(original, cloner) { 61 this.bestSolutions = original. BestSolutions;62 this.slidingWindowPositions = original. SlidingWindowPositions;63 this. ProblemData = original.ProblemData;64 this. Interpreter = original.Interpreter;69 this.bestSolutions = original.bestSolutions; 70 this.slidingWindowPositions = original.slidingWindowPositions; 71 this.problemData = original.problemData; 72 this.interpreter = original.interpreter; 65 73 } 66 74 protected SlidingWindowBestSolutionsCollection() {
Note: See TracChangeset
for help on using the changeset viewer.