- Timestamp:
- 03/04/09 16:12:31 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 6 edited
- 4 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.DataAnalysis/DatasetShuffler.cs
r1244 r1245 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.GP.StructureIdentification;29 using HeuristicLab.DataAnalysis;30 28 using HeuristicLab.Random; 31 29 32 namespace HeuristicLab. GP.StructureIdentification.Classification{30 namespace HeuristicLab.DataAnalysis { 33 31 public class DatasetShuffler : OperatorBase { 34 32 public DatasetShuffler() -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.DataAnalysis/HeuristicLab.DataAnalysis.csproj
r894 r1245 71 71 <Compile Include="Dataset.cs" /> 72 72 <Compile Include="DatasetParser.cs" /> 73 <Compile Include="DatasetShuffler.cs" /> 73 74 <Compile Include="DatasetView.cs"> 74 75 <SubType>UserControl</SubType> … … 97 98 <Name>HeuristicLab.Data</Name> 98 99 </ProjectReference> 100 <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj"> 101 <Project>{A9983BA2-B3B2-475E-8E2C-62050B71D1C5}</Project> 102 <Name>HeuristicLab.Operators</Name> 103 </ProjectReference> 99 104 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 100 105 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 101 106 <Name>HeuristicLab.PluginInfrastructure</Name> 107 </ProjectReference> 108 <ProjectReference Include="..\HeuristicLab.Random\HeuristicLab.Random.csproj"> 109 <Project>{47019A74-F7F7-482E-83AA-D3F4F777E879}</Project> 110 <Name>HeuristicLab.Random</Name> 102 111 </ProjectReference> 103 112 </ItemGroup> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.Classification/HeuristicLab.GP.StructureIdentification.Classification.csproj
r1051 r1245 67 67 <Compile Include="ClassificationMeanSquaredErrorEvaluator.cs" /> 68 68 <Compile Include="ConfusionMatrixEvaluator.cs" /> 69 <Compile Include="DatasetShuffler.cs" />70 69 <Compile Include="GPClassificationEvaluatorBase.cs" /> 71 70 <Compile Include="CrossValidation.cs" /> … … 73 72 <Compile Include="MulticlassModeller.cs" /> 74 73 <Compile Include="MulticlassOneVsOneAnalyzer.cs" /> 74 <Compile Include="OffspringSelectionGP.cs" /> 75 75 <Compile Include="Properties\AssemblyInfo.cs" /> 76 76 <Compile Include="ROCAnalyzer.cs" /> 77 <Compile Include="StandardGP.cs" /> 77 78 </ItemGroup> 78 79 <ItemGroup> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.Classification/OffspringSelectionGP.cs
r1244 r1245 28 28 using System.Diagnostics; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.Operators;31 30 using HeuristicLab.Random; 32 using HeuristicLab.Selection;33 using HeuristicLab.Logging;34 31 using HeuristicLab.Data; 35 using HeuristicLab.Operators.Programmable;36 using HeuristicLab.Selection.OffspringSelection;37 32 38 namespace HeuristicLab.GP.StructureIdentification { 39 public class OffspringSelectionGP : StandardGP { 33 namespace HeuristicLab.GP.StructureIdentification.Classification { 34 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP { 35 protected override IOperator CreateBestSolutionProcessor() { 36 IOperator seq = base.CreateBestSolutionProcessor(); 37 AccuracyEvaluator trainingAccuracy = new AccuracyEvaluator(); 38 trainingAccuracy.GetVariableInfo("Accuracy").ActualName = "TrainingAccuracy"; 39 trainingAccuracy.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 40 trainingAccuracy.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 40 41 41 private IntData maxEvaluatedSolutions = new IntData(); 42 public int MaxEvaluatedSolutions { 43 get { return maxEvaluatedSolutions.Data; } 44 set { maxEvaluatedSolutions.Data = value; } 45 } 42 AccuracyEvaluator validationAccuracy = new AccuracyEvaluator(); 43 validationAccuracy.GetVariableInfo("Accuracy").ActualName = "ValidationAccuracy"; 44 validationAccuracy.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 45 validationAccuracy.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 46 46 47 private DoubleData selectionPressureLimit = new DoubleData(); 48 public double SelectionPressureLimit { 49 get { return selectionPressureLimit.Data; } 50 set { selectionPressureLimit.Data = value; } 51 } 47 AccuracyEvaluator testAccuracy = new AccuracyEvaluator(); 48 testAccuracy.GetVariableInfo("Accuracy").ActualName = "TestAccuracy"; 49 testAccuracy.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 50 testAccuracy.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 52 51 53 private DoubleData comparisonFactor = new DoubleData(); 54 public double ComparisonFactor { 55 get { return comparisonFactor.Data; } 56 set { comparisonFactor.Data = value; } 57 } 52 ConfusionMatrixEvaluator trainingConfusionMatrix = new ConfusionMatrixEvaluator(); 53 trainingConfusionMatrix.GetVariableInfo("ConfusionMatrix").ActualName = "TrainingConfusionMatrix"; 54 trainingConfusionMatrix.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 55 trainingConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 58 56 59 private DoubleData successRatioLimit = new DoubleData(); 60 public double SuccessRatioLimit { 61 get { return successRatioLimit.Data; } 62 set { successRatioLimit.Data = value; } 63 } 57 ConfusionMatrixEvaluator validationConfusionMatrix = new ConfusionMatrixEvaluator(); 58 validationConfusionMatrix.GetVariableInfo("ConfusionMatrix").ActualName = "ValidationConfusionMatrix"; 59 validationConfusionMatrix.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 60 validationConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 64 61 65 public OffspringSelectionGP() : base() { 66 PopulationSize = 1000; 67 Parents = 20; 68 MaxEvaluatedSolutions = 1000000; 69 SelectionPressureLimit = 300; 70 ComparisonFactor = 1.0; 71 SuccessRatioLimit = 1.0; 72 } 62 ConfusionMatrixEvaluator testConfusionMatrix = new ConfusionMatrixEvaluator(); 63 testConfusionMatrix.GetVariableInfo("ConfusionMatrix").ActualName = "TestConfusionMatrix"; 64 testConfusionMatrix.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 65 testConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 73 66 74 internal override IOperator CreateGlobalInjector() { 75 VariableInjector injector = (VariableInjector)base.CreateGlobalInjector(); 76 injector.RemoveVariable("TournamentSize"); 77 injector.RemoveVariable("MaxGenerations"); 78 injector.AddVariable(new HeuristicLab.Core.Variable("MaxEvaluatedSolutions", maxEvaluatedSolutions)); 79 injector.AddVariable(new HeuristicLab.Core.Variable("ComparisonFactor", comparisonFactor)); 80 injector.AddVariable(new HeuristicLab.Core.Variable("SelectionPressureLimit", selectionPressureLimit)); 81 injector.AddVariable(new HeuristicLab.Core.Variable("SuccessRatioLimit", successRatioLimit)); 82 return injector; 83 } 84 85 internal override IOperator CreateSelector() { 86 CombinedOperator selector = new CombinedOperator(); 87 selector.Name = "Selector"; 88 SequentialProcessor seq = new SequentialProcessor(); 89 seq.Name = "Selector"; 90 EmptyOperator emptyOp = new EmptyOperator(); 91 ProportionalSelector femaleSelector = new ProportionalSelector(); 92 femaleSelector.GetVariableInfo("Selected").ActualName = "Parents"; 93 femaleSelector.GetVariableValue<BoolData>("CopySelected", null, false).Data = true; 94 95 RandomSelector maleSelector = new RandomSelector(); 96 maleSelector.GetVariableInfo("Selected").ActualName = "Parents"; 97 maleSelector.GetVariableValue<BoolData>("CopySelected", null, false).Data = true; 98 SequentialSubScopesProcessor seqSubScopesProc = new SequentialSubScopesProcessor(); 99 RightChildReducer rightChildReducer = new RightChildReducer(); 100 SubScopesMixer mixer = new SubScopesMixer(); 101 102 seqSubScopesProc.AddSubOperator(femaleSelector); 103 seqSubScopesProc.AddSubOperator(emptyOp); 104 105 seq.AddSubOperator(maleSelector); 106 seq.AddSubOperator(seqSubScopesProc); 107 seq.AddSubOperator(rightChildReducer); 108 seq.AddSubOperator(mixer); 109 110 selector.OperatorGraph.AddOperator(seq); 111 selector.OperatorGraph.InitialOperator = seq; 112 return selector; 113 } 114 115 internal override IOperator CreateChildCreater() { 116 CombinedOperator childCreater = new CombinedOperator(); 117 childCreater.Name = "Create children"; 118 SequentialProcessor seq = new SequentialProcessor(); 119 SequentialProcessor offspringSelectionSeq = new SequentialProcessor(); 120 OperatorExtractor selector = new OperatorExtractor(); 121 selector.Name = "Selector (extr.)"; 122 selector.GetVariableInfo("Operator").ActualName = "Selector"; 123 SequentialSubScopesProcessor seqSubScopesProc = new SequentialSubScopesProcessor(); 124 EmptyOperator emptyOp = new EmptyOperator(); 125 OffspringSelector offspringSelector = new OffspringSelector(); 126 OffspringAnalyzer offspringAnalyzer = new OffspringAnalyzer(); 127 SequentialProcessor selectedProc = new SequentialProcessor(); 128 OperatorExtractor crossover = new OperatorExtractor(); 129 crossover.Name = "Crossover (extr.)"; 130 crossover.GetVariableInfo("Operator").ActualName = "Crossover"; 131 UniformSequentialSubScopesProcessor individualProc = new UniformSequentialSubScopesProcessor(); 132 SequentialProcessor individualSeqProc = new SequentialProcessor(); 133 StochasticBranch cond = new StochasticBranch(); 134 cond.GetVariableInfo("Probability").ActualName = "MutationRate"; 135 OperatorExtractor manipulator = new OperatorExtractor(); 136 manipulator.Name = "Manipulator (extr.)"; 137 manipulator.GetVariableInfo("Operator").ActualName = "Manipulator"; 138 OperatorExtractor evaluator = new OperatorExtractor(); 139 evaluator.Name = "Evaluator (extr.)"; 140 evaluator.GetVariableInfo("Operator").ActualName = "Evaluator"; 141 Counter evalCounter = new Counter(); 142 evalCounter.GetVariableInfo("Value").ActualName = "EvaluatedSolutions"; 143 144 Sorter sorter = new Sorter(); 145 sorter.GetVariableInfo("Descending").ActualName = "Maximization"; 146 sorter.GetVariableInfo("Value").ActualName = "Quality"; 147 148 UniformSequentialSubScopesProcessor validationEvaluator = new UniformSequentialSubScopesProcessor(); 149 MeanSquaredErrorEvaluator validationQualityEvaluator = new MeanSquaredErrorEvaluator(); 150 validationQualityEvaluator.Name = "ValidationMeanSquaredErrorEvaluator"; 151 validationQualityEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality"; 152 validationQualityEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 153 validationQualityEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 154 155 seqSubScopesProc.AddSubOperator(emptyOp); 156 seqSubScopesProc.AddSubOperator(offspringAnalyzer); 157 158 seq.AddSubOperator(offspringSelectionSeq); 159 offspringSelectionSeq.AddSubOperator(selector); 160 offspringSelectionSeq.AddSubOperator(seqSubScopesProc); 161 offspringSelectionSeq.AddSubOperator(offspringSelector); 162 offspringSelector.AddSubOperator(offspringSelectionSeq); 163 164 offspringAnalyzer.AddSubOperator(selectedProc); 165 selectedProc.AddSubOperator(crossover); 166 selectedProc.AddSubOperator(individualProc); 167 individualProc.AddSubOperator(individualSeqProc); 168 individualSeqProc.AddSubOperator(cond); 169 cond.AddSubOperator(manipulator); 170 individualSeqProc.AddSubOperator(evaluator); 171 individualSeqProc.AddSubOperator(evalCounter); 172 173 SequentialSubScopesProcessor seqSubScopesProc2 = new SequentialSubScopesProcessor(); 174 seq.AddSubOperator(seqSubScopesProc2); 175 seqSubScopesProc2.AddSubOperator(emptyOp); 176 177 SequentialProcessor newGenProc = new SequentialProcessor(); 178 newGenProc.AddSubOperator(sorter); 179 newGenProc.AddSubOperator(validationEvaluator); 180 seqSubScopesProc2.AddSubOperator(newGenProc); 181 182 validationEvaluator.AddSubOperator(validationQualityEvaluator); 183 184 childCreater.OperatorGraph.AddOperator(seq); 185 childCreater.OperatorGraph.InitialOperator = seq; 186 return childCreater; 187 } 188 189 internal override IOperator CreateLoopCondition(IOperator loop) { 190 SequentialProcessor seq = new SequentialProcessor(); 191 seq.Name = "Loop Condition"; 192 LessThanComparator generationsComparator = new LessThanComparator(); 193 generationsComparator.GetVariableInfo("LeftSide").ActualName = "EvaluatedSolutions"; 194 generationsComparator.GetVariableInfo("RightSide").ActualName = "MaxEvaluatedSolutions"; 195 generationsComparator.GetVariableInfo("Result").ActualName = "EvaluatedSolutionsCondition"; 196 197 LessThanComparator selPresComparator = new LessThanComparator(); 198 selPresComparator.GetVariableInfo("LeftSide").ActualName = "SelectionPressure"; 199 selPresComparator.GetVariableInfo("RightSide").ActualName = "SelectionPressureLimit"; 200 selPresComparator.GetVariableInfo("Result").ActualName = "SelectionPressureCondition"; 201 202 ConditionalBranch generationsCond = new ConditionalBranch(); 203 generationsCond.GetVariableInfo("Condition").ActualName = "EvaluatedSolutionsCondition"; 204 205 ConditionalBranch selPresCond = new ConditionalBranch(); 206 selPresCond.GetVariableInfo("Condition").ActualName = "SelectionPressureCondition"; 207 208 seq.AddSubOperator(generationsComparator); 209 seq.AddSubOperator(selPresComparator); 210 seq.AddSubOperator(generationsCond); 211 generationsCond.AddSubOperator(selPresCond); 212 selPresCond.AddSubOperator(loop); 213 67 seq.AddSubOperator(trainingAccuracy); 68 seq.AddSubOperator(validationAccuracy); 69 seq.AddSubOperator(testAccuracy); 214 70 return seq; 215 71 } 216 217 internal override IOperator CreateLoggingOperator() {218 CombinedOperator loggingOperator = new CombinedOperator();219 loggingOperator.Name = "Logging";220 SequentialProcessor seq = new SequentialProcessor();221 222 DataCollector collector = new DataCollector();223 ItemList<StringData> names = collector.GetVariable("VariableNames").GetValue<ItemList<StringData>>();224 names.Add(new StringData("BestQuality"));225 names.Add(new StringData("AverageQuality"));226 names.Add(new StringData("WorstQuality"));227 names.Add(new StringData("BestValidationQuality"));228 names.Add(new StringData("AverageValidationQuality"));229 names.Add(new StringData("WorstValidationQuality"));230 names.Add(new StringData("EvaluatedSolutions"));231 names.Add(new StringData("SelectionPressure"));232 QualityLogger qualityLogger = new QualityLogger();233 QualityLogger validationQualityLogger = new QualityLogger();234 validationQualityLogger.Name = "ValidationQualityLogger";235 validationQualityLogger.GetVariableInfo("Quality").ActualName = "ValidationQuality";236 validationQualityLogger.GetVariableInfo("QualityLog").ActualName = "ValidationQualityLog";237 238 seq.AddSubOperator(collector);239 seq.AddSubOperator(qualityLogger);240 seq.AddSubOperator(validationQualityLogger);241 242 loggingOperator.OperatorGraph.AddOperator(seq);243 loggingOperator.OperatorGraph.InitialOperator = seq;244 return loggingOperator;245 }246 247 248 public override IEditor CreateEditor() {249 return new OffspringSelectionGpEditor(this);250 }251 252 public override IView CreateView() {253 return new OffspringSelectionGpEditor(this);254 }255 256 public override object Clone(IDictionary<Guid, object> clonedObjects) {257 OffspringSelectionGP clone = (OffspringSelectionGP)base.Clone(clonedObjects);258 clone.SelectionPressureLimit = SelectionPressureLimit;259 clone.SuccessRatioLimit = SuccessRatioLimit;260 clone.ComparisonFactor = ComparisonFactor;261 return clone;262 }263 264 #region SetReferences Method265 private void SetReferences() {266 // SGA267 CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;268 // SequentialProcessor in SGA269 SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;270 // RandomInjector271 RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];272 // VariableInjector273 VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];274 selectionPressureLimit = vi.GetVariable("SelectionPressureLimit").GetValue<DoubleData>();275 successRatioLimit = vi.GetVariable("SuccessRatioLimit").GetValue<DoubleData>();276 comparisonFactor = vi.GetVariable("ComparisonFactor").GetValue<DoubleData>();277 }278 #endregion279 280 #region Persistence Methods281 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {282 XmlNode node = base.GetXmlNode(name, document, persistedObjects);283 return node;284 }285 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {286 base.Populate(node, restoredObjects);287 SetReferences();288 }289 #endregion290 72 } 291 73 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.Classification/StandardGP.cs
r1244 r1245 28 28 using System.Diagnostics; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.Operators;31 30 using HeuristicLab.Random; 32 using HeuristicLab.Selection;33 using HeuristicLab.Logging;34 31 using HeuristicLab.Data; 35 using HeuristicLab.Operators.Programmable;36 32 37 namespace HeuristicLab.GP.StructureIdentification { 38 public class StandardGP : AlgorithmBase, IEditable { 33 namespace HeuristicLab.GP.StructureIdentification.Classification { 34 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP { 35 protected override IOperator CreateBestSolutionProcessor() { 36 IOperator seq = base.CreateBestSolutionProcessor(); 37 AccuracyEvaluator trainingAccuracy = new AccuracyEvaluator(); 38 trainingAccuracy.GetVariableInfo("Accuracy").ActualName = "TrainingAccuracy"; 39 trainingAccuracy.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 40 trainingAccuracy.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 39 41 40 private IntData maxGenerations = new IntData(); 41 public int MaxGenerations { 42 get { return maxGenerations.Data; } 43 set { maxGenerations.Data = value; } 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 = "TrainingSamplesStart"; 55 trainingConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 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 return seq; 44 71 } 45 46 private IntData tournamentSize = new IntData();47 public int TournamentSize {48 get { return tournamentSize.Data; }49 set { tournamentSize.Data = value; }50 }51 52 private DoubleData fullTreeShakingFactor = new DoubleData();53 public double FullTreeShakingFactor {54 get { return fullTreeShakingFactor.Data; }55 set { fullTreeShakingFactor.Data = value; }56 }57 58 private DoubleData onepointShakingFactor = new DoubleData();59 public double OnePointShakingFactor {60 get { return onepointShakingFactor.Data; }61 set { onepointShakingFactor.Data = value; }62 }63 64 public override int PopulationSize {65 get {66 return base.PopulationSize;67 }68 set {69 base.PopulationSize = value;70 Parents = 2 * value;71 }72 }73 74 public StandardGP()75 : base() {76 PopulationSize = 10000;77 MaxGenerations = 100;78 TournamentSize = 7;79 MutationRate = 0.15;80 Elites = 1;81 MaxTreeSize = 100;82 MaxTreeHeight = 10;83 FullTreeShakingFactor = 0.1;84 OnePointShakingFactor = 1.0;85 86 Engine = new SequentialEngine.SequentialEngine();87 IOperator algo = CreateAlgorithm();88 Engine.OperatorGraph.AddOperator(algo);89 Engine.OperatorGraph.InitialOperator = algo;90 }91 92 internal override IOperator CreateSelector() {93 TournamentSelector selector = new TournamentSelector();94 selector.Name = "Selector";95 selector.GetVariableInfo("Selected").ActualName = "Parents";96 selector.GetVariableInfo("GroupSize").Local = false;97 selector.RemoveVariable("GroupSize");98 selector.GetVariableInfo("GroupSize").ActualName = "TournamentSize";99 return selector;100 }101 102 internal override IOperator CreateGlobalInjector() {103 VariableInjector globalInjector = (VariableInjector)base.CreateGlobalInjector();104 globalInjector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", tournamentSize));105 globalInjector.AddVariable(new HeuristicLab.Core.Variable("MaxGenerations", maxGenerations));106 return globalInjector;107 }108 109 internal override IOperator CreateCrossover() {110 StandardCrossOver crossover = new StandardCrossOver();111 crossover.Name = "Crossover";112 crossover.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";113 return crossover;114 }115 116 internal override IOperator CreateTreeCreator() {117 ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator();118 treeCreator.Name = "Tree generator";119 treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";120 treeCreator.GetVariableInfo("MinTreeSize").Local = true;121 treeCreator.AddVariable(new HeuristicLab.Core.Variable("MinTreeSize", new IntData(30)));122 return treeCreator;123 }124 125 internal override IOperator CreateFunctionLibraryInjector() {126 return new FunctionLibraryInjector();127 }128 129 internal override IOperator CreateManipulator() {130 CombinedOperator manipulator = new CombinedOperator();131 manipulator.Name = "Manipulator";132 StochasticMultiBranch multibranch = new StochasticMultiBranch();133 FullTreeShaker fullTreeShaker = new FullTreeShaker();134 fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";135 fullTreeShaker.GetVariableInfo("ShakingFactor").Local = true;136 fullTreeShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", fullTreeShakingFactor));137 138 OnePointShaker onepointShaker = new OnePointShaker();139 onepointShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";140 onepointShaker.GetVariableInfo("ShakingFactor").Local = true;141 onepointShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", onepointShakingFactor));142 ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation();143 changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";144 CutOutNodeManipulation cutOutNodeManipulation = new CutOutNodeManipulation();145 cutOutNodeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";146 DeleteSubTreeManipulation deleteSubTreeManipulation = new DeleteSubTreeManipulation();147 deleteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";148 SubstituteSubTreeManipulation substituteSubTreeManipulation = new SubstituteSubTreeManipulation();149 substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";150 151 IOperator[] manipulators = new IOperator[] {152 onepointShaker, fullTreeShaker,153 changeNodeTypeManipulation,154 cutOutNodeManipulation,155 deleteSubTreeManipulation,156 substituteSubTreeManipulation};157 158 DoubleArrayData probabilities = new DoubleArrayData(new double[manipulators.Length]);159 for (int i = 0; i < manipulators.Length; i++) {160 probabilities.Data[i] = 1.0;161 multibranch.AddSubOperator(manipulators[i]);162 }163 multibranch.GetVariableInfo("Probabilities").Local = true;164 multibranch.AddVariable(new HeuristicLab.Core.Variable("Probabilities", probabilities));165 166 manipulator.OperatorGraph.AddOperator(multibranch);167 manipulator.OperatorGraph.InitialOperator = multibranch;168 return manipulator;169 }170 171 internal override IOperator CreateBestSolutionProcessor() {172 SequentialProcessor bestSolutionProcessor = new SequentialProcessor();173 MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();174 trainingMapeEvaluator.Name = "TrainingMapeEvaluator";175 trainingMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TrainingMAPE";176 trainingMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";177 trainingMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";178 MeanAbsolutePercentageErrorEvaluator validationMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();179 validationMapeEvaluator.Name = "ValidationMapeEvaluator";180 validationMapeEvaluator.GetVariableInfo("MAPE").ActualName = "ValidationMAPE";181 validationMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";182 validationMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";183 ProgrammableOperator progOperator = new ProgrammableOperator();184 progOperator.RemoveVariableInfo("Result");185 progOperator.AddVariableInfo(new HeuristicLab.Core.VariableInfo("EvaluatedSolutions", "", typeof(IntData), VariableKind.In));186 progOperator.Code = @"187 int evalSolutions = EvaluatedSolutions.Data;188 scope.AddVariable(new Variable(""EvaluatedSolutions"", new IntData(evalSolutions)));189 ";190 bestSolutionProcessor.AddSubOperator(trainingMapeEvaluator);191 bestSolutionProcessor.AddSubOperator(validationMapeEvaluator);192 bestSolutionProcessor.AddSubOperator(progOperator);193 return bestSolutionProcessor;194 }195 196 internal override IOperator CreateLoggingOperator() {197 CombinedOperator loggingOperator = new CombinedOperator();198 loggingOperator.Name = "Logging";199 SequentialProcessor seq = new SequentialProcessor();200 201 DataCollector collector = new DataCollector();202 ItemList<StringData> names = collector.GetVariable("VariableNames").GetValue<ItemList<StringData>>();203 names.Add(new StringData("BestQuality"));204 names.Add(new StringData("AverageQuality"));205 names.Add(new StringData("WorstQuality"));206 names.Add(new StringData("BestValidationQuality"));207 names.Add(new StringData("AverageValidationQuality"));208 names.Add(new StringData("WorstValidationQuality"));209 LinechartInjector lineChartInjector = new LinechartInjector();210 lineChartInjector.GetVariableInfo("Linechart").ActualName = "Quality Linechart";211 lineChartInjector.GetVariable("NumberOfLines").GetValue<IntData>().Data = 6;212 QualityLogger qualityLogger = new QualityLogger();213 QualityLogger validationQualityLogger = new QualityLogger();214 validationQualityLogger.Name = "ValidationQualityLogger";215 validationQualityLogger.GetVariableInfo("Quality").ActualName = "ValidationQuality";216 validationQualityLogger.GetVariableInfo("QualityLog").ActualName = "ValidationQualityLog";217 218 seq.AddSubOperator(collector);219 seq.AddSubOperator(lineChartInjector);220 seq.AddSubOperator(qualityLogger);221 seq.AddSubOperator(validationQualityLogger);222 223 loggingOperator.OperatorGraph.AddOperator(seq);224 loggingOperator.OperatorGraph.InitialOperator = seq;225 return loggingOperator;226 }227 228 public virtual IEditor CreateEditor() {229 return new StandardGpEditor(this);230 }231 232 public override IView CreateView() {233 return new StandardGpEditor(this);234 }235 236 public override object Clone(IDictionary<Guid, object> clonedObjects) {237 StandardGP clone = new StandardGP();238 clonedObjects.Add(Guid, clone);239 clone.Engine = (SequentialEngine.SequentialEngine)Auxiliary.Clone(Engine, clonedObjects);240 return clone;241 }242 243 #region SetReferences Method244 private void SetReferences() {245 // SGA246 CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;247 // SequentialProcessor in SGA248 SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;249 // RandomInjector250 RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];251 // VariableInjector252 VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];253 maxGenerations = vi.GetVariable("MaxGenerations").GetValue<IntData>();254 tournamentSize = vi.GetVariable("TournamentSize").GetValue<IntData>();255 }256 #endregion257 258 #region Persistence Methods259 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {260 XmlNode node = base.GetXmlNode(name, document, persistedObjects);261 node.AppendChild(PersistenceManager.Persist("Engine", Engine, document, persistedObjects));262 return node;263 }264 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {265 base.Populate(node, restoredObjects);266 Engine = (SequentialEngine.SequentialEngine)PersistenceManager.Restore(node.SelectSingleNode("Engine"), restoredObjects);267 SetReferences();268 }269 #endregion270 72 } 271 73 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/HeuristicLab.GP.StructureIdentification.TimeSeries.csproj
r852 r1245 69 69 </Compile> 70 70 <Compile Include="HeuristicLabGPTimeSeriesPlugin.cs" /> 71 <Compile Include="OffspringSelectionGP.cs" /> 71 72 <Compile Include="ProfitEvaluator.cs" /> 72 73 <Compile Include="Properties\AssemblyInfo.cs" /> 74 <Compile Include="StandardGP.cs" /> 73 75 <Compile Include="TheilInequalityCoefficientEvaluator.cs" /> 74 76 </ItemGroup> … … 98 100 <Name>HeuristicLab.GP</Name> 99 101 </ProjectReference> 102 <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj"> 103 <Project>{A9983BA2-B3B2-475E-8E2C-62050B71D1C5}</Project> 104 <Name>HeuristicLab.Operators</Name> 105 </ProjectReference> 100 106 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 101 107 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/OffspringSelectionGP.cs
r1244 r1245 28 28 using System.Diagnostics; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.Data; 30 31 using HeuristicLab.Operators; 31 using HeuristicLab.Random;32 using HeuristicLab.Selection;33 using HeuristicLab.Logging;34 using HeuristicLab.Data;35 using HeuristicLab.Operators.Programmable;36 using HeuristicLab.Selection.OffspringSelection;37 32 38 namespace HeuristicLab.GP.StructureIdentification { 39 public class OffspringSelectionGP : StandardGP { 40 41 private IntData maxEvaluatedSolutions = new IntData(); 42 public int MaxEvaluatedSolutions { 43 get { return maxEvaluatedSolutions.Data; } 44 set { maxEvaluatedSolutions.Data = value; } 33 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 34 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP { 35 protected override IOperator CreateFunctionLibraryInjector() { 36 return new FunctionLibraryInjector(); 45 37 } 46 38 47 private DoubleData selectionPressureLimit = new DoubleData(); 48 public double SelectionPressureLimit { 49 get { return selectionPressureLimit.Data; } 50 set { selectionPressureLimit.Data = value; } 51 } 39 protected override IOperator CreateBestSolutionProcessor() { 40 IOperator seq = base.CreateBestSolutionProcessor(); 41 TheilInequalityCoefficientEvaluator trainingTheil = new TheilInequalityCoefficientEvaluator(); 42 trainingTheil.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 43 trainingTheil.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 44 trainingTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TrainingTheilInequalityCoefficient"; 45 trainingTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TrainingTheilInequalityCoefficientBias"; 46 trainingTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TrainingTheilInequalityCoefficientVariance"; 47 trainingTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TrainingTheilInequalityCoefficientCovariance"; 52 48 53 private DoubleData comparisonFactor = new DoubleData(); 54 public double ComparisonFactor { 55 get { return comparisonFactor.Data; } 56 set { comparisonFactor.Data = value; } 57 } 49 TheilInequalityCoefficientEvaluator validationTheil = new TheilInequalityCoefficientEvaluator(); 50 validationTheil.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 51 validationTheil.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 52 validationTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "ValidationTheilInequalityCoefficient"; 53 validationTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "ValidationTheilInequalityCoefficientBias"; 54 validationTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "ValidationTheilInequalityCoefficientVariance"; 55 validationTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "ValidationTheilInequalityCoefficientCovariance"; 58 56 59 private DoubleData successRatioLimit = new DoubleData(); 60 public double SuccessRatioLimit { 61 get { return successRatioLimit.Data; } 62 set { successRatioLimit.Data = value; } 63 } 57 TheilInequalityCoefficientEvaluator testTheil = new TheilInequalityCoefficientEvaluator(); 58 testTheil.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 59 testTheil.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 60 testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient"; 61 testTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TestTheilInequalityCoefficientBias"; 62 testTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TestTheilInequalityCoefficientVariance"; 63 testTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TestTheilInequalityCoefficientCovariance"; 64 64 65 public OffspringSelectionGP() : base() { 66 PopulationSize = 1000; 67 Parents = 20; 68 MaxEvaluatedSolutions = 1000000; 69 SelectionPressureLimit = 300; 70 ComparisonFactor = 1.0; 71 SuccessRatioLimit = 1.0; 72 } 73 74 internal override IOperator CreateGlobalInjector() { 75 VariableInjector injector = (VariableInjector)base.CreateGlobalInjector(); 76 injector.RemoveVariable("TournamentSize"); 77 injector.RemoveVariable("MaxGenerations"); 78 injector.AddVariable(new HeuristicLab.Core.Variable("MaxEvaluatedSolutions", maxEvaluatedSolutions)); 79 injector.AddVariable(new HeuristicLab.Core.Variable("ComparisonFactor", comparisonFactor)); 80 injector.AddVariable(new HeuristicLab.Core.Variable("SelectionPressureLimit", selectionPressureLimit)); 81 injector.AddVariable(new HeuristicLab.Core.Variable("SuccessRatioLimit", successRatioLimit)); 82 return injector; 83 } 84 85 internal override IOperator CreateSelector() { 86 CombinedOperator selector = new CombinedOperator(); 87 selector.Name = "Selector"; 88 SequentialProcessor seq = new SequentialProcessor(); 89 seq.Name = "Selector"; 90 EmptyOperator emptyOp = new EmptyOperator(); 91 ProportionalSelector femaleSelector = new ProportionalSelector(); 92 femaleSelector.GetVariableInfo("Selected").ActualName = "Parents"; 93 femaleSelector.GetVariableValue<BoolData>("CopySelected", null, false).Data = true; 94 95 RandomSelector maleSelector = new RandomSelector(); 96 maleSelector.GetVariableInfo("Selected").ActualName = "Parents"; 97 maleSelector.GetVariableValue<BoolData>("CopySelected", null, false).Data = true; 98 SequentialSubScopesProcessor seqSubScopesProc = new SequentialSubScopesProcessor(); 99 RightChildReducer rightChildReducer = new RightChildReducer(); 100 SubScopesMixer mixer = new SubScopesMixer(); 101 102 seqSubScopesProc.AddSubOperator(femaleSelector); 103 seqSubScopesProc.AddSubOperator(emptyOp); 104 105 seq.AddSubOperator(maleSelector); 106 seq.AddSubOperator(seqSubScopesProc); 107 seq.AddSubOperator(rightChildReducer); 108 seq.AddSubOperator(mixer); 109 110 selector.OperatorGraph.AddOperator(seq); 111 selector.OperatorGraph.InitialOperator = seq; 112 return selector; 113 } 114 115 internal override IOperator CreateChildCreater() { 116 CombinedOperator childCreater = new CombinedOperator(); 117 childCreater.Name = "Create children"; 118 SequentialProcessor seq = new SequentialProcessor(); 119 SequentialProcessor offspringSelectionSeq = new SequentialProcessor(); 120 OperatorExtractor selector = new OperatorExtractor(); 121 selector.Name = "Selector (extr.)"; 122 selector.GetVariableInfo("Operator").ActualName = "Selector"; 123 SequentialSubScopesProcessor seqSubScopesProc = new SequentialSubScopesProcessor(); 124 EmptyOperator emptyOp = new EmptyOperator(); 125 OffspringSelector offspringSelector = new OffspringSelector(); 126 OffspringAnalyzer offspringAnalyzer = new OffspringAnalyzer(); 127 SequentialProcessor selectedProc = new SequentialProcessor(); 128 OperatorExtractor crossover = new OperatorExtractor(); 129 crossover.Name = "Crossover (extr.)"; 130 crossover.GetVariableInfo("Operator").ActualName = "Crossover"; 131 UniformSequentialSubScopesProcessor individualProc = new UniformSequentialSubScopesProcessor(); 132 SequentialProcessor individualSeqProc = new SequentialProcessor(); 133 StochasticBranch cond = new StochasticBranch(); 134 cond.GetVariableInfo("Probability").ActualName = "MutationRate"; 135 OperatorExtractor manipulator = new OperatorExtractor(); 136 manipulator.Name = "Manipulator (extr.)"; 137 manipulator.GetVariableInfo("Operator").ActualName = "Manipulator"; 138 OperatorExtractor evaluator = new OperatorExtractor(); 139 evaluator.Name = "Evaluator (extr.)"; 140 evaluator.GetVariableInfo("Operator").ActualName = "Evaluator"; 141 Counter evalCounter = new Counter(); 142 evalCounter.GetVariableInfo("Value").ActualName = "EvaluatedSolutions"; 143 144 Sorter sorter = new Sorter(); 145 sorter.GetVariableInfo("Descending").ActualName = "Maximization"; 146 sorter.GetVariableInfo("Value").ActualName = "Quality"; 147 148 UniformSequentialSubScopesProcessor validationEvaluator = new UniformSequentialSubScopesProcessor(); 149 MeanSquaredErrorEvaluator validationQualityEvaluator = new MeanSquaredErrorEvaluator(); 150 validationQualityEvaluator.Name = "ValidationMeanSquaredErrorEvaluator"; 151 validationQualityEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality"; 152 validationQualityEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 153 validationQualityEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 154 155 seqSubScopesProc.AddSubOperator(emptyOp); 156 seqSubScopesProc.AddSubOperator(offspringAnalyzer); 157 158 seq.AddSubOperator(offspringSelectionSeq); 159 offspringSelectionSeq.AddSubOperator(selector); 160 offspringSelectionSeq.AddSubOperator(seqSubScopesProc); 161 offspringSelectionSeq.AddSubOperator(offspringSelector); 162 offspringSelector.AddSubOperator(offspringSelectionSeq); 163 164 offspringAnalyzer.AddSubOperator(selectedProc); 165 selectedProc.AddSubOperator(crossover); 166 selectedProc.AddSubOperator(individualProc); 167 individualProc.AddSubOperator(individualSeqProc); 168 individualSeqProc.AddSubOperator(cond); 169 cond.AddSubOperator(manipulator); 170 individualSeqProc.AddSubOperator(evaluator); 171 individualSeqProc.AddSubOperator(evalCounter); 172 173 SequentialSubScopesProcessor seqSubScopesProc2 = new SequentialSubScopesProcessor(); 174 seq.AddSubOperator(seqSubScopesProc2); 175 seqSubScopesProc2.AddSubOperator(emptyOp); 176 177 SequentialProcessor newGenProc = new SequentialProcessor(); 178 newGenProc.AddSubOperator(sorter); 179 newGenProc.AddSubOperator(validationEvaluator); 180 seqSubScopesProc2.AddSubOperator(newGenProc); 181 182 validationEvaluator.AddSubOperator(validationQualityEvaluator); 183 184 childCreater.OperatorGraph.AddOperator(seq); 185 childCreater.OperatorGraph.InitialOperator = seq; 186 return childCreater; 187 } 188 189 internal override IOperator CreateLoopCondition(IOperator loop) { 190 SequentialProcessor seq = new SequentialProcessor(); 191 seq.Name = "Loop Condition"; 192 LessThanComparator generationsComparator = new LessThanComparator(); 193 generationsComparator.GetVariableInfo("LeftSide").ActualName = "EvaluatedSolutions"; 194 generationsComparator.GetVariableInfo("RightSide").ActualName = "MaxEvaluatedSolutions"; 195 generationsComparator.GetVariableInfo("Result").ActualName = "EvaluatedSolutionsCondition"; 196 197 LessThanComparator selPresComparator = new LessThanComparator(); 198 selPresComparator.GetVariableInfo("LeftSide").ActualName = "SelectionPressure"; 199 selPresComparator.GetVariableInfo("RightSide").ActualName = "SelectionPressureLimit"; 200 selPresComparator.GetVariableInfo("Result").ActualName = "SelectionPressureCondition"; 201 202 ConditionalBranch generationsCond = new ConditionalBranch(); 203 generationsCond.GetVariableInfo("Condition").ActualName = "EvaluatedSolutionsCondition"; 204 205 ConditionalBranch selPresCond = new ConditionalBranch(); 206 selPresCond.GetVariableInfo("Condition").ActualName = "SelectionPressureCondition"; 207 208 seq.AddSubOperator(generationsComparator); 209 seq.AddSubOperator(selPresComparator); 210 seq.AddSubOperator(generationsCond); 211 generationsCond.AddSubOperator(selPresCond); 212 selPresCond.AddSubOperator(loop); 65 seq.AddSubOperator(trainingTheil); 66 seq.AddSubOperator(validationTheil); 67 seq.AddSubOperator(testTheil); 213 68 214 69 return seq; 215 70 } 216 217 internal override IOperator CreateLoggingOperator() {218 CombinedOperator loggingOperator = new CombinedOperator();219 loggingOperator.Name = "Logging";220 SequentialProcessor seq = new SequentialProcessor();221 222 DataCollector collector = new DataCollector();223 ItemList<StringData> names = collector.GetVariable("VariableNames").GetValue<ItemList<StringData>>();224 names.Add(new StringData("BestQuality"));225 names.Add(new StringData("AverageQuality"));226 names.Add(new StringData("WorstQuality"));227 names.Add(new StringData("BestValidationQuality"));228 names.Add(new StringData("AverageValidationQuality"));229 names.Add(new StringData("WorstValidationQuality"));230 names.Add(new StringData("EvaluatedSolutions"));231 names.Add(new StringData("SelectionPressure"));232 QualityLogger qualityLogger = new QualityLogger();233 QualityLogger validationQualityLogger = new QualityLogger();234 validationQualityLogger.Name = "ValidationQualityLogger";235 validationQualityLogger.GetVariableInfo("Quality").ActualName = "ValidationQuality";236 validationQualityLogger.GetVariableInfo("QualityLog").ActualName = "ValidationQualityLog";237 238 seq.AddSubOperator(collector);239 seq.AddSubOperator(qualityLogger);240 seq.AddSubOperator(validationQualityLogger);241 242 loggingOperator.OperatorGraph.AddOperator(seq);243 loggingOperator.OperatorGraph.InitialOperator = seq;244 return loggingOperator;245 }246 247 248 public override IEditor CreateEditor() {249 return new OffspringSelectionGpEditor(this);250 }251 252 public override IView CreateView() {253 return new OffspringSelectionGpEditor(this);254 }255 256 public override object Clone(IDictionary<Guid, object> clonedObjects) {257 OffspringSelectionGP clone = (OffspringSelectionGP)base.Clone(clonedObjects);258 clone.SelectionPressureLimit = SelectionPressureLimit;259 clone.SuccessRatioLimit = SuccessRatioLimit;260 clone.ComparisonFactor = ComparisonFactor;261 return clone;262 }263 264 #region SetReferences Method265 private void SetReferences() {266 // SGA267 CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;268 // SequentialProcessor in SGA269 SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;270 // RandomInjector271 RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];272 // VariableInjector273 VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];274 selectionPressureLimit = vi.GetVariable("SelectionPressureLimit").GetValue<DoubleData>();275 successRatioLimit = vi.GetVariable("SuccessRatioLimit").GetValue<DoubleData>();276 comparisonFactor = vi.GetVariable("ComparisonFactor").GetValue<DoubleData>();277 }278 #endregion279 280 #region Persistence Methods281 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {282 XmlNode node = base.GetXmlNode(name, document, persistedObjects);283 return node;284 }285 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {286 base.Populate(node, restoredObjects);287 SetReferences();288 }289 #endregion290 71 } 291 72 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/StandardGP.cs
r1244 r1245 28 28 using System.Diagnostics; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.Operators;31 using HeuristicLab.Random;32 using HeuristicLab.Selection;33 using HeuristicLab.Logging;34 30 using HeuristicLab.Data; 35 using HeuristicLab.Operators.Programmable;36 31 37 namespace HeuristicLab.GP.StructureIdentification { 38 public class StandardGP : AlgorithmBase, IEditable { 39 40 private IntData maxGenerations = new IntData(); 41 public int MaxGenerations { 42 get { return maxGenerations.Data; } 43 set { maxGenerations.Data = value; } 44 } 45 46 private IntData tournamentSize = new IntData(); 47 public int TournamentSize { 48 get { return tournamentSize.Data; } 49 set { tournamentSize.Data = value; } 50 } 51 52 private DoubleData fullTreeShakingFactor = new DoubleData(); 53 public double FullTreeShakingFactor { 54 get { return fullTreeShakingFactor.Data; } 55 set { fullTreeShakingFactor.Data = value; } 56 } 57 58 private DoubleData onepointShakingFactor = new DoubleData(); 59 public double OnePointShakingFactor { 60 get { return onepointShakingFactor.Data; } 61 set { onepointShakingFactor.Data = value; } 62 } 63 64 public override int PopulationSize { 65 get { 66 return base.PopulationSize; 67 } 68 set { 69 base.PopulationSize = value; 70 Parents = 2 * value; 71 } 72 } 73 74 public StandardGP() 75 : base() { 76 PopulationSize = 10000; 77 MaxGenerations = 100; 78 TournamentSize = 7; 79 MutationRate = 0.15; 80 Elites = 1; 81 MaxTreeSize = 100; 82 MaxTreeHeight = 10; 83 FullTreeShakingFactor = 0.1; 84 OnePointShakingFactor = 1.0; 85 86 Engine = new SequentialEngine.SequentialEngine(); 87 IOperator algo = CreateAlgorithm(); 88 Engine.OperatorGraph.AddOperator(algo); 89 Engine.OperatorGraph.InitialOperator = algo; 90 } 91 92 internal override IOperator CreateSelector() { 93 TournamentSelector selector = new TournamentSelector(); 94 selector.Name = "Selector"; 95 selector.GetVariableInfo("Selected").ActualName = "Parents"; 96 selector.GetVariableInfo("GroupSize").Local = false; 97 selector.RemoveVariable("GroupSize"); 98 selector.GetVariableInfo("GroupSize").ActualName = "TournamentSize"; 99 return selector; 100 } 101 102 internal override IOperator CreateGlobalInjector() { 103 VariableInjector globalInjector = (VariableInjector)base.CreateGlobalInjector(); 104 globalInjector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", tournamentSize)); 105 globalInjector.AddVariable(new HeuristicLab.Core.Variable("MaxGenerations", maxGenerations)); 106 return globalInjector; 107 } 108 109 internal override IOperator CreateCrossover() { 110 StandardCrossOver crossover = new StandardCrossOver(); 111 crossover.Name = "Crossover"; 112 crossover.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 113 return crossover; 114 } 115 116 internal override IOperator CreateTreeCreator() { 117 ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator(); 118 treeCreator.Name = "Tree generator"; 119 treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 120 treeCreator.GetVariableInfo("MinTreeSize").Local = true; 121 treeCreator.AddVariable(new HeuristicLab.Core.Variable("MinTreeSize", new IntData(30))); 122 return treeCreator; 123 } 124 125 internal override IOperator CreateFunctionLibraryInjector() { 32 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 33 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP { 34 protected override IOperator CreateFunctionLibraryInjector() { 126 35 return new FunctionLibraryInjector(); 127 36 } 128 37 129 internal override IOperator CreateManipulator() { 130 CombinedOperator manipulator = new CombinedOperator(); 131 manipulator.Name = "Manipulator"; 132 StochasticMultiBranch multibranch = new StochasticMultiBranch(); 133 FullTreeShaker fullTreeShaker = new FullTreeShaker(); 134 fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 135 fullTreeShaker.GetVariableInfo("ShakingFactor").Local = true; 136 fullTreeShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", fullTreeShakingFactor)); 38 protected override IOperator CreateBestSolutionProcessor() { 39 IOperator seq = base.CreateBestSolutionProcessor(); 40 TheilInequalityCoefficientEvaluator trainingTheil = new TheilInequalityCoefficientEvaluator(); 41 trainingTheil.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 42 trainingTheil.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 43 trainingTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TrainingTheilInequalityCoefficient"; 44 trainingTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TrainingTheilInequalityCoefficientBias"; 45 trainingTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TrainingTheilInequalityCoefficientVariance"; 46 trainingTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TrainingTheilInequalityCoefficientCovariance"; 137 47 138 OnePointShaker onepointShaker = new OnePointShaker(); 139 onepointShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 140 onepointShaker.GetVariableInfo("ShakingFactor").Local = true; 141 onepointShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", onepointShakingFactor)); 142 ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation(); 143 changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 144 CutOutNodeManipulation cutOutNodeManipulation = new CutOutNodeManipulation(); 145 cutOutNodeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 146 DeleteSubTreeManipulation deleteSubTreeManipulation = new DeleteSubTreeManipulation(); 147 deleteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 148 SubstituteSubTreeManipulation substituteSubTreeManipulation = new SubstituteSubTreeManipulation(); 149 substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 48 TheilInequalityCoefficientEvaluator validationTheil = new TheilInequalityCoefficientEvaluator(); 49 validationTheil.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 50 validationTheil.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 51 validationTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "ValidationTheilInequalityCoefficient"; 52 validationTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "ValidationTheilInequalityCoefficientBias"; 53 validationTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "ValidationTheilInequalityCoefficientVariance"; 54 validationTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "ValidationTheilInequalityCoefficientCovariance"; 150 55 151 IOperator[] manipulators = new IOperator[] { 152 onepointShaker, fullTreeShaker, 153 changeNodeTypeManipulation, 154 cutOutNodeManipulation, 155 deleteSubTreeManipulation, 156 substituteSubTreeManipulation}; 56 TheilInequalityCoefficientEvaluator testTheil = new TheilInequalityCoefficientEvaluator(); 57 testTheil.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart"; 58 testTheil.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd"; 59 testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient"; 60 testTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TestTheilInequalityCoefficientBias"; 61 testTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TestTheilInequalityCoefficientVariance"; 62 testTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TestTheilInequalityCoefficientCovariance"; 157 63 158 DoubleArrayData probabilities = new DoubleArrayData(new double[manipulators.Length]); 159 for (int i = 0; i < manipulators.Length; i++) { 160 probabilities.Data[i] = 1.0; 161 multibranch.AddSubOperator(manipulators[i]); 162 } 163 multibranch.GetVariableInfo("Probabilities").Local = true; 164 multibranch.AddVariable(new HeuristicLab.Core.Variable("Probabilities", probabilities)); 64 seq.AddSubOperator(trainingTheil); 65 seq.AddSubOperator(validationTheil); 66 seq.AddSubOperator(testTheil); 165 67 166 manipulator.OperatorGraph.AddOperator(multibranch); 167 manipulator.OperatorGraph.InitialOperator = multibranch; 168 return manipulator; 68 return seq; 169 69 } 170 171 internal override IOperator CreateBestSolutionProcessor() {172 SequentialProcessor bestSolutionProcessor = new SequentialProcessor();173 MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();174 trainingMapeEvaluator.Name = "TrainingMapeEvaluator";175 trainingMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TrainingMAPE";176 trainingMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";177 trainingMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";178 MeanAbsolutePercentageErrorEvaluator validationMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();179 validationMapeEvaluator.Name = "ValidationMapeEvaluator";180 validationMapeEvaluator.GetVariableInfo("MAPE").ActualName = "ValidationMAPE";181 validationMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";182 validationMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";183 ProgrammableOperator progOperator = new ProgrammableOperator();184 progOperator.RemoveVariableInfo("Result");185 progOperator.AddVariableInfo(new HeuristicLab.Core.VariableInfo("EvaluatedSolutions", "", typeof(IntData), VariableKind.In));186 progOperator.Code = @"187 int evalSolutions = EvaluatedSolutions.Data;188 scope.AddVariable(new Variable(""EvaluatedSolutions"", new IntData(evalSolutions)));189 ";190 bestSolutionProcessor.AddSubOperator(trainingMapeEvaluator);191 bestSolutionProcessor.AddSubOperator(validationMapeEvaluator);192 bestSolutionProcessor.AddSubOperator(progOperator);193 return bestSolutionProcessor;194 }195 196 internal override IOperator CreateLoggingOperator() {197 CombinedOperator loggingOperator = new CombinedOperator();198 loggingOperator.Name = "Logging";199 SequentialProcessor seq = new SequentialProcessor();200 201 DataCollector collector = new DataCollector();202 ItemList<StringData> names = collector.GetVariable("VariableNames").GetValue<ItemList<StringData>>();203 names.Add(new StringData("BestQuality"));204 names.Add(new StringData("AverageQuality"));205 names.Add(new StringData("WorstQuality"));206 names.Add(new StringData("BestValidationQuality"));207 names.Add(new StringData("AverageValidationQuality"));208 names.Add(new StringData("WorstValidationQuality"));209 LinechartInjector lineChartInjector = new LinechartInjector();210 lineChartInjector.GetVariableInfo("Linechart").ActualName = "Quality Linechart";211 lineChartInjector.GetVariable("NumberOfLines").GetValue<IntData>().Data = 6;212 QualityLogger qualityLogger = new QualityLogger();213 QualityLogger validationQualityLogger = new QualityLogger();214 validationQualityLogger.Name = "ValidationQualityLogger";215 validationQualityLogger.GetVariableInfo("Quality").ActualName = "ValidationQuality";216 validationQualityLogger.GetVariableInfo("QualityLog").ActualName = "ValidationQualityLog";217 218 seq.AddSubOperator(collector);219 seq.AddSubOperator(lineChartInjector);220 seq.AddSubOperator(qualityLogger);221 seq.AddSubOperator(validationQualityLogger);222 223 loggingOperator.OperatorGraph.AddOperator(seq);224 loggingOperator.OperatorGraph.InitialOperator = seq;225 return loggingOperator;226 }227 228 public virtual IEditor CreateEditor() {229 return new StandardGpEditor(this);230 }231 232 public override IView CreateView() {233 return new StandardGpEditor(this);234 }235 236 public override object Clone(IDictionary<Guid, object> clonedObjects) {237 StandardGP clone = new StandardGP();238 clonedObjects.Add(Guid, clone);239 clone.Engine = (SequentialEngine.SequentialEngine)Auxiliary.Clone(Engine, clonedObjects);240 return clone;241 }242 243 #region SetReferences Method244 private void SetReferences() {245 // SGA246 CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;247 // SequentialProcessor in SGA248 SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;249 // RandomInjector250 RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];251 // VariableInjector252 VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];253 maxGenerations = vi.GetVariable("MaxGenerations").GetValue<IntData>();254 tournamentSize = vi.GetVariable("TournamentSize").GetValue<IntData>();255 }256 #endregion257 258 #region Persistence Methods259 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {260 XmlNode node = base.GetXmlNode(name, document, persistedObjects);261 node.AppendChild(PersistenceManager.Persist("Engine", Engine, document, persistedObjects));262 return node;263 }264 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {265 base.Populate(node, restoredObjects);266 Engine = (SequentialEngine.SequentialEngine)PersistenceManager.Restore(node.SelectSingleNode("Engine"), restoredObjects);267 SetReferences();268 }269 #endregion270 70 } 271 71 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/AlgorithmBase.cs
r1238 r1245 112 112 } 113 113 114 internal virtual CombinedOperator CreateAlgorithm() {114 protected internal virtual CombinedOperator CreateAlgorithm() { 115 115 CombinedOperator algo = new CombinedOperator(); 116 116 algo.Name = "GP"; … … 164 164 } 165 165 166 internal abstract IOperator CreateSelector();167 168 internal abstract IOperator CreateCrossover();169 170 internal abstract IOperator CreateTreeCreator();171 172 internal abstract IOperator CreateFunctionLibraryInjector();173 174 internal virtual IOperator CreateGlobalInjector() {166 protected internal abstract IOperator CreateSelector(); 167 168 protected internal abstract IOperator CreateCrossover(); 169 170 protected internal abstract IOperator CreateTreeCreator(); 171 172 protected internal abstract IOperator CreateFunctionLibraryInjector(); 173 174 protected internal virtual IOperator CreateGlobalInjector() { 175 175 VariableInjector injector = new VariableInjector(); 176 176 injector.Name = "Global Injector"; … … 190 190 } 191 191 192 internal abstract IOperator CreateManipulator();193 194 internal virtual IOperator CreateInitialization() {192 protected internal abstract IOperator CreateManipulator(); 193 194 protected internal virtual IOperator CreateInitialization() { 195 195 CombinedOperator init = new CombinedOperator(); 196 196 init.Name = "Initialization"; … … 231 231 } 232 232 233 internal virtual IOperator CreateMainLoop() {233 protected internal virtual IOperator CreateMainLoop() { 234 234 CombinedOperator main = new CombinedOperator(); 235 235 SequentialProcessor seq = new SequentialProcessor(); … … 268 268 } 269 269 270 internal virtual IOperator CreateLoggingOperator() {270 protected internal virtual IOperator CreateLoggingOperator() { 271 271 return new EmptyOperator(); 272 272 } 273 273 274 internal virtual IOperator CreateLoopCondition(IOperator loop) {274 protected internal virtual IOperator CreateLoopCondition(IOperator loop) { 275 275 SequentialProcessor seq = new SequentialProcessor(); 276 276 seq.Name = "Loop Condition"; … … 289 289 } 290 290 291 internal virtual IOperator CreateBestSolutionProcessor() {291 protected internal virtual IOperator CreateBestSolutionProcessor() { 292 292 return new EmptyOperator(); 293 293 } 294 294 295 internal virtual IOperator CreateReplacement() {295 protected internal virtual IOperator CreateReplacement() { 296 296 CombinedOperator replacement = new CombinedOperator(); 297 297 replacement.Name = "Replacement"; … … 327 327 } 328 328 329 internal virtual IOperator CreateChildCreater() {329 protected internal virtual IOperator CreateChildCreater() { 330 330 CombinedOperator childCreater = new CombinedOperator(); 331 331 childCreater.Name = "Create children"; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffspringSelectionGP.cs
r1239 r1245 72 72 } 73 73 74 internal override IOperator CreateGlobalInjector() {74 protected internal override IOperator CreateGlobalInjector() { 75 75 VariableInjector injector = (VariableInjector)base.CreateGlobalInjector(); 76 76 injector.RemoveVariable("TournamentSize"); … … 83 83 } 84 84 85 internal override IOperator CreateSelector() {85 protected internal override IOperator CreateSelector() { 86 86 CombinedOperator selector = new CombinedOperator(); 87 87 selector.Name = "Selector"; … … 113 113 } 114 114 115 internal override IOperator CreateChildCreater() {115 protected internal override IOperator CreateChildCreater() { 116 116 CombinedOperator childCreater = new CombinedOperator(); 117 117 childCreater.Name = "Create children"; … … 187 187 } 188 188 189 internal override IOperator CreateLoopCondition(IOperator loop) {189 protected internal override IOperator CreateLoopCondition(IOperator loop) { 190 190 SequentialProcessor seq = new SequentialProcessor(); 191 191 seq.Name = "Loop Condition"; … … 215 215 } 216 216 217 internal override IOperator CreateLoggingOperator() {217 protected internal override IOperator CreateLoggingOperator() { 218 218 CombinedOperator loggingOperator = new CombinedOperator(); 219 219 loggingOperator.Name = "Logging"; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGP.cs
r1238 r1245 83 83 FullTreeShakingFactor = 0.1; 84 84 OnePointShakingFactor = 1.0; 85 86 85 Engine = new SequentialEngine.SequentialEngine(); 87 86 IOperator algo = CreateAlgorithm(); … … 90 89 } 91 90 92 internal override IOperator CreateSelector() {91 protected internal override IOperator CreateSelector() { 93 92 TournamentSelector selector = new TournamentSelector(); 94 93 selector.Name = "Selector"; … … 100 99 } 101 100 102 internal override IOperator CreateGlobalInjector() {101 protected internal override IOperator CreateGlobalInjector() { 103 102 VariableInjector globalInjector = (VariableInjector)base.CreateGlobalInjector(); 104 103 globalInjector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", tournamentSize)); … … 107 106 } 108 107 109 internal override IOperator CreateCrossover() {108 protected internal override IOperator CreateCrossover() { 110 109 StandardCrossOver crossover = new StandardCrossOver(); 111 110 crossover.Name = "Crossover"; … … 114 113 } 115 114 116 internal override IOperator CreateTreeCreator() {115 protected internal override IOperator CreateTreeCreator() { 117 116 ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator(); 118 117 treeCreator.Name = "Tree generator"; … … 123 122 } 124 123 125 internal override IOperator CreateFunctionLibraryInjector() {124 protected internal override IOperator CreateFunctionLibraryInjector() { 126 125 return new FunctionLibraryInjector(); 127 126 } 128 127 129 internal override IOperator CreateManipulator() {128 protected internal override IOperator CreateManipulator() { 130 129 CombinedOperator manipulator = new CombinedOperator(); 131 130 manipulator.Name = "Manipulator"; … … 169 168 } 170 169 171 internal override IOperator CreateBestSolutionProcessor() {170 protected internal override IOperator CreateBestSolutionProcessor() { 172 171 SequentialProcessor bestSolutionProcessor = new SequentialProcessor(); 173 172 MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator(); … … 181 180 validationMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 182 181 validationMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 182 MeanAbsolutePercentageOfRangeErrorEvaluator trainingMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator(); 183 trainingMapreEvaluator.Name = "TrainingMapreEvaluator"; 184 trainingMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TrainingMAPRE"; 185 trainingMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart"; 186 trainingMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 187 MeanAbsolutePercentageOfRangeErrorEvaluator validationMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator(); 188 validationMapreEvaluator.Name = "ValidationMapreEvaluator"; 189 validationMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "ValidationMAPRE"; 190 validationMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart"; 191 validationMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd"; 183 192 ProgrammableOperator progOperator = new ProgrammableOperator(); 184 193 progOperator.RemoveVariableInfo("Result"); … … 190 199 bestSolutionProcessor.AddSubOperator(trainingMapeEvaluator); 191 200 bestSolutionProcessor.AddSubOperator(validationMapeEvaluator); 201 bestSolutionProcessor.AddSubOperator(trainingMapreEvaluator); 202 bestSolutionProcessor.AddSubOperator(validationMapreEvaluator); 192 203 bestSolutionProcessor.AddSubOperator(progOperator); 193 204 return bestSolutionProcessor; 194 205 } 195 206 196 internal override IOperator CreateLoggingOperator() {207 protected internal override IOperator CreateLoggingOperator() { 197 208 CombinedOperator loggingOperator = new CombinedOperator(); 198 209 loggingOperator.Name = "Logging";
Note: See TracChangeset
for help on using the changeset viewer.