Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2337


Ignore:
Timestamp:
09/07/09 13:03:29 (15 years ago)
Author:
gkronber
Message:

refactoring: pulled common code of OSGP and SGP into static class DefaultStructureIdentificationOperators. #720

Location:
branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj

    r2335 r2337  
    8484    <Compile Include="BaseClasses\FunctionTreeBase.cs" />
    8585    <Compile Include="BaseClasses\TreeEvaluatorBase.cs" />
     86    <Compile Include="IStructureIdentificationAlgorithm.cs" />
    8687    <Compile Include="HL3TreeEvaluatorInjector.cs" />
    8788    <Compile Include="HL2TreeEvaluatorInjector.cs" />
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGP.cs

    r2335 r2337  
    3535    public override string Name { get { return "OffspringSelectionGP - StructureIdentification"; } }
    3636
     37    public HeuristicLab.DataAnalysis.Dataset Dataset {
     38      get {
     39        throw new NotImplementedException();
     40      }
     41      set {
     42        throw new NotImplementedException();
     43      }
     44    }
     45
     46    public int TargetVariable {
     47      get {
     48        throw new NotImplementedException();
     49      }
     50      set {
     51        throw new NotImplementedException();
     52      }
     53    }
     54
     55    public IAnalyzerModel Model {
     56      get { throw new NotImplementedException(); }
     57    }
     58
    3759    public virtual double PunishmentFactor {
    3860      get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; }
     
    4668
    4769    protected override IOperator CreateFunctionLibraryInjector() {
    48       CombinedOperator op = new CombinedOperator();
    49       op.Name = "FunctionLibraryInjector";
    50       SequentialProcessor seq = new SequentialProcessor();     
    51       seq.AddSubOperator(new FunctionLibraryInjector());
    52       seq.AddSubOperator(new HL2TreeEvaluatorInjector());
    53       op.OperatorGraph.AddOperator(seq);
    54       op.OperatorGraph.InitialOperator = seq;
    55       return op;
     70      return DefaultStructureIdentificationAlgorithmOperators.CreateFunctionLibraryInjector();
    5671    }
    5772
    5873    protected override IOperator CreateProblemInjector() {
    59       return new ProblemInjector();
     74      return DefaultStructureIdentificationAlgorithmOperators.CreateProblemInjector();
    6075    }
    6176
    6277    protected override IOperator CreateInitialPopulationEvaluator() {
    63       MeanSquaredErrorEvaluator eval = new MeanSquaredErrorEvaluator();
    64       eval.Name = "Evaluator";
    65       eval.GetVariableInfo("MSE").ActualName = "Quality";
    66       eval.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
    67       eval.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    68       return eval;
     78      return DefaultStructureIdentificationAlgorithmOperators.CreateInitialPopulationEvaluator();
    6979    }
    7080
    7181    protected override IOperator CreateEvaluationOperator() {
    72       return CreateInitialPopulationEvaluator();
     82      return DefaultStructureIdentificationAlgorithmOperators.CreateEvaluator();
    7383    }
    7484
    7585
    7686    protected override IOperator CreateGenerationStepHook() {
    77       CombinedOperator op = new CombinedOperator();
    78       SequentialProcessor seq = new SequentialProcessor();
    79       UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
    80       SequentialProcessor individualProc = new SequentialProcessor();
    81       MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();
    82       validationEvaluator.Name = "ValidationEvaluator";
    83       validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
    84       validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    85       validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
    86 
    87       individualProc.AddSubOperator(validationEvaluator);
    88 
    89       BestSolutionStorer solutionStorer = new BestSolutionStorer();
    90       solutionStorer.GetVariableInfo("BestSolution").ActualName = "BestValidationSolution";
    91       solutionStorer.GetVariableInfo("Quality").ActualName = "ValidationQuality";
    92 
    93       BestAverageWorstQualityCalculator validationQualityCalculator = new BestAverageWorstQualityCalculator();
    94       validationQualityCalculator.Name = "BestAverageWorstValidationQualityCalculator";
    95       validationQualityCalculator.GetVariableInfo("Quality").ActualName = "ValidationQuality";
    96       validationQualityCalculator.GetVariableInfo("BestQuality").ActualName = "BestValidationQuality";
    97       validationQualityCalculator.GetVariableInfo("AverageQuality").ActualName = "AverageValidationQuality";
    98       validationQualityCalculator.GetVariableInfo("WorstQuality").ActualName = "WorstValidationQuality";
    99 
    100       subScopesProc.AddSubOperator(individualProc);
    101 
    102       seq.AddSubOperator(subScopesProc);
    103       seq.AddSubOperator(solutionStorer);
    104       seq.AddSubOperator(validationQualityCalculator);
    105 
    106       op.OperatorGraph.AddOperator(seq);
    107       op.OperatorGraph.InitialOperator = seq;
    108       return op;
     87      return DefaultStructureIdentificationAlgorithmOperators.CreateGenerationStepHook();
    10988    }
    11089
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs

    r2335 r2337  
    3131
    3232namespace HeuristicLab.GP.StructureIdentification {
    33   public class StandardGP : HeuristicLab.GP.Algorithms.StandardGP {
     33  public class StandardGP : HeuristicLab.GP.Algorithms.StandardGP, IAlgorithm {
    3434
    3535    public override string Name { get { return "StandardGP - StructureIdentification"; } }
     36
     37    public HeuristicLab.DataAnalysis.Dataset Dataset {
     38      get {
     39        throw new NotImplementedException();
     40      }
     41      set {
     42        throw new NotImplementedException();
     43      }
     44    }
     45
     46    public int TargetVariable {
     47      get {
     48        throw new NotImplementedException();
     49      }
     50      set {
     51        throw new NotImplementedException();
     52      }
     53    }
     54
     55    public IAnalyzerModel Model {
     56      get { throw new NotImplementedException(); }
     57    }
     58
    3659    public virtual double PunishmentFactor {
    3760      get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; }
     
    4669
    4770    protected override IOperator CreateFunctionLibraryInjector() {
    48       CombinedOperator op = new CombinedOperator();
    49       op.Name = "FunctionLibraryInjector";
    50       SequentialProcessor seq = new SequentialProcessor();
    51       seq.AddSubOperator(new FunctionLibraryInjector());
    52       seq.AddSubOperator(new HL2TreeEvaluatorInjector());
    53       op.OperatorGraph.AddOperator(seq);
    54       op.OperatorGraph.InitialOperator = seq;
    55       return op;
     71      return DefaultStructureIdentificationAlgorithmOperators.CreateFunctionLibraryInjector();
    5672    }
    5773
    5874    protected override IOperator CreateProblemInjector() {
    59       return new ProblemInjector();
     75      return DefaultStructureIdentificationAlgorithmOperators.CreateProblemInjector();
    6076    }
    6177
    6278    protected override IOperator CreateInitialPopulationEvaluator() {
    63       MeanSquaredErrorEvaluator eval = new MeanSquaredErrorEvaluator();
    64       eval.Name = "Evaluator";
    65       eval.GetVariableInfo("MSE").ActualName = "Quality";
    66       eval.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
    67       eval.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    68       return eval;
     79      return DefaultStructureIdentificationAlgorithmOperators.CreateInitialPopulationEvaluator();
    6980    }
    7081
    7182    protected override IOperator CreateEvaluationOperator() {
    72       return CreateInitialPopulationEvaluator();
     83      return DefaultStructureIdentificationAlgorithmOperators.CreateEvaluator();     
    7384    }
    7485
    7586
    7687    protected override IOperator CreateGenerationStepHook() {
    77       CombinedOperator op = new CombinedOperator();
    78       SequentialProcessor seq = new SequentialProcessor();
    79       UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
    80       SequentialProcessor individualProc = new SequentialProcessor();
    81       MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();
    82       validationEvaluator.Name = "ValidationEvaluator";
    83       validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
    84       validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    85       validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
    86 
    87       individualProc.AddSubOperator(validationEvaluator);
    88 
    89       BestSolutionStorer solutionStorer = new BestSolutionStorer();
    90       solutionStorer.GetVariableInfo("BestSolution").ActualName = "BestValidationSolution";
    91       solutionStorer.GetVariableInfo("Quality").ActualName = "ValidationQuality";
    92 
    93       BestAverageWorstQualityCalculator validationQualityCalculator = new BestAverageWorstQualityCalculator();
    94       validationQualityCalculator.Name = "BestAverageWorstValidationQualityCalculator";
    95       validationQualityCalculator.GetVariableInfo("Quality").ActualName = "ValidationQuality";
    96       validationQualityCalculator.GetVariableInfo("BestQuality").ActualName = "BestValidationQuality";
    97       validationQualityCalculator.GetVariableInfo("AverageQuality").ActualName = "AverageValidationQuality";
    98       validationQualityCalculator.GetVariableInfo("WorstQuality").ActualName = "WorstValidationQuality";
    99 
    100       subScopesProc.AddSubOperator(individualProc);
    101 
    102       seq.AddSubOperator(subScopesProc);
    103       seq.AddSubOperator(solutionStorer);
    104       seq.AddSubOperator(validationQualityCalculator);
    105 
    106       op.OperatorGraph.AddOperator(seq);
    107       op.OperatorGraph.InitialOperator = seq;
    108       return op;
     88      return DefaultStructureIdentificationAlgorithmOperators.CreateGenerationStepHook();
    10989    }
    11090
Note: See TracChangeset for help on using the changeset viewer.