- Timestamp:
- 09/07/09 18:55:50 (15 years ago)
- Location:
- branches/gp-algorithms-refactoring-#720/sources
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj
r2328 r2340 83 83 <Compile Include="ClassificationMeanSquaredErrorEvaluator.cs" /> 84 84 <Compile Include="ConfusionMatrixEvaluator.cs" /> 85 <Compile Include="TargetClassesCalculator.cs" /> 86 <Compile Include="DefaultClassificationAlgorithmOperators.cs" /> 85 87 <Compile Include="GPClassificationEvaluatorBase.cs" /> 86 88 <Compile Include="CrossValidation.cs" /> … … 109 111 <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project> 110 112 <Name>HeuristicLab.Data-3.2</Name> 113 </ProjectReference> 114 <ProjectReference Include="..\..\HeuristicLab.GP.Algorithms\3.2\HeuristicLab.GP.Algorithms-3.2.csproj"> 115 <Project>{3127719F-110E-4558-8845-98559DBB422D}</Project> 116 <Name>HeuristicLab.GP.Algorithms-3.2</Name> 111 117 </ProjectReference> 112 118 <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj"> -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/OffspringSelectionGP.cs
r2335 r2340 25 25 26 26 namespace HeuristicLab.GP.StructureIdentification.Classification { 27 public class OffspringSelectionGP : HeuristicLab.GP. OffspringSelectionGP, IClassificationAlgorithm {27 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, IClassificationAlgorithm { 28 28 29 protected override IOperator CreateBestSolutionProcessor() { 30 IOperator seq = new SequentialProcessor(); 31 seq.AddSubOperator(base.CreateBestSolutionProcessor()); 32 seq.AddSubOperator(StandardGP.BestSolutionProcessor); 33 return seq; 29 protected override IOperator CreateProblemInjector() { 30 return DefaultClassificationAlgorithmOperators.CreateProblemInjector(); 31 } 32 33 protected override IOperator CreatePostProcessingOperator() { 34 return DefaultClassificationAlgorithmOperators.CreatePostProcessingOperator(); 34 35 } 35 36 } -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/StandardGP.cs
r2335 r2340 23 23 using HeuristicLab.Modeling; 24 24 using HeuristicLab.Operators; 25 using System; 25 26 26 27 namespace HeuristicLab.GP.StructureIdentification.Classification { 27 public class StandardGP : HeuristicLab.GP.StandardGP, IClassificationAlgorithm { 28 protected override IOperator CreateBestSolutionProcessor() { 29 IOperator bestSolutionProcessor = BestSolutionProcessor; 30 bestSolutionProcessor.AddSubOperator(base.CreateBestSolutionProcessor()); 31 return bestSolutionProcessor; 32 } 33 34 internal static IOperator BestSolutionProcessor { 35 get { 36 SequentialProcessor seq = new SequentialProcessor(); 37 AccuracyEvaluator trainingAccuracy = new AccuracyEvaluator(); 38 trainingAccuracy.GetVariableInfo("Accuracy").ActualName = "TrainingAccuracy"; 39 trainingAccuracy.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart"; 40 trainingAccuracy.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd"; 41 42 AccuracyEvaluator validationAccuracy = new AccuracyEvaluator(); 43 validationAccuracy.GetVariableInfo("Accuracy").ActualName = "ValidationAccuracy"; 44 validationAccuracy.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 45 validationAccuracy.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 46 47 AccuracyEvaluator testAccuracy = new AccuracyEvaluator(); 48 testAccuracy.GetVariableInfo("Accuracy").ActualName = "TestAccuracy"; 49 testAccuracy.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 50 testAccuracy.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 51 52 ConfusionMatrixEvaluator trainingConfusionMatrix = new ConfusionMatrixEvaluator(); 53 trainingConfusionMatrix.GetVariableInfo("ConfusionMatrix").ActualName = "TrainingConfusionMatrix"; 54 trainingConfusionMatrix.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart"; 55 trainingConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd"; 56 57 ConfusionMatrixEvaluator validationConfusionMatrix = new ConfusionMatrixEvaluator(); 58 validationConfusionMatrix.GetVariableInfo("ConfusionMatrix").ActualName = "ValidationConfusionMatrix"; 59 validationConfusionMatrix.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 60 validationConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 61 62 ConfusionMatrixEvaluator testConfusionMatrix = new ConfusionMatrixEvaluator(); 63 testConfusionMatrix.GetVariableInfo("ConfusionMatrix").ActualName = "TestConfusionMatrix"; 64 testConfusionMatrix.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 65 testConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 66 67 seq.AddSubOperator(trainingAccuracy); 68 seq.AddSubOperator(validationAccuracy); 69 seq.AddSubOperator(testAccuracy); 70 seq.AddSubOperator(trainingConfusionMatrix); 71 seq.AddSubOperator(validationConfusionMatrix); 72 seq.AddSubOperator(testConfusionMatrix); 73 return seq; 74 } 28 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, IClassificationAlgorithm { 29 protected override IOperator CreatePostProcessingOperator() { 30 return DefaultClassificationAlgorithmOperators.CreatePostProcessingOperator(); 75 31 } 76 32 } -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLab.GP.StructureIdentification.TimeSeries-3.3.csproj
r2222 r2340 83 83 <ItemGroup> 84 84 <Compile Include="AveragePercentageChangeEvaluator.cs" /> 85 <Compile Include="DefaultTimeSeriesOperators.cs" /> 85 86 <Compile Include="HeuristicLabGPTimeSeriesPlugin.cs" /> 86 87 <Compile Include="OffspringSelectionGP.cs" /> … … 102 103 <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project> 103 104 <Name>HeuristicLab.Data-3.2</Name> 105 </ProjectReference> 106 <ProjectReference Include="..\..\HeuristicLab.GP.Algorithms\3.2\HeuristicLab.GP.Algorithms-3.2.csproj"> 107 <Project>{3127719F-110E-4558-8845-98559DBB422D}</Project> 108 <Name>HeuristicLab.GP.Algorithms-3.2</Name> 104 109 </ProjectReference> 105 110 <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj"> -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/OffspringSelectionGP.cs
r2335 r2340 23 23 using HeuristicLab.Modeling; 24 24 using HeuristicLab.Operators; 25 using System; 26 using HeuristicLab.Data; 27 using HeuristicLab.GP.Algorithms; 25 28 26 29 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 27 public class OffspringSelectionGP : HeuristicLab.GP.OffspringSelectionGP, ITimeSeriesAlgorithm { 28 public override IOperator ProblemInjector { 29 get { 30 CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator; 31 return algo.OperatorGraph.InitialOperator.SubOperators[1]; 32 } 33 set { 34 CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator; 35 algo.OperatorGraph.InitialOperator.RemoveSubOperator(1); 36 value.Name = "ProblemInjector"; 37 algo.OperatorGraph.InitialOperator.AddSubOperator(value, 1); 38 } 30 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, ITimeSeriesAlgorithm { 31 32 public int MinTimeOffset { 33 get { return GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data; } 34 set { GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data = value; } 35 } 36 37 public int MaxTimeOffset { 38 get { return GetVariableInjector().GetVariable("MaxTimeOffset").GetValue<IntData>().Data; } 39 set { GetVariableInjector().GetVariable("MaxTimeOffset").GetValue<IntData>().Data = value; } 40 } 41 42 public bool UseEstimatedTargetValue { 43 get { return GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data; } 44 set { GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data = value; } 45 } 46 47 protected override IOperator CreateProblemInjector() { 48 return DefaultTimeSeriesOperators.CreateProblemInjector(); 39 49 } 40 50 41 51 protected override IOperator CreateFunctionLibraryInjector() { 42 return newFunctionLibraryInjector();52 return DefaultTimeSeriesOperators.CreateFunctionLibraryInjector(); 43 53 } 44 54 45 protected override IOperator CreateP roblemInjector() {46 return new ProblemInjector();55 protected override IOperator CreatePostProcessingOperator() { 56 return DefaultTimeSeriesOperators.CreatePostProcessingOperator(); 47 57 } 48 58 49 protected override IOperator CreateBestSolutionProcessor() { 50 SequentialProcessor seq = new SequentialProcessor(); 51 seq.AddSubOperator(base.CreateBestSolutionProcessor()); 52 seq.AddSubOperator(StandardGP.BestSolutionProcessor); 53 return seq; 59 protected override VariableInjector CreateGlobalInjector() { 60 VariableInjector injector = base.CreateGlobalInjector(); 61 injector.AddVariable(new HeuristicLab.Core.Variable("MinTimeOffset", new IntData())); 62 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTimeOffset", new IntData())); 63 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData())); 64 return injector; 54 65 } 55 66 56 public override IEditor CreateEditor() {57 return new OffspringSelectionGpEditor(this);58 }59 60 public override IView CreateView() {61 return new OffspringSelectionGpEditor(this);62 }63 67 } 64 68 } -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/StandardGP.cs
r2335 r2340 25 25 using HeuristicLab.Modeling; 26 26 using HeuristicLab.Operators; 27 using System; 27 28 28 29 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 29 public class StandardGP : HeuristicLab.GP.StandardGP, ITimeSeriesAlgorithm { 30 public override IOperator ProblemInjector { 31 get { 32 CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator; 33 return algo.OperatorGraph.InitialOperator.SubOperators[1]; 34 } 35 set { 36 CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator; 37 algo.OperatorGraph.InitialOperator.RemoveSubOperator(1); 38 value.Name = "ProblemInjector"; 39 algo.OperatorGraph.InitialOperator.AddSubOperator(value, 1); 40 } 30 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, ITimeSeriesAlgorithm { 31 public int MinTimeOffset { 32 get { return GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data; } 33 set { GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data = value; } 41 34 } 42 43 protected override IOperator CreateFunctionLibraryInjector() { 44 return new FunctionLibraryInjector(); 35 36 public int MaxTimeOffset { 37 get { return GetVariableInjector().GetVariable("MaxTimeOffset").GetValue<IntData>().Data; } 38 set { GetVariableInjector().GetVariable("MaxTimeOffset").GetValue<IntData>().Data = value; } 39 } 40 41 public bool UseEstimatedTargetValue { 42 get { return GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data; } 43 set { GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data = value; } 45 44 } 46 45 47 46 protected override IOperator CreateProblemInjector() { 48 return newProblemInjector();47 return DefaultTimeSeriesOperators.CreateProblemInjector(); 49 48 } 50 49 51 protected override IOperator CreateBestSolutionProcessor() { 52 SequentialProcessor seq = new SequentialProcessor(); 53 seq.AddSubOperator(base.CreateBestSolutionProcessor()); 54 seq.AddSubOperator(BestSolutionProcessor); 55 return seq; 50 protected override IOperator CreateFunctionLibraryInjector() { 51 return DefaultTimeSeriesOperators.CreateFunctionLibraryInjector(); 56 52 } 57 53 58 p ublic override IEditor CreateEditor() {59 return new StandardGpEditor(this);54 protected override IOperator CreatePostProcessingOperator() { 55 return DefaultTimeSeriesOperators.CreatePostProcessingOperator(); 60 56 } 61 57 62 public override IView CreateView() { 63 return new StandardGpEditor(this); 64 } 65 66 internal static IOperator BestSolutionProcessor { 67 get { 68 SequentialProcessor seq = new SequentialProcessor(); 69 TheilInequalityCoefficientEvaluator trainingTheil = new TheilInequalityCoefficientEvaluator(); 70 trainingTheil.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart"; 71 trainingTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd"; 72 trainingTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TrainingTheilInequalityCoefficient"; 73 trainingTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TrainingTheilInequalityCoefficientBias"; 74 trainingTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TrainingTheilInequalityCoefficientVariance"; 75 trainingTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TrainingTheilInequalityCoefficientCovariance"; 76 77 TheilInequalityCoefficientEvaluator validationTheil = new TheilInequalityCoefficientEvaluator(); 78 validationTheil.GetVariableInfo("SamplesStart").ActualName = "ActualValidationSamplesStart"; 79 validationTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualValidationSamplesEnd"; 80 validationTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "ValidationTheilInequalityCoefficient"; 81 validationTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "ValidationTheilInequalityCoefficientBias"; 82 validationTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "ValidationTheilInequalityCoefficientVariance"; 83 validationTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "ValidationTheilInequalityCoefficientCovariance"; 84 85 TheilInequalityCoefficientEvaluator testTheil = new TheilInequalityCoefficientEvaluator(); 86 testTheil.GetVariableInfo("SamplesStart").ActualName = "ActualTestSamplesStart"; 87 testTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualTestSamplesEnd"; 88 testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient"; 89 testTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TestTheilInequalityCoefficientBias"; 90 testTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TestTheilInequalityCoefficientVariance"; 91 testTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TestTheilInequalityCoefficientCovariance"; 92 93 SimpleEvaluator trainingEvaluator = new SimpleEvaluator(); 94 trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart"; 95 trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd"; 96 trainingEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTraining"; 97 98 SimpleEvaluator validationEvaluator = new SimpleEvaluator(); 99 validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 100 validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 101 validationEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesValidation"; 102 103 SimpleEvaluator testEvaluator = new SimpleEvaluator(); 104 testEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 105 testEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 106 testEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTest"; 107 108 LinechartInjector trainingChartInjector = new LinechartInjector(); 109 trainingChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2; 110 trainingChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesTraining"; 111 trainingChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartTrainingPredictedValues"; 112 113 LinechartInjector validationChartInjector = new LinechartInjector(); 114 validationChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2; 115 validationChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesValidation"; 116 validationChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartValidationPredictedValues"; 117 118 LinechartInjector testChartInjector = new LinechartInjector(); 119 testChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2; 120 testChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesTest"; 121 testChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartTestPredictedValues"; 122 123 seq.AddSubOperator(trainingTheil); 124 seq.AddSubOperator(validationTheil); 125 seq.AddSubOperator(testTheil); 126 seq.AddSubOperator(trainingEvaluator); 127 seq.AddSubOperator(trainingChartInjector); 128 seq.AddSubOperator(validationEvaluator); 129 seq.AddSubOperator(validationChartInjector); 130 seq.AddSubOperator(testEvaluator); 131 seq.AddSubOperator(testChartInjector); 132 133 return seq; 134 } 58 protected override VariableInjector CreateGlobalInjector() { 59 VariableInjector injector = base.CreateGlobalInjector(); 60 injector.AddVariable(new HeuristicLab.Core.Variable("MinTimeOffset", new IntData())); 61 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTimeOffset", new IntData())); 62 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData())); 63 return injector; 135 64 } 136 65 } -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs
r2337 r2340 26 26 using HeuristicLab.Modeling; 27 27 using HeuristicLab.Logging; 28 using HeuristicLab.Selection; 29 using HeuristicLab.Data; 28 30 29 31 namespace HeuristicLab.GP.StructureIdentification { 30 internalstatic class DefaultStructureIdentificationAlgorithmOperators {31 internalstatic IOperator CreateFunctionLibraryInjector() {32 public static class DefaultStructureIdentificationAlgorithmOperators { 33 public static IOperator CreateFunctionLibraryInjector() { 32 34 CombinedOperator op = new CombinedOperator(); 33 35 op.Name = "FunctionLibraryInjector"; 34 36 SequentialProcessor seq = new SequentialProcessor(); 35 37 seq.AddSubOperator(new FunctionLibraryInjector()); 36 seq.AddSubOperator(new HL 2TreeEvaluatorInjector());38 seq.AddSubOperator(new HL3TreeEvaluatorInjector()); 37 39 op.OperatorGraph.AddOperator(seq); 38 40 op.OperatorGraph.InitialOperator = seq; … … 40 42 } 41 43 42 internal static IOperator CreateProblemInjector() { 43 return new ProblemInjector(); 44 } 45 46 internal static IOperator CreateInitialPopulationEvaluator() { 44 public static IOperator CreateProblemInjector() { 45 CombinedOperator op = new CombinedOperator(); 46 op.Name = "ProblemInjector"; 47 SequentialProcessor seq = new SequentialProcessor(); 48 49 seq.AddSubOperator(new ProblemInjector()); 50 DatasetShuffler shuffler = new DatasetShuffler(); 51 shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart"; 52 shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd"; 53 seq.AddSubOperator(shuffler); 54 op.OperatorGraph.AddOperator(seq); 55 op.OperatorGraph.InitialOperator = seq; 56 return op; 57 } 58 59 public static IOperator CreateInitialPopulationEvaluator() { 47 60 MeanSquaredErrorEvaluator eval = new MeanSquaredErrorEvaluator(); 48 61 eval.Name = "Evaluator"; … … 53 66 } 54 67 55 internalstatic IOperator CreateEvaluator() {68 public static IOperator CreateEvaluator() { 56 69 return CreateInitialPopulationEvaluator(); 57 70 } 58 71 59 internalstatic IOperator CreateGenerationStepHook() {72 public static IOperator CreateGenerationStepHook() { 60 73 CombinedOperator op = new CombinedOperator(); 61 74 SequentialProcessor seq = new SequentialProcessor(); … … 91 104 return op; 92 105 } 106 107 public static IOperator CreatePostProcessingOperator() { 108 CombinedOperator op = new CombinedOperator(); 109 op.Name = "ModelAnalyser"; 110 SequentialProcessor seq = new SequentialProcessor(); 111 LeftReducer cleanUp = new LeftReducer(); 112 cleanUp.Name = "Reset Population"; 113 seq.AddSubOperator(cleanUp); 114 115 SolutionExtractor extractor = new SolutionExtractor(); 116 extractor.GetVariableInfo("Scope").ActualName = "BestValidationSolution"; 117 SequentialSubScopesProcessor seqSubScopeProc = new SequentialSubScopesProcessor(); 118 SequentialProcessor solutionProc = new SequentialProcessor(); 119 120 seq.AddSubOperator(extractor); 121 seq.AddSubOperator(seqSubScopeProc); 122 seqSubScopeProc.AddSubOperator(solutionProc); 123 124 HL3TreeEvaluatorInjector evaluatorInjector = new HL3TreeEvaluatorInjector(); 125 evaluatorInjector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(1000.0))); 126 evaluatorInjector.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 127 128 #region MSE 129 MeanSquaredErrorEvaluator trainingMseEvaluator = new MeanSquaredErrorEvaluator(); 130 trainingMseEvaluator.Name = "TrainingMseEvaluator"; 131 trainingMseEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 132 trainingMseEvaluator.GetVariableInfo("MSE").ActualName = "TrainingMSE"; 133 trainingMseEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 134 trainingMseEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 135 MeanSquaredErrorEvaluator validationMseEvaluator = new MeanSquaredErrorEvaluator(); 136 validationMseEvaluator.Name = "ValidationMseEvaluator"; 137 validationMseEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 138 validationMseEvaluator.GetVariableInfo("MSE").ActualName = "ValidationMSE"; 139 validationMseEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 140 validationMseEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 141 MeanSquaredErrorEvaluator testMseEvaluator = new MeanSquaredErrorEvaluator(); 142 testMseEvaluator.Name = "TestMeanSquaredErrorEvaluator"; 143 testMseEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 144 testMseEvaluator.GetVariableInfo("MSE").ActualName = "TestMSE"; 145 testMseEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 146 testMseEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 147 #endregion 148 #region MAPE 149 MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator(); 150 trainingMapeEvaluator.Name = "TrainingMapeEvaluator"; 151 trainingMapeEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 152 trainingMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TrainingMAPE"; 153 trainingMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 154 trainingMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 155 MeanAbsolutePercentageErrorEvaluator validationMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator(); 156 validationMapeEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 157 validationMapeEvaluator.Name = "ValidationMapeEvaluator"; 158 validationMapeEvaluator.GetVariableInfo("MAPE").ActualName = "ValidationMAPE"; 159 validationMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 160 validationMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 161 MeanAbsolutePercentageErrorEvaluator testMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator(); 162 testMapeEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 163 testMapeEvaluator.Name = "TestMapeEvaluator"; 164 testMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TestMAPE"; 165 testMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 166 testMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 167 #endregion 168 #region MAPRE 169 MeanAbsolutePercentageOfRangeErrorEvaluator trainingMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator(); 170 trainingMapreEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 171 trainingMapreEvaluator.Name = "TrainingMapreEvaluator"; 172 trainingMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TrainingMAPRE"; 173 trainingMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 174 trainingMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 175 MeanAbsolutePercentageOfRangeErrorEvaluator validationMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator(); 176 validationMapreEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 177 validationMapreEvaluator.Name = "ValidationMapreEvaluator"; 178 validationMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "ValidationMAPRE"; 179 validationMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 180 validationMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 181 MeanAbsolutePercentageOfRangeErrorEvaluator testMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator(); 182 testMapreEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 183 testMapreEvaluator.Name = "TestMapreEvaluator"; 184 testMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TestMAPRE"; 185 testMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 186 testMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 187 #endregion MAPRE 188 #region R2 189 CoefficientOfDeterminationEvaluator trainingR2Evaluator = new CoefficientOfDeterminationEvaluator(); 190 trainingR2Evaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 191 trainingR2Evaluator.Name = "TrainingR2Evaluator"; 192 trainingR2Evaluator.GetVariableInfo("R2").ActualName = "TrainingR2"; 193 trainingR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 194 trainingR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 195 CoefficientOfDeterminationEvaluator validationR2Evaluator = new CoefficientOfDeterminationEvaluator(); 196 validationR2Evaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 197 validationR2Evaluator.Name = "ValidationR2Evaluator"; 198 validationR2Evaluator.GetVariableInfo("R2").ActualName = "ValidationR2"; 199 validationR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 200 validationR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 201 CoefficientOfDeterminationEvaluator testR2Evaluator = new CoefficientOfDeterminationEvaluator(); 202 testR2Evaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 203 testR2Evaluator.Name = "TestR2Evaluator"; 204 testR2Evaluator.GetVariableInfo("R2").ActualName = "TestR2"; 205 testR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 206 testR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 207 #endregion 208 #region VAF 209 VarianceAccountedForEvaluator trainingVAFEvaluator = new VarianceAccountedForEvaluator(); 210 trainingVAFEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 211 trainingVAFEvaluator.Name = "TrainingVAFEvaluator"; 212 trainingVAFEvaluator.GetVariableInfo("VAF").ActualName = "TrainingVAF"; 213 trainingVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 214 trainingVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 215 VarianceAccountedForEvaluator validationVAFEvaluator = new VarianceAccountedForEvaluator(); 216 validationVAFEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 217 validationVAFEvaluator.Name = "ValidationVAFEvaluator"; 218 validationVAFEvaluator.GetVariableInfo("VAF").ActualName = "ValidationVAF"; 219 validationVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 220 validationVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 221 VarianceAccountedForEvaluator testVAFEvaluator = new VarianceAccountedForEvaluator(); 222 testVAFEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 223 testVAFEvaluator.Name = "TestVAFEvaluator"; 224 testVAFEvaluator.GetVariableInfo("VAF").ActualName = "TestVAF"; 225 testVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 226 testVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 227 #endregion 228 229 solutionProc.AddSubOperator(evaluatorInjector); 230 solutionProc.AddSubOperator(trainingMseEvaluator); 231 solutionProc.AddSubOperator(validationMseEvaluator); 232 solutionProc.AddSubOperator(testMseEvaluator); 233 solutionProc.AddSubOperator(trainingMapeEvaluator); 234 solutionProc.AddSubOperator(validationMapeEvaluator); 235 solutionProc.AddSubOperator(testMapeEvaluator); 236 solutionProc.AddSubOperator(trainingMapreEvaluator); 237 solutionProc.AddSubOperator(validationMapreEvaluator); 238 solutionProc.AddSubOperator(testMapreEvaluator); 239 solutionProc.AddSubOperator(trainingR2Evaluator); 240 solutionProc.AddSubOperator(validationR2Evaluator); 241 solutionProc.AddSubOperator(testR2Evaluator); 242 solutionProc.AddSubOperator(trainingVAFEvaluator); 243 solutionProc.AddSubOperator(validationVAFEvaluator); 244 solutionProc.AddSubOperator(testVAFEvaluator); 245 246 #region variable impacts 247 // calculate and set variable impacts 248 VariableNamesExtractor namesExtractor = new VariableNamesExtractor(); 249 namesExtractor.GetVariableInfo("VariableNames").ActualName = "InputVariableNames"; 250 PredictorBuilder predictorBuilder = new PredictorBuilder(); 251 predictorBuilder.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator"; 252 253 VariableEvaluationImpactCalculator evaluationImpactCalculator = new VariableEvaluationImpactCalculator(); 254 evaluationImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 255 evaluationImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 256 VariableQualityImpactCalculator qualityImpactCalculator = new VariableQualityImpactCalculator(); 257 qualityImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 258 qualityImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 259 260 solutionProc.AddSubOperator(namesExtractor); 261 solutionProc.AddSubOperator(predictorBuilder); 262 solutionProc.AddSubOperator(evaluationImpactCalculator); 263 solutionProc.AddSubOperator(qualityImpactCalculator); 264 #endregion 265 266 op.OperatorGraph.AddOperator(seq); 267 op.OperatorGraph.InitialOperator = seq; 268 return op; 269 } 270 271 public static IAnalyzerModel CreateGPModel(IScope bestModelScope) { 272 IAnalyzerModel model = new AnalyzerModel(); 273 model.Predictor = bestModelScope.GetVariableValue<IPredictor>("Predictor", true); 274 Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true); 275 model.Dataset = ds; 276 model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data); 277 model.TrainingSamplesStart = bestModelScope.GetVariableValue<IntData>("TrainingSamplesStart", true).Data; 278 model.TrainingSamplesEnd = bestModelScope.GetVariableValue<IntData>("TrainingSamplesEnd", true).Data; 279 model.ValidationSamplesStart = bestModelScope.GetVariableValue<IntData>("ValidationSamplesStart", true).Data; 280 model.ValidationSamplesEnd = bestModelScope.GetVariableValue<IntData>("ValidationSamplesEnd", true).Data; 281 model.TestSamplesStart = bestModelScope.GetVariableValue<IntData>("TestSamplesStart", true).Data; 282 model.TestSamplesEnd = bestModelScope.GetVariableValue<IntData>("TestSamplesEnd", true).Data; 283 284 model.TrainingMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("TrainingMSE", false).Data; 285 model.ValidationMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("ValidationMSE", false).Data; 286 model.TestMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("TestMSE", false).Data; 287 model.TrainingCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TrainingR2", false).Data; 288 model.ValidationCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data; 289 model.TestCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TestR2", false).Data; 290 model.TrainingMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TrainingMAPE", false).Data; 291 model.ValidationMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data; 292 model.TestMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data; 293 model.TrainingMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TrainingMAPRE", false).Data; 294 model.ValidationMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data; 295 model.TestMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data; 296 model.TrainingVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TrainingVAF", false).Data; 297 model.ValidationVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data; 298 model.TestVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data; 299 300 ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false); 301 ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false); 302 foreach (ItemList row in evaluationImpacts) { 303 string variableName = ((StringData)row[0]).Data; 304 double impact = ((DoubleData)row[1]).Data; 305 model.SetVariableEvaluationImpact(variableName, impact); 306 model.AddInputVariable(variableName); 307 } 308 foreach (ItemList row in qualityImpacts) { 309 string variableName = ((StringData)row[0]).Data; 310 double impact = ((DoubleData)row[1]).Data; 311 model.SetVariableQualityImpact(variableName, impact); 312 model.AddInputVariable(variableName); 313 } 314 315 return model; 316 } 93 317 } 94 318 } -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs
r2328 r2340 36 36 AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); 37 37 AddVariableInfo(new VariableInfo("SamplesEnd", "End index of samples in dataset to evaluate", typeof(IntData), VariableKind.In)); 38 AddVariableInfo(new VariableInfo("UseEstimatedTargetValue", " Wether to use the original (measured) or the estimated (calculated) value for the target variable for autoregressive modelling", typeof(BoolData), VariableKind.In));38 AddVariableInfo(new VariableInfo("UseEstimatedTargetValue", "(optional) Wether to use the original (measured) or the estimated (calculated) value for the target variable for autoregressive modelling", typeof(BoolData), VariableKind.In)); 39 39 } 40 40 … … 47 47 int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data; 48 48 int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data; 49 bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, true).Data; 49 BoolData useEstimatedValuesData = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, true, false); 50 bool useEstimatedValues = useEstimatedValuesData == null ? false : useEstimatedValuesData.Data; 50 51 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 51 52 evaluator.PrepareForEvaluation(dataset, gpModel.FunctionTree); -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj
r2337 r2340 84 84 <Compile Include="BaseClasses\FunctionTreeBase.cs" /> 85 85 <Compile Include="BaseClasses\TreeEvaluatorBase.cs" /> 86 <Compile Include=" IStructureIdentificationAlgorithm.cs" />86 <Compile Include="DefaultStructureIdentificationOperators.cs" /> 87 87 <Compile Include="HL3TreeEvaluatorInjector.cs" /> 88 88 <Compile Include="HL2TreeEvaluatorInjector.cs" /> -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGP.cs
r2337 r2340 30 30 using HeuristicLab.Selection.OffspringSelection; 31 31 using HeuristicLab.Modeling; 32 using HeuristicLab.DataAnalysis; 32 33 33 34 namespace HeuristicLab.GP.StructureIdentification { 34 public class OffspringSelectionGP : HeuristicLab.GP.Algorithms.OffspringSelectionGP {35 public class OffspringSelectionGP : HeuristicLab.GP.Algorithms.OffspringSelectionGP, IAlgorithm { 35 36 public override string Name { get { return "OffspringSelectionGP - StructureIdentification"; } } 36 37 37 public HeuristicLab.DataAnalysis.Dataset Dataset { 38 get { 39 throw new NotImplementedException(); 40 } 41 set { 42 throw new NotImplementedException(); 43 } 38 public virtual int TargetVariable { 39 get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; } 40 set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; } 44 41 } 45 42 46 public int TargetVariable { 47 get { 48 throw new NotImplementedException(); 49 } 50 set { 51 throw new NotImplementedException(); 52 } 43 public virtual Dataset Dataset { 44 get { return ProblemInjector.GetVariableValue<Dataset>("Dataset", null, false); } 45 set { ProblemInjector.GetVariable("Dataset").Value = value; } 53 46 } 54 47 55 public IAnalyzerModel Model { 56 get { throw new NotImplementedException(); } 48 public virtual IAnalyzerModel Model { 49 get { 50 if (!Engine.Terminated) 51 throw new InvalidOperationException("The algorithm is still running. Wait until the algorithm is terminated to retrieve the result."); 52 else 53 return CreateGPModel(); 54 } 57 55 } 58 56 … … 60 58 get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; } 61 59 set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; } 60 } 61 62 public override IOperator ProblemInjector { 63 get { return GetProblemInjector().OperatorGraph.InitialOperator.SubOperators[0]; } 64 set { 65 value.Name = "ProblemInjector"; 66 CombinedOperator problemInjector = GetProblemInjector(); 67 problemInjector.OperatorGraph.RemoveOperator(ProblemInjector.Guid); 68 problemInjector.OperatorGraph.AddOperator(value); 69 problemInjector.OperatorGraph.InitialOperator.AddSubOperator(value, 0); 70 } 62 71 } 63 72 … … 90 99 protected override VariableInjector CreateGlobalInjector() { 91 100 VariableInjector injector = base.CreateGlobalInjector(); 92 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));93 101 injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData())); 94 102 return injector; 95 103 } 104 96 105 97 106 protected override IOperator CreateLoggingOperator() { … … 123 132 } 124 133 134 protected override IOperator CreatePostProcessingOperator() { 135 return DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator(); 136 } 137 125 138 public override object Clone(IDictionary<Guid, object> clonedObjects) { 126 139 OffspringSelectionGP clone = (OffspringSelectionGP)base.Clone(clonedObjects); … … 128 141 return clone; 129 142 } 143 144 protected CombinedOperator GetProblemInjector() { 145 return (CombinedOperator)GetInitializationOperator().SubOperators[0]; 146 } 147 148 private IAnalyzerModel CreateGPModel() { 149 IScope bestModelScope = Engine.GlobalScope.SubScopes[0]; 150 return DefaultStructureIdentificationAlgorithmOperators.CreateGPModel(bestModelScope); 151 } 130 152 } 131 153 } -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs
r2337 r2340 29 29 using System.Collections.Generic; 30 30 using System; 31 using HeuristicLab.DataAnalysis; 31 32 32 33 namespace HeuristicLab.GP.StructureIdentification { … … 35 36 public override string Name { get { return "StandardGP - StructureIdentification"; } } 36 37 37 public HeuristicLab.DataAnalysis.Dataset Dataset { 38 get { 39 throw new NotImplementedException(); 40 } 41 set { 42 throw new NotImplementedException(); 43 } 38 public virtual int TargetVariable { 39 get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; } 40 set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; } 44 41 } 45 42 46 public int TargetVariable { 47 get { 48 throw new NotImplementedException(); 49 } 50 set { 51 throw new NotImplementedException(); 52 } 43 public virtual Dataset Dataset { 44 get { return ProblemInjector.GetVariableValue<Dataset>("Dataset", null, false); } 45 set { ProblemInjector.GetVariable("Dataset").Value = value; } 53 46 } 54 47 55 public IAnalyzerModel Model { 56 get { throw new NotImplementedException(); } 48 public virtual IAnalyzerModel Model { 49 get { 50 if (!Engine.Terminated) 51 throw new InvalidOperationException("The algorithm is still running. Wait until the algorithm is terminated to retrieve the result."); 52 else 53 return CreateGPModel(); 54 } 57 55 } 58 56 … … 60 58 get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; } 61 59 set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; } 60 } 61 62 public override IOperator ProblemInjector { 63 get { return GetProblemInjector().OperatorGraph.InitialOperator.SubOperators[0]; } 64 set { 65 value.Name = "ProblemInjector"; 66 CombinedOperator problemInjector = GetProblemInjector(); 67 problemInjector.OperatorGraph.RemoveOperator(ProblemInjector.Guid); 68 problemInjector.OperatorGraph.AddOperator(value); 69 problemInjector.OperatorGraph.InitialOperator.AddSubOperator(value, 0); 70 } 62 71 } 63 72 … … 81 90 82 91 protected override IOperator CreateEvaluationOperator() { 83 return DefaultStructureIdentificationAlgorithmOperators.CreateEvaluator(); 92 return DefaultStructureIdentificationAlgorithmOperators.CreateEvaluator(); 84 93 } 85 94 … … 91 100 protected override VariableInjector CreateGlobalInjector() { 92 101 VariableInjector injector = base.CreateGlobalInjector(); 93 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));94 102 injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData())); 95 103 return injector; … … 123 131 } 124 132 133 protected override IOperator CreatePostProcessingOperator() { 134 return DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator(); 135 } 136 125 137 public override object Clone(IDictionary<Guid, object> clonedObjects) { 126 138 StandardGP clone = (StandardGP)base.Clone(clonedObjects); … … 128 140 return clone; 129 141 } 142 143 protected CombinedOperator GetProblemInjector() { 144 return (CombinedOperator)GetInitializationOperator().SubOperators[0]; 145 } 146 147 private IAnalyzerModel CreateGPModel() { 148 IScope bestModelScope = Engine.GlobalScope.SubScopes[0]; 149 return DefaultStructureIdentificationAlgorithmOperators.CreateGPModel(bestModelScope); 150 } 130 151 } 131 152 } -
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs
r2328 r2340 125 125 injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(1000))); 126 126 injector.AddVariable(new HeuristicLab.Core.Variable("TotalEvaluatedNodes", new DoubleData(0))); 127 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData(false)));128 127 129 128 return injector;
Note: See TracChangeset
for help on using the changeset viewer.