Changeset 1262 for branches/CEDMA-Refactoring-Ticket419
- Timestamp:
- 03/05/09 18:32:59 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/OffspringSelectionGP.cs
r1254 r1262 34 34 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 35 35 public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP { 36 private BoolData autoregressive = new BoolData(); 37 public bool Autoregressive { 38 get { return autoregressive.Data; } 39 set { autoregressive.Data = value; } 36 public virtual bool Autoregressive { 37 get { return GetVariableInjector().GetVariable("Autoregressive").GetValue<BoolData>().Data; } 38 set { GetVariableInjector().GetVariable("Autoregressive").GetValue<BoolData>().Data = value; } 40 39 } 41 40 42 41 protected override IOperator CreateFunctionLibraryInjector() { 43 42 return new FunctionLibraryInjector(); … … 50 49 protected override IOperator CreateGlobalInjector() { 51 50 VariableInjector injector = (VariableInjector)base.CreateGlobalInjector(); 52 injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", autoregressive));51 injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", new BoolData())); 53 52 return injector; 54 53 } … … 67 66 return new OffspringSelectionGpEditor(this); 68 67 } 68 69 public override object Clone(IDictionary<Guid, object> clonedObjects) { 70 OffspringSelectionGP clone = (OffspringSelectionGP)base.Clone(clonedObjects); 71 clone.Autoregressive = Autoregressive; 72 return clone; 73 } 69 74 } 70 75 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/OffspringSelectionGpEditor.cs
r1253 r1262 19 19 20 20 protected override void SetDataBinding() { 21 base.SetDataBinding(); 21 base.SetDataBinding(); 22 22 autoregressionCheckbox.DataBindings.Add("Checked", OffspringSelectionGP, "Autoregressive"); 23 23 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/StandardGP.cs
r1254 r1262 34 34 namespace HeuristicLab.GP.StructureIdentification.TimeSeries { 35 35 public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP { 36 private BoolData autoregressive = new BoolData();37 36 public bool Autoregressive { 38 get { return autoregressive.Data; }39 set { autoregressive.Data = value; }37 get { return GetVariableInjector().GetVariable("Autoregressive").GetValue<BoolData>().Data; } 38 set { GetVariableInjector().GetVariable("Autoregressive").GetValue<BoolData>().Data = value; } 40 39 } 41 40 … … 50 49 protected override IOperator CreateGlobalInjector() { 51 50 VariableInjector injector = (VariableInjector)base.CreateGlobalInjector(); 52 injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", autoregressive));51 injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", new BoolData())); 53 52 return injector; 54 53 } … … 138 137 } 139 138 } 139 public override object Clone(IDictionary<Guid, object> clonedObjects) { 140 OffspringSelectionGP clone = (OffspringSelectionGP)base.Clone(clonedObjects); 141 clone.Autoregressive = Autoregressive; 142 return clone; 143 } 140 144 } 141 145 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/AlgorithmBase.cs
r1251 r1262 37 37 namespace HeuristicLab.GP.StructureIdentification { 38 38 public abstract class AlgorithmBase : ItemBase { 39 private DoubleData mutationRate = new DoubleData();40 39 public virtual double MutationRate { 41 get { return mutationRate.Data; } 42 set { mutationRate.Data = value; } 43 } 44 private IntData populationSize = new IntData(); 40 get { return GetVariableInjector().GetVariable("MutationRate").GetValue<DoubleData>().Data; } 41 set { GetVariableInjector().GetVariable("MutationRate").GetValue<DoubleData>().Data = value; } 42 } 45 43 public virtual int PopulationSize { 46 get { return populationSize.Data; } 47 set { 48 populationSize.Data = value; 49 } 50 } 51 52 private BoolData setSeedRandomly = new BoolData(); 44 get { return GetVariableInjector().GetVariable("PopulationSize").GetValue<IntData>().Data; } 45 set { GetVariableInjector().GetVariable("PopulationSize").GetValue<IntData>().Data = value; } 46 } 47 53 48 public virtual bool SetSeedRandomly { 54 get { return setSeedRandomly.Data; } 55 set { setSeedRandomly.Data = value; } 56 } 57 58 private IntData seed = new IntData(); 49 get { return GetRandomInjector().GetVariable("SetSeedRandomly").GetValue<BoolData>().Data; } 50 set { GetRandomInjector().GetVariable("SetSeedRandomly").GetValue<BoolData>().Data = value; } 51 } 52 59 53 public virtual int Seed { 60 get { return seed.Data; }61 set { seed.Data = value; }54 get { return GetRandomInjector().GetVariable("Seed").GetValue<IntData>().Data; } 55 set { GetRandomInjector().GetVariable("Seed").GetValue<IntData>().Data = value; } 62 56 } 63 57 … … 71 65 } 72 66 73 private IntData elites = new IntData();74 67 public virtual int Elites { 75 get { return elites.Data; } 76 set { elites.Data = value; } 77 } 78 79 private int maxTreeSize = 50; 68 get { return GetVariableInjector().GetVariable("Elites").GetValue<IntData>().Data; } 69 set { GetVariableInjector().GetVariable("Elites").GetValue<IntData>().Data = value; } 70 } 71 80 72 public virtual int MaxTreeSize { 81 get { return maxTreeSize; } 82 set { maxTreeSize = value; } 83 } 84 85 private int maxTreeHeight = 8; 73 get { return GetVariableInjector().GetVariable("MaxTreeSize").GetValue<IntData>().Data; } 74 set { GetVariableInjector().GetVariable("MaxTreeSize").GetValue<IntData>().Data = value; } 75 } 76 86 77 public virtual int MaxTreeHeight { 87 get { return maxTreeHeight; } 88 set { maxTreeHeight = value; } 89 } 90 91 private IntData parents = new IntData(); 78 get { return GetVariableInjector().GetVariable("MaxTreeHeight").GetValue<IntData>().Data; } 79 set { GetVariableInjector().GetVariable("MaxTreeHeight").GetValue<IntData>().Data = value; } 80 } 81 92 82 public virtual int Parents { 93 get { return parents.Data; } 94 protected set { parents.Data = value; } 95 } 96 97 private double punishmentFactor = 10.0; 98 private bool useEstimatedTargetValue = false; 83 get { return GetVariableInjector().GetVariable("Parents").GetValue<IntData>().Data; } 84 set { GetVariableInjector().GetVariable("Parents").GetValue<IntData>().Data = value; } 85 } 86 87 public virtual double PunishmentFactor { 88 get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; } 89 set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; } 90 } 91 92 public virtual bool UseEstimatedTargetValue { 93 get { return GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data; } 94 set { GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data = value; } 95 } 96 99 97 private IOperator algorithm; 100 98 … … 119 117 120 118 RandomInjector randomInjector = new RandomInjector(); 121 randomInjector.GetVariable("SetSeedRandomly").Value = setSeedRandomly;122 randomInjector.GetVariable("Seed").Value = seed;123 119 randomInjector.Name = "Random Injector"; 124 120 125 121 IOperator globalInjector = CreateGlobalInjector(); 126 122 IOperator initialization = CreateInitialization(); 127 IOperator funLibInjector = CreateFunctionLibraryInjector(); 123 IOperator funLibInjector = CreateFunctionLibraryInjector(); 128 124 IOperator mainLoop = CreateMainLoop(); 129 125 mainLoop.Name = "Main loop"; 130 126 131 127 IOperator treeCreator = CreateTreeCreator(); 132 128 133 129 MeanSquaredErrorEvaluator evaluator = new MeanSquaredErrorEvaluator(); 134 130 evaluator.GetVariableInfo("MSE").ActualName = "Quality"; … … 136 132 evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd"; 137 133 evaluator.Name = "Evaluator"; 138 134 139 135 IOperator crossover = CreateCrossover(); 140 136 IOperator manipulator = CreateManipulator(); … … 180 176 injector.Name = "Global Injector"; 181 177 injector.AddVariable(new HeuristicLab.Core.Variable("Generations", new IntData(0))); 182 injector.AddVariable(new HeuristicLab.Core.Variable("MutationRate", mutationRate));183 injector.AddVariable(new HeuristicLab.Core.Variable("PopulationSize", populationSize));184 injector.AddVariable(new HeuristicLab.Core.Variable("Elites", elites));178 injector.AddVariable(new HeuristicLab.Core.Variable("MutationRate", new DoubleData())); 179 injector.AddVariable(new HeuristicLab.Core.Variable("PopulationSize", new IntData())); 180 injector.AddVariable(new HeuristicLab.Core.Variable("Elites", new IntData())); 185 181 injector.AddVariable(new HeuristicLab.Core.Variable("Maximization", new BoolData(false))); 186 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeHeight", new IntData( maxTreeHeight)));187 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeSize", new IntData( maxTreeSize)));182 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeHeight", new IntData())); 183 injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeSize", new IntData())); 188 184 injector.AddVariable(new HeuristicLab.Core.Variable("EvaluatedSolutions", new IntData(0))); 189 185 injector.AddVariable(new HeuristicLab.Core.Variable("TotalEvaluatedNodes", new DoubleData(0))); 190 injector.AddVariable(new HeuristicLab.Core.Variable("Parents", parents));191 injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData( punishmentFactor)));192 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData( useEstimatedTargetValue)));186 injector.AddVariable(new HeuristicLab.Core.Variable("Parents", new IntData())); 187 injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData())); 188 injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData())); 193 189 return injector; 194 190 } … … 392 388 } 393 389 394 #region SetReferences Method 395 private void SetReferences() { 396 // SGA 390 protected VariableInjector GetVariableInjector() { 397 391 CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator; 398 // SequentialProcessor in SGA392 // SequentialProcessor in GP 399 393 algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator; 400 // RandomInjector 401 RandomInjector ri = (RandomInjector)algorithm.SubOperators[1]; 402 setSeedRandomly = ri.GetVariable("SetSeedRandomly").GetValue<BoolData>(); 403 seed = ri.GetVariable("Seed").GetValue<IntData>(); 404 // VariableInjector 405 VariableInjector vi = (VariableInjector)algorithm.SubOperators[2]; 406 populationSize = vi.GetVariable("PopulationSize").GetValue<IntData>(); 407 mutationRate = vi.GetVariable("MutationRate").GetValue<DoubleData>(); 408 elites = vi.GetVariable("Elites").GetValue<IntData>(); 409 parents = vi.GetVariable("Parents").GetValue<IntData>(); 410 } 411 #endregion 394 return (VariableInjector)algorithm.SubOperators[2]; 395 } 396 397 protected RandomInjector GetRandomInjector() { 398 CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator; 399 // SequentialProcessor in GP 400 algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator; 401 return (RandomInjector)algorithm.SubOperators[1]; 402 } 412 403 413 404 #region Persistence Methods … … 420 411 base.Populate(node, restoredObjects); 421 412 engine = (SequentialEngine.SequentialEngine)PersistenceManager.Restore(node.SelectSingleNode("Engine"), restoredObjects); 422 SetReferences();423 413 } 424 414 #endregion -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffSpringSelectionGpEditor.Designer.cs
r1253 r1262 49 49 this.tabControl = new System.Windows.Forms.TabControl(); 50 50 this.parametersTabPage = new System.Windows.Forms.TabPage(); 51 this.selectionPressureTextBox = new System.Windows.Forms.TextBox(); 52 this.selectionPressureLabel = new System.Windows.Forms.Label(); 51 53 this.viewProblemInitializationButton = new System.Windows.Forms.Button(); 52 54 this.setProblemInitializationButton = new System.Windows.Forms.Button(); … … 58 60 this.mutationRateTextBox = new System.Windows.Forms.TextBox(); 59 61 this.mutationRateLabel = new System.Windows.Forms.Label(); 60 this.maximum GenerationsTextBox = new System.Windows.Forms.TextBox();61 this.max imumGenerationsLabel = new System.Windows.Forms.Label();62 this.maximumEvaluatedSolutionsTextBox = new System.Windows.Forms.TextBox(); 63 this.maxEvaluatedSolutionsLabel = new System.Windows.Forms.Label(); 62 64 this.randomSeedTextBox = new System.Windows.Forms.TextBox(); 63 65 this.populationSizeTextBox = new System.Windows.Forms.TextBox(); … … 70 72 this.resetButton = new System.Windows.Forms.Button(); 71 73 this.cloneEngineButton = new System.Windows.Forms.Button(); 72 this.selectionPressureTextBox = new System.Windows.Forms.TextBox();73 this.selectionPressureLabel = new System.Windows.Forms.Label();74 74 this.tabControl.SuspendLayout(); 75 75 this.parametersTabPage.SuspendLayout(); … … 114 114 this.parametersTabPage.Controls.Add(this.mutationRateTextBox); 115 115 this.parametersTabPage.Controls.Add(this.mutationRateLabel); 116 this.parametersTabPage.Controls.Add(this.maximum GenerationsTextBox);117 this.parametersTabPage.Controls.Add(this.max imumGenerationsLabel);116 this.parametersTabPage.Controls.Add(this.maximumEvaluatedSolutionsTextBox); 117 this.parametersTabPage.Controls.Add(this.maxEvaluatedSolutionsLabel); 118 118 this.parametersTabPage.Controls.Add(this.randomSeedTextBox); 119 119 this.parametersTabPage.Controls.Add(this.populationSizeTextBox); … … 129 129 this.parametersTabPage.UseVisualStyleBackColor = true; 130 130 // 131 // selectionPressureTextBox 132 // 133 this.selectionPressureTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 134 this.selectionPressureTextBox.Location = new System.Drawing.Point(218, 130); 135 this.selectionPressureTextBox.Name = "selectionPressureTextBox"; 136 this.selectionPressureTextBox.Size = new System.Drawing.Size(186, 20); 137 this.selectionPressureTextBox.TabIndex = 17; 138 // 139 // selectionPressureLabel 140 // 141 this.selectionPressureLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 142 this.selectionPressureLabel.AutoSize = true; 143 this.selectionPressureLabel.Location = new System.Drawing.Point(65, 133); 144 this.selectionPressureLabel.Name = "selectionPressureLabel"; 145 this.selectionPressureLabel.Size = new System.Drawing.Size(145, 13); 146 this.selectionPressureLabel.TabIndex = 16; 147 this.selectionPressureLabel.Text = "Maximum &Selection Pressure:"; 148 // 131 149 // viewProblemInitializationButton 132 150 // … … 169 187 this.setRandomSeedRandomlyCheckBox.TabIndex = 1; 170 188 this.setRandomSeedRandomlyCheckBox.UseVisualStyleBackColor = true; 189 this.setRandomSeedRandomlyCheckBox.CheckedChanged += new System.EventHandler(this.setRandomSeedRandomlyCheckBox_CheckedChanged); 171 190 // 172 191 // elitesTextBox … … 216 235 this.mutationRateLabel.Text = "&Mutation Rate:"; 217 236 // 218 // maximum GenerationsTextBox219 // 220 this.maximum GenerationsTextBox.Anchor = System.Windows.Forms.AnchorStyles.None;221 this.maximum GenerationsTextBox.Location = new System.Drawing.Point(218, 104);222 this.maximum GenerationsTextBox.Name = "maximumGenerationsTextBox";223 this.maximum GenerationsTextBox.Size = new System.Drawing.Size(186, 20);224 this.maximum GenerationsTextBox.TabIndex = 7;225 // 226 // max imumGenerationsLabel227 // 228 this.max imumGenerationsLabel.Anchor = System.Windows.Forms.AnchorStyles.None;229 this.max imumGenerationsLabel.AutoSize = true;230 this.max imumGenerationsLabel.Location = new System.Drawing.Point(65, 107);231 this.max imumGenerationsLabel.Name = "maximumGenerationsLabel";232 this.max imumGenerationsLabel.Size = new System.Drawing.Size(114, 13);233 this.max imumGenerationsLabel.TabIndex = 6;234 this.max imumGenerationsLabel.Text = "Maximum &Generations:";237 // maximumEvaluatedSolutionsTextBox 238 // 239 this.maximumEvaluatedSolutionsTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 240 this.maximumEvaluatedSolutionsTextBox.Location = new System.Drawing.Point(218, 104); 241 this.maximumEvaluatedSolutionsTextBox.Name = "maximumEvaluatedSolutionsTextBox"; 242 this.maximumEvaluatedSolutionsTextBox.Size = new System.Drawing.Size(186, 20); 243 this.maximumEvaluatedSolutionsTextBox.TabIndex = 7; 244 // 245 // maxEvaluatedSolutionsLabel 246 // 247 this.maxEvaluatedSolutionsLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 248 this.maxEvaluatedSolutionsLabel.AutoSize = true; 249 this.maxEvaluatedSolutionsLabel.Location = new System.Drawing.Point(65, 107); 250 this.maxEvaluatedSolutionsLabel.Name = "maxEvaluatedSolutionsLabel"; 251 this.maxEvaluatedSolutionsLabel.Size = new System.Drawing.Size(130, 13); 252 this.maxEvaluatedSolutionsLabel.TabIndex = 6; 253 this.maxEvaluatedSolutionsLabel.Text = "Max. E&valuated Solutions:"; 235 254 // 236 255 // randomSeedTextBox … … 334 353 this.cloneEngineButton.UseVisualStyleBackColor = true; 335 354 this.cloneEngineButton.Click += new System.EventHandler(this.cloneEngineButton_Click); 336 //337 // selectionPressureTextBox338 //339 this.selectionPressureTextBox.Anchor = System.Windows.Forms.AnchorStyles.None;340 this.selectionPressureTextBox.Location = new System.Drawing.Point(218, 130);341 this.selectionPressureTextBox.Name = "selectionPressureTextBox";342 this.selectionPressureTextBox.Size = new System.Drawing.Size(186, 20);343 this.selectionPressureTextBox.TabIndex = 17;344 //345 // selectionPressureLabel346 //347 this.selectionPressureLabel.Anchor = System.Windows.Forms.AnchorStyles.None;348 this.selectionPressureLabel.AutoSize = true;349 this.selectionPressureLabel.Location = new System.Drawing.Point(65, 133);350 this.selectionPressureLabel.Name = "selectionPressureLabel";351 this.selectionPressureLabel.Size = new System.Drawing.Size(145, 13);352 this.selectionPressureLabel.TabIndex = 16;353 this.selectionPressureLabel.Text = "Maximum &Selection Pressure:";354 355 // 355 356 // OffspringSelectionGpEditor … … 384 385 private System.Windows.Forms.Label populationSizeLabel; 385 386 private System.Windows.Forms.TabPage scopesTabPage; 386 private System.Windows.Forms.TextBox maximum GenerationsTextBox;387 private System.Windows.Forms.Label max imumGenerationsLabel;387 private System.Windows.Forms.TextBox maximumEvaluatedSolutionsTextBox; 388 private System.Windows.Forms.Label maxEvaluatedSolutionsLabel; 388 389 private System.Windows.Forms.TextBox elitesTextBox; 389 390 private System.Windows.Forms.Label elitesLabel; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffSpringSelectionGpEditor.cs
r1253 r1262 76 76 randomSeedTextBox.DataBindings.Add("Text", OffspringSelectionGP, "Seed"); 77 77 populationSizeTextBox.DataBindings.Add("Text", OffspringSelectionGP, "PopulationSize"); 78 maximum GenerationsTextBox.DataBindings.Add("Text", OffspringSelectionGP, "MaxGenerations");78 maximumEvaluatedSolutionsTextBox.DataBindings.Add("Text", OffspringSelectionGP, "MaxEvaluatedSolutions"); 79 79 selectionPressureTextBox.DataBindings.Add("Text", OffspringSelectionGP, "SelectionPressureLimit"); 80 80 mutationRateTextBox.DataBindings.Add("Text", OffspringSelectionGP, "MutationRate"); … … 134 134 } 135 135 #endregion 136 137 private void setRandomSeedRandomlyCheckBox_CheckedChanged(object sender, EventArgs e) { 138 randomSeedTextBox.Enabled = !setRandomSeedRandomlyCheckBox.Checked; 139 randomSeedLabel.Enabled = !setRandomSeedRandomlyCheckBox.Checked; 140 } 136 141 } 137 142 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffspringSelectionGP.cs
r1245 r1262 39 39 public class OffspringSelectionGP : StandardGP { 40 40 41 private IntData maxEvaluatedSolutions = new IntData(); 42 public int MaxEvaluatedSolutions { 43 get { return maxEvaluatedSolutions.Data; } 44 set { maxEvaluatedSolutions.Data = value; } 45 } 46 47 private DoubleData selectionPressureLimit = new DoubleData(); 48 public double SelectionPressureLimit { 49 get { return selectionPressureLimit.Data; } 50 set { selectionPressureLimit.Data = value; } 51 } 52 53 private DoubleData comparisonFactor = new DoubleData(); 54 public double ComparisonFactor { 55 get { return comparisonFactor.Data; } 56 set { comparisonFactor.Data = value; } 57 } 58 59 private DoubleData successRatioLimit = new DoubleData(); 60 public double SuccessRatioLimit { 61 get { return successRatioLimit.Data; } 62 set { successRatioLimit.Data = value; } 63 } 64 65 public OffspringSelectionGP() : base() { 41 public virtual int MaxEvaluatedSolutions { 42 get { return GetVariableInjector().GetVariable("MaxEvaluatedSolutions").GetValue<IntData>().Data; } 43 set { GetVariableInjector().GetVariable("MaxEvaluatedSolutions").GetValue<IntData>().Data = value; } 44 } 45 46 public virtual double SelectionPressureLimit { 47 get { return GetVariableInjector().GetVariable("SelectionPressureLimit").GetValue<DoubleData>().Data; } 48 set { GetVariableInjector().GetVariable("SelectionPressureLimit").GetValue<DoubleData>().Data = value; } 49 } 50 51 public virtual double ComparisonFactor { 52 get { return GetVariableInjector().GetVariable("ComparisonFactor").GetValue<DoubleData>().Data; } 53 set { GetVariableInjector().GetVariable("ComparisonFactor").GetValue<DoubleData>().Data = value; } 54 } 55 56 public virtual double SuccessRatioLimit { 57 get { return GetVariableInjector().GetVariable("SuccessRatioLimit").GetValue<DoubleData>().Data; } 58 set { GetVariableInjector().GetVariable("SuccessRatioLimit").GetValue<DoubleData>().Data = value; } 59 } 60 61 public override int MaxGenerations { 62 get { throw new NotSupportedException(); } 63 set { /* ignore */ } 64 } 65 66 public override int TournamentSize { 67 get { throw new NotSupportedException(); } 68 set { /* ignore */ } 69 } 70 71 public OffspringSelectionGP() 72 : base() { 66 73 PopulationSize = 1000; 67 74 Parents = 20; … … 76 83 injector.RemoveVariable("TournamentSize"); 77 84 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));85 injector.AddVariable(new HeuristicLab.Core.Variable("MaxEvaluatedSolutions", new IntData())); 86 injector.AddVariable(new HeuristicLab.Core.Variable("ComparisonFactor", new DoubleData())); 87 injector.AddVariable(new HeuristicLab.Core.Variable("SelectionPressureLimit", new DoubleData())); 88 injector.AddVariable(new HeuristicLab.Core.Variable("SuccessRatioLimit", new DoubleData())); 82 89 return injector; 83 90 } … … 199 206 selPresComparator.GetVariableInfo("RightSide").ActualName = "SelectionPressureLimit"; 200 207 selPresComparator.GetVariableInfo("Result").ActualName = "SelectionPressureCondition"; 201 208 202 209 ConditionalBranch generationsCond = new ConditionalBranch(); 203 210 generationsCond.GetVariableInfo("Condition").ActualName = "EvaluatedSolutionsCondition"; … … 261 268 return clone; 262 269 } 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 270 } 291 271 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGP.cs
r1252 r1262 38 38 public class StandardGP : AlgorithmBase, IEditable { 39 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(); 40 public virtual int MaxGenerations { 41 get { return GetVariableInjector().GetVariable("MaxGenerations").GetValue<IntData>().Data; } 42 set { GetVariableInjector().GetVariable("MaxGenerations").GetValue<IntData>().Data = value; } 43 } 44 45 public virtual int TournamentSize { 46 get { return GetVariableInjector().GetVariable("TournamentSize").GetValue<IntData>().Data; } 47 set { GetVariableInjector().GetVariable("TournamentSize").GetValue<IntData>().Data = value; } 48 } 49 53 50 public double FullTreeShakingFactor { 54 get { return fullTreeShakingFactor.Data; } 55 set { fullTreeShakingFactor.Data = value; } 56 } 57 58 private DoubleData onepointShakingFactor = new DoubleData(); 51 get { return GetVariableInjector().GetVariable("FullTreeShakingFactor").GetValue<DoubleData>().Data; } 52 set { GetVariableInjector().GetVariable("FullTreeShakingFactor").GetValue<DoubleData>().Data = value; } 53 } 54 59 55 public double OnePointShakingFactor { 60 get { return onepointShakingFactor.Data; }61 set { onepointShakingFactor.Data = value; }56 get { return GetVariableInjector().GetVariable("OnePointShakingFactor").GetValue<DoubleData>().Data; } 57 set { GetVariableInjector().GetVariable("OnePointShakingFactor").GetValue<DoubleData>().Data = value; } 62 58 } 63 59 … … 83 79 FullTreeShakingFactor = 0.1; 84 80 OnePointShakingFactor = 1.0; 85 Engine = new SequentialEngine.SequentialEngine(); 86 IOperator algo = CreateAlgorithm(); 87 Engine.OperatorGraph.AddOperator(algo); 88 Engine.OperatorGraph.InitialOperator = algo; 81 PunishmentFactor = 10.0; 82 UseEstimatedTargetValue = false; 83 SetSeedRandomly = true; 89 84 } 90 85 … … 105 100 protected internal override IOperator CreateGlobalInjector() { 106 101 VariableInjector globalInjector = (VariableInjector)base.CreateGlobalInjector(); 107 globalInjector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", tournamentSize)); 108 globalInjector.AddVariable(new HeuristicLab.Core.Variable("MaxGenerations", maxGenerations)); 102 globalInjector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", new IntData())); 103 globalInjector.AddVariable(new HeuristicLab.Core.Variable("MaxGenerations", new IntData())); 104 globalInjector.AddVariable(new HeuristicLab.Core.Variable("FullTreeShakingFactor", new DoubleData())); 105 globalInjector.AddVariable(new HeuristicLab.Core.Variable("OnePointShakingFactor", new DoubleData())); 109 106 return globalInjector; 110 107 } … … 136 133 FullTreeShaker fullTreeShaker = new FullTreeShaker(); 137 134 fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 138 fullTreeShaker.GetVariableInfo("ShakingFactor").Local = true; 139 fullTreeShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", fullTreeShakingFactor)); 135 fullTreeShaker.GetVariableInfo("ShakingFactor").ActualName = "FullTreeShakingFactor"; 140 136 141 137 OnePointShaker onepointShaker = new OnePointShaker(); 142 138 onepointShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; 143 onepointShaker.GetVariableInfo("ShakingFactor").Local = true; 144 onepointShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", onepointShakingFactor)); 139 onepointShaker.GetVariableInfo("ShakingFactor").ActualName = "OnePointShakingFactor"; 145 140 ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation(); 146 141 changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary"; … … 248 243 return new StandardGpEditor(this); 249 244 } 250 251 public override object Clone(IDictionary<Guid, object> clonedObjects) {252 StandardGP clone = new StandardGP();253 clonedObjects.Add(Guid, clone);254 clone.Engine = (SequentialEngine.SequentialEngine)Auxiliary.Clone(Engine, clonedObjects);255 return clone;256 }257 258 #region SetReferences Method259 private void SetReferences() {260 // SGA261 CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;262 // SequentialProcessor in SGA263 SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;264 // RandomInjector265 RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];266 // VariableInjector267 VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];268 maxGenerations = vi.GetVariable("MaxGenerations").GetValue<IntData>();269 tournamentSize = vi.GetVariable("TournamentSize").GetValue<IntData>();270 }271 #endregion272 273 #region Persistence Methods274 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {275 XmlNode node = base.GetXmlNode(name, document, persistedObjects);276 node.AppendChild(PersistenceManager.Persist("Engine", Engine, document, persistedObjects));277 return node;278 }279 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {280 base.Populate(node, restoredObjects);281 Engine = (SequentialEngine.SequentialEngine)PersistenceManager.Restore(node.SelectSingleNode("Engine"), restoredObjects);282 SetReferences();283 }284 #endregion285 245 } 286 246 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGpEditor.Designer.cs
r1253 r1262 165 165 this.setRandomSeedRandomlyCheckBox.TabIndex = 1; 166 166 this.setRandomSeedRandomlyCheckBox.UseVisualStyleBackColor = true; 167 this.setRandomSeedRandomlyCheckBox.CheckedChanged += new System.EventHandler(this.setRandomSeedRandomlyCheckBox_CheckedChanged); 167 168 // 168 169 // elitesTextBox -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGpEditor.cs
r1253 r1262 133 133 #endregion 134 134 135 135 private void setRandomSeedRandomlyCheckBox_CheckedChanged(object sender, EventArgs e) { 136 randomSeedTextBox.Enabled = !setRandomSeedRandomlyCheckBox.Checked; 137 randomSeedLabel.Enabled = !setRandomSeedRandomlyCheckBox.Checked; 138 } 136 139 } 137 140 }
Note: See TracChangeset
for help on using the changeset viewer.