Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/09 18:32:59 (16 years ago)
Author:
gkronber
Message:

Fixed a few issues in persistence of hard-coded GP algorithms. #224 (Simple frontend for GP for non-expert users (similar to HeurisicLab.SGA))

Location:
branches/CEDMA-Refactoring-Ticket419
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/OffspringSelectionGP.cs

    r1254 r1262  
    3434namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
    3535  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; }
    4039    }
    41    
     40
    4241    protected override IOperator CreateFunctionLibraryInjector() {
    4342      return new FunctionLibraryInjector();
     
    5049    protected override IOperator CreateGlobalInjector() {
    5150      VariableInjector injector = (VariableInjector)base.CreateGlobalInjector();
    52       injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", autoregressive));
     51      injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", new BoolData()));
    5352      return injector;
    5453    }
     
    6766      return new OffspringSelectionGpEditor(this);
    6867    }
     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    }
    6974  }
    7075}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/OffspringSelectionGpEditor.cs

    r1253 r1262  
    1919
    2020    protected override void SetDataBinding() {
    21       base.SetDataBinding();
     21      base.SetDataBinding();     
    2222      autoregressionCheckbox.DataBindings.Add("Checked", OffspringSelectionGP, "Autoregressive");
    2323    }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/StandardGP.cs

    r1254 r1262  
    3434namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
    3535  public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP {
    36     private BoolData autoregressive = new BoolData();
    3736    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; }
    4039    }
    4140
     
    5049    protected override IOperator CreateGlobalInjector() {
    5150      VariableInjector injector = (VariableInjector)base.CreateGlobalInjector();
    52       injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", autoregressive));
     51      injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", new BoolData()));
    5352      return injector;
    5453    }
     
    138137      }
    139138    }
     139    public override object Clone(IDictionary<Guid, object> clonedObjects) {
     140      OffspringSelectionGP clone = (OffspringSelectionGP)base.Clone(clonedObjects);
     141      clone.Autoregressive = Autoregressive;
     142      return clone;
     143    }
    140144  }
    141145}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/AlgorithmBase.cs

    r1251 r1262  
    3737namespace HeuristicLab.GP.StructureIdentification {
    3838  public abstract class AlgorithmBase : ItemBase {
    39     private DoubleData mutationRate = new DoubleData();
    4039    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    }
    4543    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
    5348    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
    5953    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; }
    6256    }
    6357
     
    7165    }
    7266
    73     private IntData elites = new IntData();
    7467    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
    8072    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
    8677    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
    9282    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
    9997    private IOperator algorithm;
    10098
     
    119117
    120118      RandomInjector randomInjector = new RandomInjector();
    121       randomInjector.GetVariable("SetSeedRandomly").Value = setSeedRandomly;
    122       randomInjector.GetVariable("Seed").Value = seed;
    123119      randomInjector.Name = "Random Injector";
    124120
    125121      IOperator globalInjector = CreateGlobalInjector();
    126122      IOperator initialization = CreateInitialization();
    127       IOperator funLibInjector = CreateFunctionLibraryInjector(); 
     123      IOperator funLibInjector = CreateFunctionLibraryInjector();
    128124      IOperator mainLoop = CreateMainLoop();
    129125      mainLoop.Name = "Main loop";
    130126
    131127      IOperator treeCreator = CreateTreeCreator();
    132      
     128
    133129      MeanSquaredErrorEvaluator evaluator = new MeanSquaredErrorEvaluator();
    134130      evaluator.GetVariableInfo("MSE").ActualName = "Quality";
     
    136132      evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
    137133      evaluator.Name = "Evaluator";
    138      
     134
    139135      IOperator crossover = CreateCrossover();
    140136      IOperator manipulator = CreateManipulator();
     
    180176      injector.Name = "Global Injector";
    181177      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()));
    185181      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()));
    188184      injector.AddVariable(new HeuristicLab.Core.Variable("EvaluatedSolutions", new IntData(0)));
    189185      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()));
    193189      return injector;
    194190    }
     
    392388    }
    393389
    394     #region SetReferences Method
    395     private void SetReferences() {
    396       // SGA
     390    protected VariableInjector GetVariableInjector() {
    397391      CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    398       // SequentialProcessor in SGA
     392      // SequentialProcessor in GP
    399393      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    }
    412403
    413404    #region Persistence Methods
     
    420411      base.Populate(node, restoredObjects);
    421412      engine = (SequentialEngine.SequentialEngine)PersistenceManager.Restore(node.SelectSingleNode("Engine"), restoredObjects);
    422       SetReferences();
    423413    }
    424414    #endregion
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffSpringSelectionGpEditor.Designer.cs

    r1253 r1262  
    4949      this.tabControl = new System.Windows.Forms.TabControl();
    5050      this.parametersTabPage = new System.Windows.Forms.TabPage();
     51      this.selectionPressureTextBox = new System.Windows.Forms.TextBox();
     52      this.selectionPressureLabel = new System.Windows.Forms.Label();
    5153      this.viewProblemInitializationButton = new System.Windows.Forms.Button();
    5254      this.setProblemInitializationButton = new System.Windows.Forms.Button();
     
    5860      this.mutationRateTextBox = new System.Windows.Forms.TextBox();
    5961      this.mutationRateLabel = new System.Windows.Forms.Label();
    60       this.maximumGenerationsTextBox = new System.Windows.Forms.TextBox();
    61       this.maximumGenerationsLabel = new System.Windows.Forms.Label();
     62      this.maximumEvaluatedSolutionsTextBox = new System.Windows.Forms.TextBox();
     63      this.maxEvaluatedSolutionsLabel = new System.Windows.Forms.Label();
    6264      this.randomSeedTextBox = new System.Windows.Forms.TextBox();
    6365      this.populationSizeTextBox = new System.Windows.Forms.TextBox();
     
    7072      this.resetButton = new System.Windows.Forms.Button();
    7173      this.cloneEngineButton = new System.Windows.Forms.Button();
    72       this.selectionPressureTextBox = new System.Windows.Forms.TextBox();
    73       this.selectionPressureLabel = new System.Windows.Forms.Label();
    7474      this.tabControl.SuspendLayout();
    7575      this.parametersTabPage.SuspendLayout();
     
    114114      this.parametersTabPage.Controls.Add(this.mutationRateTextBox);
    115115      this.parametersTabPage.Controls.Add(this.mutationRateLabel);
    116       this.parametersTabPage.Controls.Add(this.maximumGenerationsTextBox);
    117       this.parametersTabPage.Controls.Add(this.maximumGenerationsLabel);
     116      this.parametersTabPage.Controls.Add(this.maximumEvaluatedSolutionsTextBox);
     117      this.parametersTabPage.Controls.Add(this.maxEvaluatedSolutionsLabel);
    118118      this.parametersTabPage.Controls.Add(this.randomSeedTextBox);
    119119      this.parametersTabPage.Controls.Add(this.populationSizeTextBox);
     
    129129      this.parametersTabPage.UseVisualStyleBackColor = true;
    130130      //
     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      //
    131149      // viewProblemInitializationButton
    132150      //
     
    169187      this.setRandomSeedRandomlyCheckBox.TabIndex = 1;
    170188      this.setRandomSeedRandomlyCheckBox.UseVisualStyleBackColor = true;
     189      this.setRandomSeedRandomlyCheckBox.CheckedChanged += new System.EventHandler(this.setRandomSeedRandomlyCheckBox_CheckedChanged);
    171190      //
    172191      // elitesTextBox
     
    216235      this.mutationRateLabel.Text = "&Mutation Rate:";
    217236      //
    218       // maximumGenerationsTextBox
    219       //
    220       this.maximumGenerationsTextBox.Anchor = System.Windows.Forms.AnchorStyles.None;
    221       this.maximumGenerationsTextBox.Location = new System.Drawing.Point(218, 104);
    222       this.maximumGenerationsTextBox.Name = "maximumGenerationsTextBox";
    223       this.maximumGenerationsTextBox.Size = new System.Drawing.Size(186, 20);
    224       this.maximumGenerationsTextBox.TabIndex = 7;
    225       //
    226       // maximumGenerationsLabel
    227       //
    228       this.maximumGenerationsLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    229       this.maximumGenerationsLabel.AutoSize = true;
    230       this.maximumGenerationsLabel.Location = new System.Drawing.Point(65, 107);
    231       this.maximumGenerationsLabel.Name = "maximumGenerationsLabel";
    232       this.maximumGenerationsLabel.Size = new System.Drawing.Size(114, 13);
    233       this.maximumGenerationsLabel.TabIndex = 6;
    234       this.maximumGenerationsLabel.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:";
    235254      //
    236255      // randomSeedTextBox
     
    334353      this.cloneEngineButton.UseVisualStyleBackColor = true;
    335354      this.cloneEngineButton.Click += new System.EventHandler(this.cloneEngineButton_Click);
    336       //
    337       // selectionPressureTextBox
    338       //
    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       // selectionPressureLabel
    346       //
    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:";
    354355      //
    355356      // OffspringSelectionGpEditor
     
    384385    private System.Windows.Forms.Label populationSizeLabel;
    385386    private System.Windows.Forms.TabPage scopesTabPage;
    386     private System.Windows.Forms.TextBox maximumGenerationsTextBox;
    387     private System.Windows.Forms.Label maximumGenerationsLabel;
     387    private System.Windows.Forms.TextBox maximumEvaluatedSolutionsTextBox;
     388    private System.Windows.Forms.Label maxEvaluatedSolutionsLabel;
    388389    private System.Windows.Forms.TextBox elitesTextBox;
    389390    private System.Windows.Forms.Label elitesLabel;
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffSpringSelectionGpEditor.cs

    r1253 r1262  
    7676      randomSeedTextBox.DataBindings.Add("Text", OffspringSelectionGP, "Seed");
    7777      populationSizeTextBox.DataBindings.Add("Text", OffspringSelectionGP, "PopulationSize");
    78       maximumGenerationsTextBox.DataBindings.Add("Text", OffspringSelectionGP, "MaxGenerations");
     78      maximumEvaluatedSolutionsTextBox.DataBindings.Add("Text", OffspringSelectionGP, "MaxEvaluatedSolutions");
    7979      selectionPressureTextBox.DataBindings.Add("Text", OffspringSelectionGP, "SelectionPressureLimit");
    8080      mutationRateTextBox.DataBindings.Add("Text", OffspringSelectionGP, "MutationRate");
     
    134134    }
    135135    #endregion
     136
     137    private void setRandomSeedRandomlyCheckBox_CheckedChanged(object sender, EventArgs e) {
     138      randomSeedTextBox.Enabled = !setRandomSeedRandomlyCheckBox.Checked;
     139      randomSeedLabel.Enabled = !setRandomSeedRandomlyCheckBox.Checked;
     140    }
    136141  }
    137142}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffspringSelectionGP.cs

    r1245 r1262  
    3939  public class OffspringSelectionGP : StandardGP {
    4040
    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() {
    6673      PopulationSize = 1000;
    6774      Parents = 20;
     
    7683      injector.RemoveVariable("TournamentSize");
    7784      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()));
    8289      return injector;
    8390    }
     
    199206      selPresComparator.GetVariableInfo("RightSide").ActualName = "SelectionPressureLimit";
    200207      selPresComparator.GetVariableInfo("Result").ActualName = "SelectionPressureCondition";
    201      
     208
    202209      ConditionalBranch generationsCond = new ConditionalBranch();
    203210      generationsCond.GetVariableInfo("Condition").ActualName = "EvaluatedSolutionsCondition";
     
    261268      return clone;
    262269    }
    263 
    264     #region SetReferences Method
    265     private void SetReferences() {
    266       // SGA
    267       CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    268       // SequentialProcessor in SGA
    269       SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
    270       // RandomInjector
    271       RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];
    272       // VariableInjector
    273       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     #endregion
    279 
    280     #region Persistence Methods
    281     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     #endregion
    290270  }
    291271}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGP.cs

    r1252 r1262  
    3838  public class StandardGP : AlgorithmBase, IEditable {
    3939
    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
    5350    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
    5955    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; }
    6258    }
    6359
     
    8379      FullTreeShakingFactor = 0.1;
    8480      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;
    8984    }
    9085
     
    105100    protected internal override IOperator CreateGlobalInjector() {
    106101      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()));
    109106      return globalInjector;
    110107    }
     
    136133      FullTreeShaker fullTreeShaker = new FullTreeShaker();
    137134      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";
    140136
    141137      OnePointShaker onepointShaker = new OnePointShaker();
    142138      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";
    145140      ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation();
    146141      changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
     
    248243      return new StandardGpEditor(this);
    249244    }
    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 Method
    259     private void SetReferences() {
    260       // SGA
    261       CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    262       // SequentialProcessor in SGA
    263       SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
    264       // RandomInjector
    265       RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];
    266       // VariableInjector
    267       VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];
    268       maxGenerations = vi.GetVariable("MaxGenerations").GetValue<IntData>();
    269       tournamentSize = vi.GetVariable("TournamentSize").GetValue<IntData>();
    270     }
    271     #endregion
    272 
    273     #region Persistence Methods
    274     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     #endregion
    285245  }
    286246}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGpEditor.Designer.cs

    r1253 r1262  
    165165      this.setRandomSeedRandomlyCheckBox.TabIndex = 1;
    166166      this.setRandomSeedRandomlyCheckBox.UseVisualStyleBackColor = true;
     167      this.setRandomSeedRandomlyCheckBox.CheckedChanged += new System.EventHandler(this.setRandomSeedRandomlyCheckBox_CheckedChanged);
    167168      //
    168169      // elitesTextBox
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGpEditor.cs

    r1253 r1262  
    133133    #endregion
    134134
    135 
     135    private void setRandomSeedRandomlyCheckBox_CheckedChanged(object sender, EventArgs e) {
     136      randomSeedTextBox.Enabled = !setRandomSeedRandomlyCheckBox.Checked;
     137      randomSeedLabel.Enabled = !setRandomSeedRandomlyCheckBox.Checked;
     138    }
    136139  }
    137140}
Note: See TracChangeset for help on using the changeset viewer.