Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1245 for branches


Ignore:
Timestamp:
03/04/09 16:12:31 (16 years ago)
Author:
gkronber
Message:
  • Moved DatasetShuffler from plugin HeuristicLab.GP.StructureIdentification.Classification to plugin HeuristicLab.DataAnalysis.
  • Added variants of StandardGP and OffspringSelectionGP for Classification and time-series analysis.

#224 (Simple frontend for GP for non-expert users (similar to HeurisicLab.SGA))

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  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
    28 using HeuristicLab.GP.StructureIdentification;
    29 using HeuristicLab.DataAnalysis;
    3028using HeuristicLab.Random;
    3129
    32 namespace HeuristicLab.GP.StructureIdentification.Classification {
     30namespace HeuristicLab.DataAnalysis {
    3331  public class DatasetShuffler : OperatorBase {
    3432    public DatasetShuffler()
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.DataAnalysis/HeuristicLab.DataAnalysis.csproj

    r894 r1245  
    7171    <Compile Include="Dataset.cs" />
    7272    <Compile Include="DatasetParser.cs" />
     73    <Compile Include="DatasetShuffler.cs" />
    7374    <Compile Include="DatasetView.cs">
    7475      <SubType>UserControl</SubType>
     
    9798      <Name>HeuristicLab.Data</Name>
    9899    </ProjectReference>
     100    <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj">
     101      <Project>{A9983BA2-B3B2-475E-8E2C-62050B71D1C5}</Project>
     102      <Name>HeuristicLab.Operators</Name>
     103    </ProjectReference>
    99104    <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    100105      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    101106      <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>
    102111    </ProjectReference>
    103112  </ItemGroup>
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.Classification/HeuristicLab.GP.StructureIdentification.Classification.csproj

    r1051 r1245  
    6767    <Compile Include="ClassificationMeanSquaredErrorEvaluator.cs" />
    6868    <Compile Include="ConfusionMatrixEvaluator.cs" />
    69     <Compile Include="DatasetShuffler.cs" />
    7069    <Compile Include="GPClassificationEvaluatorBase.cs" />
    7170    <Compile Include="CrossValidation.cs" />
     
    7372    <Compile Include="MulticlassModeller.cs" />
    7473    <Compile Include="MulticlassOneVsOneAnalyzer.cs" />
     74    <Compile Include="OffspringSelectionGP.cs" />
    7575    <Compile Include="Properties\AssemblyInfo.cs" />
    7676    <Compile Include="ROCAnalyzer.cs" />
     77    <Compile Include="StandardGP.cs" />
    7778  </ItemGroup>
    7879  <ItemGroup>
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.Classification/OffspringSelectionGP.cs

    r1244 r1245  
    2828using System.Diagnostics;
    2929using HeuristicLab.DataAnalysis;
    30 using HeuristicLab.Operators;
    3130using HeuristicLab.Random;
    32 using HeuristicLab.Selection;
    33 using HeuristicLab.Logging;
    3431using HeuristicLab.Data;
    35 using HeuristicLab.Operators.Programmable;
    36 using HeuristicLab.Selection.OffspringSelection;
    3732
    38 namespace HeuristicLab.GP.StructureIdentification {
    39   public class OffspringSelectionGP : StandardGP {
     33namespace 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";
    4041
    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";
    4646
    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";
    5251
    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";
    5856
    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";
    6461
    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";
    7366
    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);
    21470      return seq;
    21571    }
    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 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
    29072  }
    29173}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.Classification/StandardGP.cs

    r1244 r1245  
    2828using System.Diagnostics;
    2929using HeuristicLab.DataAnalysis;
    30 using HeuristicLab.Operators;
    3130using HeuristicLab.Random;
    32 using HeuristicLab.Selection;
    33 using HeuristicLab.Logging;
    3431using HeuristicLab.Data;
    35 using HeuristicLab.Operators.Programmable;
    3632
    37 namespace HeuristicLab.GP.StructureIdentification {
    38   public class StandardGP : AlgorithmBase, IEditable {
     33namespace 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";
    3941
    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;
    4471    }
    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 Method
    244     private void SetReferences() {
    245       // SGA
    246       CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    247       // SequentialProcessor in SGA
    248       SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
    249       // RandomInjector
    250       RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];
    251       // VariableInjector
    252       VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];
    253       maxGenerations = vi.GetVariable("MaxGenerations").GetValue<IntData>();
    254       tournamentSize = vi.GetVariable("TournamentSize").GetValue<IntData>();
    255     }
    256     #endregion
    257 
    258     #region Persistence Methods
    259     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     #endregion
    27072  }
    27173}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/HeuristicLab.GP.StructureIdentification.TimeSeries.csproj

    r852 r1245  
    6969    </Compile>
    7070    <Compile Include="HeuristicLabGPTimeSeriesPlugin.cs" />
     71    <Compile Include="OffspringSelectionGP.cs" />
    7172    <Compile Include="ProfitEvaluator.cs" />
    7273    <Compile Include="Properties\AssemblyInfo.cs" />
     74    <Compile Include="StandardGP.cs" />
    7375    <Compile Include="TheilInequalityCoefficientEvaluator.cs" />
    7476  </ItemGroup>
     
    98100      <Name>HeuristicLab.GP</Name>
    99101    </ProjectReference>
     102    <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj">
     103      <Project>{A9983BA2-B3B2-475E-8E2C-62050B71D1C5}</Project>
     104      <Name>HeuristicLab.Operators</Name>
     105    </ProjectReference>
    100106    <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    101107      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/OffspringSelectionGP.cs

    r1244 r1245  
    2828using System.Diagnostics;
    2929using HeuristicLab.DataAnalysis;
     30using HeuristicLab.Data;
    3031using 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;
    3732
    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; }
     33namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
     34  public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP {
     35    protected override IOperator CreateFunctionLibraryInjector() {
     36      return new FunctionLibraryInjector();
    4537    }
    4638
    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";
    5248
    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";
    5856
    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";
    6464
    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);
    21368
    21469      return seq;
    21570    }
    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 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
    29071  }
    29172}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification.TimeSeries/StandardGP.cs

    r1244 r1245  
    2828using System.Diagnostics;
    2929using HeuristicLab.DataAnalysis;
    30 using HeuristicLab.Operators;
    31 using HeuristicLab.Random;
    32 using HeuristicLab.Selection;
    33 using HeuristicLab.Logging;
    3430using HeuristicLab.Data;
    35 using HeuristicLab.Operators.Programmable;
    3631
    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() {
     32namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
     33  public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP {
     34    protected override IOperator CreateFunctionLibraryInjector() {
    12635      return new FunctionLibraryInjector();
    12736    }
    12837
    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";
    13747
    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";
    15055
    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";
    15763
    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);
    16567
    166       manipulator.OperatorGraph.AddOperator(multibranch);
    167       manipulator.OperatorGraph.InitialOperator = multibranch;
    168       return manipulator;
     68      return seq;
    16969    }
    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 Method
    244     private void SetReferences() {
    245       // SGA
    246       CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    247       // SequentialProcessor in SGA
    248       SequentialProcessor algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
    249       // RandomInjector
    250       RandomInjector ri = (RandomInjector)algorithm.SubOperators[1];
    251       // VariableInjector
    252       VariableInjector vi = (VariableInjector)algorithm.SubOperators[2];
    253       maxGenerations = vi.GetVariable("MaxGenerations").GetValue<IntData>();
    254       tournamentSize = vi.GetVariable("TournamentSize").GetValue<IntData>();
    255     }
    256     #endregion
    257 
    258     #region Persistence Methods
    259     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     #endregion
    27070  }
    27171}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/AlgorithmBase.cs

    r1238 r1245  
    112112    }
    113113
    114     internal virtual CombinedOperator CreateAlgorithm() {
     114    protected internal virtual CombinedOperator CreateAlgorithm() {
    115115      CombinedOperator algo = new CombinedOperator();
    116116      algo.Name = "GP";
     
    164164    }
    165165
    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() {
    175175      VariableInjector injector = new VariableInjector();
    176176      injector.Name = "Global Injector";
     
    190190    }
    191191
    192     internal abstract IOperator CreateManipulator();
    193 
    194     internal virtual IOperator CreateInitialization() {
     192    protected internal abstract IOperator CreateManipulator();
     193
     194    protected internal virtual IOperator CreateInitialization() {
    195195      CombinedOperator init = new CombinedOperator();
    196196      init.Name = "Initialization";
     
    231231    }
    232232
    233     internal virtual IOperator CreateMainLoop() {
     233    protected internal virtual IOperator CreateMainLoop() {
    234234      CombinedOperator main = new CombinedOperator();
    235235      SequentialProcessor seq = new SequentialProcessor();
     
    268268    }
    269269
    270     internal virtual IOperator CreateLoggingOperator() {
     270    protected internal virtual IOperator CreateLoggingOperator() {
    271271      return new EmptyOperator();
    272272    }
    273273
    274     internal virtual IOperator CreateLoopCondition(IOperator loop) {
     274    protected internal virtual IOperator CreateLoopCondition(IOperator loop) {
    275275      SequentialProcessor seq = new SequentialProcessor();
    276276      seq.Name = "Loop Condition";
     
    289289    }
    290290
    291     internal virtual IOperator CreateBestSolutionProcessor() {
     291    protected internal virtual IOperator CreateBestSolutionProcessor() {
    292292      return new EmptyOperator();
    293293    }
    294294
    295     internal virtual IOperator CreateReplacement() {
     295    protected internal virtual IOperator CreateReplacement() {
    296296      CombinedOperator replacement = new CombinedOperator();
    297297      replacement.Name = "Replacement";
     
    327327    }
    328328
    329     internal virtual IOperator CreateChildCreater() {
     329    protected internal virtual IOperator CreateChildCreater() {
    330330      CombinedOperator childCreater = new CombinedOperator();
    331331      childCreater.Name = "Create children";
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/OffspringSelectionGP.cs

    r1239 r1245  
    7272    }
    7373
    74     internal override IOperator CreateGlobalInjector() {
     74    protected internal override IOperator CreateGlobalInjector() {
    7575      VariableInjector injector = (VariableInjector)base.CreateGlobalInjector();
    7676      injector.RemoveVariable("TournamentSize");
     
    8383    }
    8484
    85     internal override IOperator CreateSelector() {
     85    protected internal override IOperator CreateSelector() {
    8686      CombinedOperator selector = new CombinedOperator();
    8787      selector.Name = "Selector";
     
    113113    }
    114114
    115     internal override IOperator CreateChildCreater() {
     115    protected internal override IOperator CreateChildCreater() {
    116116      CombinedOperator childCreater = new CombinedOperator();
    117117      childCreater.Name = "Create children";
     
    187187    }
    188188
    189     internal override IOperator CreateLoopCondition(IOperator loop) {
     189    protected internal override IOperator CreateLoopCondition(IOperator loop) {
    190190      SequentialProcessor seq = new SequentialProcessor();
    191191      seq.Name = "Loop Condition";
     
    215215    }
    216216
    217     internal override IOperator CreateLoggingOperator() {
     217    protected internal override IOperator CreateLoggingOperator() {
    218218      CombinedOperator loggingOperator = new CombinedOperator();
    219219      loggingOperator.Name = "Logging";
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StandardGP.cs

    r1238 r1245  
    8383      FullTreeShakingFactor = 0.1;
    8484      OnePointShakingFactor = 1.0;
    85 
    8685      Engine = new SequentialEngine.SequentialEngine();
    8786      IOperator algo = CreateAlgorithm();
     
    9089    }
    9190
    92     internal override IOperator CreateSelector() {
     91    protected internal override IOperator CreateSelector() {
    9392      TournamentSelector selector = new TournamentSelector();
    9493      selector.Name = "Selector";
     
    10099    }
    101100
    102     internal override IOperator CreateGlobalInjector() {
     101    protected internal override IOperator CreateGlobalInjector() {
    103102      VariableInjector globalInjector = (VariableInjector)base.CreateGlobalInjector();
    104103      globalInjector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", tournamentSize));
     
    107106    }
    108107
    109     internal override IOperator CreateCrossover() {
     108    protected internal override IOperator CreateCrossover() {
    110109      StandardCrossOver crossover = new StandardCrossOver();
    111110      crossover.Name = "Crossover";
     
    114113    }
    115114
    116     internal override IOperator CreateTreeCreator() {
     115    protected internal override IOperator CreateTreeCreator() {
    117116      ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator();
    118117      treeCreator.Name = "Tree generator";
     
    123122    }
    124123
    125     internal override IOperator CreateFunctionLibraryInjector() {
     124    protected internal override IOperator CreateFunctionLibraryInjector() {
    126125      return new FunctionLibraryInjector();
    127126    }
    128127
    129     internal override IOperator CreateManipulator() {
     128    protected internal override IOperator CreateManipulator() {
    130129      CombinedOperator manipulator = new CombinedOperator();
    131130      manipulator.Name = "Manipulator";
     
    169168    }
    170169
    171     internal override IOperator CreateBestSolutionProcessor() {
     170    protected internal override IOperator CreateBestSolutionProcessor() {
    172171      SequentialProcessor bestSolutionProcessor = new SequentialProcessor();
    173172      MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
     
    181180      validationMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    182181      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";
    183192      ProgrammableOperator progOperator = new ProgrammableOperator();
    184193      progOperator.RemoveVariableInfo("Result");
     
    190199      bestSolutionProcessor.AddSubOperator(trainingMapeEvaluator);
    191200      bestSolutionProcessor.AddSubOperator(validationMapeEvaluator);
     201      bestSolutionProcessor.AddSubOperator(trainingMapreEvaluator);
     202      bestSolutionProcessor.AddSubOperator(validationMapreEvaluator);
    192203      bestSolutionProcessor.AddSubOperator(progOperator);
    193204      return bestSolutionProcessor;
    194205    }
    195206
    196     internal override IOperator CreateLoggingOperator() {
     207    protected internal override IOperator CreateLoggingOperator() {
    197208      CombinedOperator loggingOperator = new CombinedOperator();
    198209      loggingOperator.Name = "Logging";
Note: See TracChangeset for help on using the changeset viewer.