Changeset 10413
- Timestamp:
- 01/28/14 19:12:39 (11 years ago)
- Location:
- branches/Sliding Window GP
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SlidingWindowBestSolutionsCollectionView.cs
r10402 r10413 64 64 var dataGridView = (DataGridView)sender; 65 65 var cell = dataGridView.SelectedCells[0]; 66 var bestSolutions = Content.BestSolutions. ToList();66 var bestSolutions = Content.BestSolutions.Values.ToList(); 67 67 var tree = bestSolutions[cell.RowIndex]; 68 68 var model = Content.CreateModel(tree, Content.Interpreter); … … 115 115 116 116 private void UpdateQualitiesMap() { 117 var bestSolutions = Content.BestSolutions. ToList();118 var swPositions = Content. SlidingWindowPositions.ToList();117 var bestSolutions = Content.BestSolutions.Values.ToList(); 118 var swPositions = Content.BestSolutions.Keys.ToList(); 119 119 var qualitiesMap = new DoubleMatrix(bestSolutions.Count, swPositions.Count + 1); 120 qualitiesMap.ColumnNames = Content.SlidingWindowPositions.Select(x => x.Start + "-" + x.End).Concat(new List<string> { "Training" });120 qualitiesMap.ColumnNames = swPositions.Select(x => x.Item1 + "-" + x.Item2).Concat(new List<string> { "Training" }); 121 121 qualitiesMap.RowNames = Enumerable.Range(1, bestSolutions.Count).Select(x => "M" + x); 122 122 double min = 0, max = 0; … … 124 124 for (int i = 0; i < qualitiesMap.Columns - 1; ++i) { 125 125 var pos = swPositions[i]; 126 var rows = Enumerable.Range(pos. Start, pos.End - pos.Start).ToList();126 var rows = Enumerable.Range(pos.Item1, pos.Item2 - pos.Item1).ToList(); 127 127 128 128 for (int j = 0; j < qualitiesMap.Rows; ++j) { -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowAnalyzer.cs
r10396 r10413 138 138 } 139 139 140 SaveBestSolution(); 141 140 142 if (!CheckForUpdate()) return base.Apply(); 141 142 SaveBestSolution();143 143 144 144 //update necessary - move sliding window … … 189 189 var fitnessPartition = FitnessCalculationPartitionParameter.ActualValue; 190 190 var best = FindBestIndividual(); 191 var range = new IntRange(fitnessPartition.Start, fitnessPartition.End);191 var range = new Tuple<int, int>(fitnessPartition.Start, fitnessPartition.End); 192 192 193 bestSolutionsCollection .Add(best, range);193 bestSolutionsCollection[range] = best; 194 194 } 195 195 -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowBestSolutionsCollection.cs
r10402 r10413 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 using SlidingWindowRange = System.Tuple<int, int>; 28 29 29 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 31 32 [Item("SlidingWindowBestSolutionsCollection", "An object holding a collection of the best sliding window solutions.")] 32 33 public abstract class SlidingWindowBestSolutionsCollection : Item { 33 34 private List<ISymbolicExpressionTree> bestSolutions;35 34 [Storable] 36 public IEnumerable<ISymbolicExpressionTree> BestSolutions { 35 private Dictionary<SlidingWindowRange, ISymbolicExpressionTree> bestSolutions; 36 public Dictionary<SlidingWindowRange, ISymbolicExpressionTree> BestSolutions { 37 37 get { return bestSolutions; } 38 set { bestSolutions = new List<ISymbolicExpressionTree>(value); } 39 } 40 41 private List<IntRange> slidingWindowPositions; 42 [Storable] 43 public IEnumerable<IntRange> SlidingWindowPositions { 44 get { return slidingWindowPositions; } 45 set { slidingWindowPositions = new List<IntRange>(value); } 38 set { bestSolutions = value; } 46 39 } 47 40 … … 68 61 : base(original, cloner) { 69 62 this.bestSolutions = original.bestSolutions; 70 this.slidingWindowPositions = original.slidingWindowPositions;71 63 this.problemData = original.problemData; 72 64 this.interpreter = original.interpreter; 73 65 } 74 66 protected SlidingWindowBestSolutionsCollection() { 75 bestSolutions = new List<ISymbolicExpressionTree>(); 76 slidingWindowPositions = new List<IntRange>(); 67 bestSolutions = new Dictionary<SlidingWindowRange, ISymbolicExpressionTree>(); 77 68 } 78 69 79 public void Add(ISymbolicExpressionTree solution, IntRange range) { 80 if (bestSolutions == null) bestSolutions = new List<ISymbolicExpressionTree>(); 81 bestSolutions.Add(solution); 82 if (slidingWindowPositions == null) slidingWindowPositions = new List<IntRange>(); 83 slidingWindowPositions.Add(range); 70 public bool ContainsKey(SlidingWindowRange key) { 71 return bestSolutions.ContainsKey(key); 72 } 73 74 public ISymbolicExpressionTree this[SlidingWindowRange key] { 75 get { 76 return bestSolutions[key]; 77 } 78 set { 79 if (bestSolutions.ContainsKey(key)) 80 bestSolutions[key] = value; 81 else 82 bestSolutions.Add(key, value); 83 } 84 } 85 86 public void Add(SlidingWindowRange range, ISymbolicExpressionTree solution) { 87 bestSolutions.Add(range, solution); 84 88 } 85 89 86 90 public void Clear() { 87 91 if (bestSolutions != null) bestSolutions.Clear(); 88 if (slidingWindowPositions != null) slidingWindowPositions.Clear();89 92 } 90 93 … … 92 95 double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue); 93 96 94 public abstract ISymbolicDataAnalysisSolution CreateSolution(ISymbolicDataAnalysisModel model, 95 IDataAnalysisProblemData problemData); 97 public abstract ISymbolicDataAnalysisSolution CreateSolution(ISymbolicDataAnalysisModel model, IDataAnalysisProblemData problemData); 96 98 } 97 99 }
Note: See TracChangeset
for help on using the changeset viewer.