Changeset 7850 for branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow
- Timestamp:
- 05/21/12 10:30:41 (13 years ago)
- Location:
- branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/GenerationalSlidingWindowAnalyzer.cs
r7845 r7850 72 72 Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "")); 73 73 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, "")); 74 Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalParameterName, "", new IntValue(0))); 75 Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalStartParameterName, "", new IntValue(10))); 74 Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalParameterName, "", new IntValue(5))); 75 Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalStartParameterName, "", new IntValue(0))); 76 77 GenerationsIntervalStartParameter.Hidden = true; 76 78 } 77 79 … … 80 82 var start = GenerationsIntervalStart.Value; 81 83 var step = GenerationsInterval.Value; 84 if (iteration == 0) return false; 82 85 if (iteration < start) return false; 83 84 86 if ((iteration - start) % step == 0) return true; 85 87 -
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowAnalyzer.cs
r7845 r7850 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 35 36 private const string ResultCollectionParameterName = "Results"; 36 37 private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition"; 37 private const string SlidingWindowParameterName = "Sliding Window";38 38 private const string SlidingWindowSizeParameterName = "Sliding Window Size"; 39 39 private const string SlidingWindowStepWidthParameterName = "Sliding Window Step Width"; … … 52 52 } 53 53 54 public IValueLookupParameter<IntRange> SlidingWindowParameter {55 get { return (IValueLookupParameter<IntRange>)Parameters[SlidingWindowParameterName]; }56 }57 54 public IFixedValueParameter<IntValue> SlidingWindowSizeParameter { 58 55 get { return (IFixedValueParameter<IntValue>)Parameters[SlidingWindowSizeParameterName]; } … … 65 62 #region properties 66 63 public bool EnabledByDefault { get { return false; } } 67 public IntRange SlidingWindow { get { return SlidingWindowParameter.Value; } }68 64 public IntValue SlidingWindowSize { get { return SlidingWindowSizeParameter.Value; } } 69 65 public IntValue SlidingWindowStepWidth { get { return SlidingWindowStepWidthParameter.Value; } } … … 77 73 78 74 protected SlidingWindowAnalyzer() { 75 Parameters.Add(new LookupParameter<ResultCollection>(ResultCollectionParameterName, "The result collection to store the analysis results.")); 79 76 Parameters.Add(new ValueLookupParameter<T>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated.")); 80 77 Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "")); 81 Parameters.Add(new ValueLookupParameter<IntRange>(SlidingWindowParameterName, ""));82 78 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowSizeParameterName, "", new IntValue(1))); 83 79 Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowStepWidthParameterName, "", new IntValue(1))); … … 85 81 86 82 public override IOperation Apply() { 87 if (!ExecutionContext.Scope.Variables.ContainsKey(FitnessCalculationPartitionParameter.ActualName))88 ExecutionContext.Scope.Variables.Add(new Core.Variable(FitnessCalculationPartitionParameter.ActualName, (IntRange)SlidingWindow.Clone()));89 90 83 if (CheckForUpdate()) { 91 84 var fitnessPartition = FitnessCalculationPartitionParameter.ActualValue; 85 if (fitnessPartition.End - fitnessPartition.Start == SlidingWindowSize.Value) 86 fitnessPartition.Start += SlidingWindowStepWidth.Value; 92 87 93 88 fitnessPartition.End += SlidingWindowStepWidth.Value; 94 if (fitnessPartition.End - fitnessPartition.Start > SlidingWindowS tepWidth.Value)89 if (fitnessPartition.End - fitnessPartition.Start > SlidingWindowSize.Value) 95 90 fitnessPartition.End = fitnessPartition.Start + SlidingWindowSize.Value; 96 97 if (fitnessPartition.End - fitnessPartition.Start == SlidingWindowSize.Value) {98 fitnessPartition.Start += SlidingWindowStepWidth.Value;99 }100 91 } 101 92 … … 104 95 SlidingWindowData slidingWindowData; 105 96 if (!results.ContainsKey(SlidingWindowDataResultName)) { 106 slidingWindowData = new SlidingWindowData(FitnessCalculationPartitionParameter.ActualValue, new double[10]); 97 string targetVariable; 98 var classificationProblemData = ProblemDataParameter.ActualValue as IClassificationProblemData; 99 var regressionProblemData = ProblemDataParameter.ActualValue as IRegressionProblemData; 100 if (classificationProblemData != null) targetVariable = classificationProblemData.TargetVariable; 101 else if (regressionProblemData != null) targetVariable = regressionProblemData.TargetVariable; 102 else throw new NotSupportedException(); 103 104 var targetData = ProblemDataParameter.ActualValue.Dataset.GetDoubleValues(targetVariable); 105 slidingWindowData = new SlidingWindowData(FitnessCalculationPartitionParameter.ActualValue, targetData); 107 106 results.Add(new Result(SlidingWindowDataResultName, slidingWindowData)); 108 } else slidingWindowData = (SlidingWindowData)results[SlidingWindowDataResultName] ;107 } else slidingWindowData = (SlidingWindowData)results[SlidingWindowDataResultName].Value; 109 108 110 109 slidingWindowData.SlidingWindowPosition.Start = FitnessCalculationPartitionParameter.ActualValue.Start;
Note: See TracChangeset
for help on using the changeset viewer.