Changeset 1051
- Timestamp:
- 12/22/08 09:37:50 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.Classification/HeuristicLab.GP.StructureIdentification.Classification.csproj
r852 r1051 70 70 <Compile Include="GPClassificationEvaluatorBase.cs" /> 71 71 <Compile Include="CrossValidation.cs" /> 72 <Compile Include="FunctionLibraryInjector.cs">73 <SubType>Code</SubType>74 </Compile>75 72 <Compile Include="HeuristicLabGPClassificationPlugin.cs" /> 76 73 <Compile Include="MulticlassModeller.cs" /> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/HeuristicLab.GP.StructureIdentification.csproj
r1050 r1051 72 72 <Compile Include="Constant.cs" /> 73 73 <Compile Include="FunctionLibraryInjector.cs" /> 74 <Compile Include="StandardGpEditor.cs"> 75 <SubType>UserControl</SubType> 76 </Compile> 77 <Compile Include="StandardGpEditor.Designer.cs"> 78 <DependentUpon>StandardGpEditor.cs</DependentUpon> 79 </Compile> 74 80 <Compile Include="StandardGP.cs" /> 75 81 <Compile Include="Cosinus.cs" /> … … 161 167 </ItemGroup> 162 168 <ItemGroup> 169 <EmbeddedResource Include="StandardGpEditor.resx"> 170 <DependentUpon>StandardGpEditor.cs</DependentUpon> 171 <SubType>Designer</SubType> 172 </EmbeddedResource> 163 173 <EmbeddedResource Include="StructIdProblemInjectorView.resx"> 164 174 <DependentUpon>StructIdProblemInjectorView.cs</DependentUpon> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGP.cs
r1050 r1051 35 35 36 36 namespace HeuristicLab.GP.StructureIdentification { 37 public class StandardGP {37 public class StandardGP : ItemBase, IEditable { 38 38 private IntData maxGenerations = new IntData(); 39 39 public int MaxGenerations { … … 41 41 set { maxGenerations.Data = value; } 42 42 } 43 43 44 44 private IntData tournamentSize = new IntData(); 45 45 public int TournamentSize { … … 62 62 } 63 63 64 private BoolData setSeedRandomly = new BoolData(); 65 public bool SetSeedRandomly { 66 get { return setSeedRandomly.Data; } 67 set { setSeedRandomly.Data = value; } 68 } 69 70 private IntData seed = new IntData(); 71 public int Seed { 72 get { return seed.Data; } 73 set { seed.Data = value; } 74 } 75 76 public IOperator ProblemInjector { 77 get { return algorithm.SubOperators[0]; } 78 set { 79 value.Name = "ProblemInjector"; 80 algorithm.RemoveSubOperator(0); 81 algorithm.AddSubOperator(value, 0); 82 } 83 } 84 85 private IntData elites = new IntData(); 86 public int Elites { 87 get { return elites.Data; } 88 set { elites.Data = value; } 89 } 90 64 91 private int maxTreeSize = 50; 65 92 private int maxTreeHeight = 8; … … 68 95 private double fullTreeShakingFactor = 0.1; 69 96 private double onepointShakingFactor = 1.0; 70 97 private IOperator algorithm; 71 98 private SequentialEngine.SequentialEngine engine; 72 99 100 public IEngine Engine { 101 get { return engine; } 102 } 103 73 104 public StandardGP() { 74 PopulationSize = 100 00;105 PopulationSize = 100; 75 106 MaxGenerations = 100; 76 107 TournamentSize = 7; 77 108 MutationRate = 0.15; 78 109 engine = new SequentialEngine.SequentialEngine(); 79 CreateAlgorithm(); 80 } 81 82 public void Reset() { 83 engine.Reset(); 84 } 85 86 private void Run() { 87 Reset(); 88 } 89 90 private void CreateAlgorithm() { 91 SequentialProcessor seq = new SequentialProcessor(); 110 CombinedOperator algo = CreateAlgorithm(); 111 engine.OperatorGraph.AddOperator(algo); 112 engine.OperatorGraph.InitialOperator = algo; 113 } 114 115 private CombinedOperator CreateAlgorithm() { 116 CombinedOperator algo = new CombinedOperator(); 117 algo.Name = "StandardGP"; 118 SequentialProcessor seq = new SequentialProcessor(); 119 EmptyOperator problemInjectorPlaceholder = new EmptyOperator(); 92 120 RandomInjector randomInjector = new RandomInjector(); 121 randomInjector.GetVariable("SetSeedRandomly").Value = setSeedRandomly; 122 randomInjector.GetVariable("Seed").Value = seed; 93 123 randomInjector.Name = "Random Injector"; 94 124 VariableInjector globalInjector = CreateGlobalInjector(); … … 104 134 treeCreator.Name = "Tree generator"; 105 135 treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 136 treeCreator.GetVariableInfo("MinTreeSize").Local = true; 137 treeCreator.AddVariable(new HeuristicLab.Core.Variable("MinTreeSize", new IntData(3))); 106 138 MeanSquaredErrorEvaluator evaluator = new MeanSquaredErrorEvaluator(); 107 139 evaluator.GetVariableInfo("MSE").ActualName = "Quality"; … … 121 153 selector.GetVariableInfo("GroupSize").ActualName = "TournamentSize"; 122 154 155 seq.AddSubOperator(problemInjectorPlaceholder); 123 156 seq.AddSubOperator(randomInjector); 124 157 seq.AddSubOperator(globalInjector); … … 135 168 mainLoop.AddSubOperator(manipulator); 136 169 mainLoop.AddSubOperator(evaluator); 137 engine.OperatorGraph.AddOperator(seq); 138 engine.OperatorGraph.InitialOperator = seq; 170 algo.OperatorGraph.AddOperator(seq); 171 algo.OperatorGraph.InitialOperator = seq; 172 this.algorithm = seq; 173 return algo; 139 174 } 140 175 … … 147 182 injector.AddVariable(new HeuristicLab.Core.Variable("PopulationSize", populationSize)); 148 183 injector.AddVariable(new HeuristicLab.Core.Variable("Parents", parents)); 149 injector.AddVariable(new HeuristicLab.Core.Variable("Elites", new IntData(1))); 184 injector.AddVariable(new HeuristicLab.Core.Variable("Elites", elites)); 185 injector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", tournamentSize)); 150 186 injector.AddVariable(new HeuristicLab.Core.Variable("Maximization", new BoolData(false))); 151 187 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeHeight", new IntData(maxTreeHeight))); … … 160 196 CombinedOperator manipulator = new CombinedOperator(); 161 197 StochasticMultiBranch multibranch = new StochasticMultiBranch(); 162 163 198 FullTreeShaker fullTreeShaker = new FullTreeShaker(); 164 199 fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; … … 179 214 substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 180 215 181 multibranch.AddSubOperator(fullTreeShaker); 182 multibranch.AddSubOperator(onepointShaker); 183 multibranch.AddSubOperator(changeNodeTypeManipulation); 184 multibranch.AddSubOperator(cutOutNodeManipulation); 185 multibranch.AddSubOperator(deleteSubTreeManipulation); 186 multibranch.AddSubOperator(substituteSubTreeManipulation); 216 IOperator[] manipulators = new IOperator[] { 217 onepointShaker, fullTreeShaker, 218 changeNodeTypeManipulation, 219 cutOutNodeManipulation, 220 deleteSubTreeManipulation, 221 substituteSubTreeManipulation}; 222 223 DoubleArrayData probabilities = new DoubleArrayData(new double[manipulators.Length]); 224 for(int i=0;i<manipulators.Length;i++) { 225 probabilities.Data[i] = 1.0; 226 multibranch.AddSubOperator(manipulators[i]); 227 } 228 multibranch.GetVariableInfo("Probabilities").Local = true; 229 multibranch.AddVariable(new HeuristicLab.Core.Variable("Probabilities", probabilities)); 230 187 231 manipulator.OperatorGraph.AddOperator(multibranch); 188 232 manipulator.OperatorGraph.InitialOperator = multibranch; … … 194 238 SequentialProcessor seq = new SequentialProcessor(); 195 239 SubScopesCreater subScopesCreater = new SubScopesCreater(); 240 subScopesCreater.GetVariableInfo("SubScopes").ActualName = "PopulationSize"; 196 241 UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor(); 197 242 SequentialProcessor individualSeq = new SequentialProcessor(); … … 202 247 evaluator.Name = "Evaluator (extr.)"; 203 248 evaluator.GetVariableInfo("Operator").ActualName = "Evaluator"; 204 249 205 250 seq.AddSubOperator(subScopesCreater); 206 251 seq.AddSubOperator(subScopesProc); … … 237 282 comparator.GetVariableInfo("RightSide").ActualName = "MaxGenerations"; 238 283 comparator.GetVariableInfo("Result").ActualName = "GenerationsCondition"; 239 240 284 ConditionalBranch cond = new ConditionalBranch(); 241 285 cond.GetVariableInfo("Condition").ActualName = "GenerationsCondition"; 286 287 seq.AddSubOperator(childCreater); 288 seq.AddSubOperator(replacement); 289 seq.AddSubOperator(qualityCalculator); 290 seq.AddSubOperator(collector); 291 seq.AddSubOperator(lineChartInjector); 292 seq.AddSubOperator(qualityLogger); 293 seq.AddSubOperator(counter); 294 seq.AddSubOperator(comparator); 295 seq.AddSubOperator(cond); 296 cond.AddSubOperator(seq); 297 242 298 main.OperatorGraph.AddOperator(seq); 243 299 main.OperatorGraph.InitialOperator = seq; … … 253 309 leftSelector.GetVariableInfo("Selected").ActualName = "Elites"; 254 310 RightReducer rightReducer = new RightReducer(); 255 311 256 312 SequentialProcessor remainingProc = new SequentialProcessor(); 257 313 RightSelector rightSelector = new RightSelector(); … … 303 359 sorter.GetVariableInfo("Descending").ActualName = "Maximization"; 304 360 sorter.GetVariableInfo("Value").ActualName = "Quality"; 305 361 306 362 307 363 seq.AddSubOperator(selector); … … 321 377 return childCreater; 322 378 } 379 380 public IEditor CreateEditor() { 381 return new StandardGpEditor(this); 382 } 383 384 public IView CreateView() { 385 return new StandardGpEditor(this); 386 } 323 387 } 324 388 }
Note: See TracChangeset
for help on using the changeset viewer.