Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2340 for branches


Ignore:
Timestamp:
09/07/09 18:55:50 (15 years ago)
Author:
gkronber
Message:

Fixed some issues in the GP algorithms for time-series prognosis and classification. #720

Location:
branches/gp-algorithms-refactoring-#720/sources
Files:
3 added
12 edited

Legend:

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

    r2328 r2340  
    8383    <Compile Include="ClassificationMeanSquaredErrorEvaluator.cs" />
    8484    <Compile Include="ConfusionMatrixEvaluator.cs" />
     85    <Compile Include="TargetClassesCalculator.cs" />
     86    <Compile Include="DefaultClassificationAlgorithmOperators.cs" />
    8587    <Compile Include="GPClassificationEvaluatorBase.cs" />
    8688    <Compile Include="CrossValidation.cs" />
     
    109111      <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project>
    110112      <Name>HeuristicLab.Data-3.2</Name>
     113    </ProjectReference>
     114    <ProjectReference Include="..\..\HeuristicLab.GP.Algorithms\3.2\HeuristicLab.GP.Algorithms-3.2.csproj">
     115      <Project>{3127719F-110E-4558-8845-98559DBB422D}</Project>
     116      <Name>HeuristicLab.GP.Algorithms-3.2</Name>
    111117    </ProjectReference>
    112118    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/OffspringSelectionGP.cs

    r2335 r2340  
    2525
    2626namespace HeuristicLab.GP.StructureIdentification.Classification {
    27   public class OffspringSelectionGP : HeuristicLab.GP.OffspringSelectionGP, IClassificationAlgorithm {
     27  public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, IClassificationAlgorithm {
    2828
    29     protected override IOperator CreateBestSolutionProcessor() {
    30       IOperator seq = new SequentialProcessor();
    31       seq.AddSubOperator(base.CreateBestSolutionProcessor());
    32       seq.AddSubOperator(StandardGP.BestSolutionProcessor);
    33       return seq;
     29    protected override IOperator CreateProblemInjector() {
     30      return DefaultClassificationAlgorithmOperators.CreateProblemInjector();
     31    }
     32
     33    protected override IOperator CreatePostProcessingOperator() {
     34      return DefaultClassificationAlgorithmOperators.CreatePostProcessingOperator();
    3435    }
    3536  }
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/StandardGP.cs

    r2335 r2340  
    2323using HeuristicLab.Modeling;
    2424using HeuristicLab.Operators;
     25using System;
    2526
    2627namespace HeuristicLab.GP.StructureIdentification.Classification {
    27   public class StandardGP : HeuristicLab.GP.StandardGP, IClassificationAlgorithm {
    28     protected override IOperator CreateBestSolutionProcessor() {
    29       IOperator bestSolutionProcessor = BestSolutionProcessor;
    30       bestSolutionProcessor.AddSubOperator(base.CreateBestSolutionProcessor());
    31       return bestSolutionProcessor;
    32     }
    33 
    34     internal static IOperator BestSolutionProcessor {
    35       get {
    36         SequentialProcessor seq = new SequentialProcessor();
    37         AccuracyEvaluator trainingAccuracy = new AccuracyEvaluator();
    38         trainingAccuracy.GetVariableInfo("Accuracy").ActualName = "TrainingAccuracy";
    39         trainingAccuracy.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
    40         trainingAccuracy.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    41 
    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 = "ActualTrainingSamplesStart";
    55         trainingConfusionMatrix.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    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         seq.AddSubOperator(trainingConfusionMatrix);
    71         seq.AddSubOperator(validationConfusionMatrix);
    72         seq.AddSubOperator(testConfusionMatrix);
    73         return seq;
    74       }
     28  public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, IClassificationAlgorithm {
     29    protected override IOperator CreatePostProcessingOperator() {
     30      return DefaultClassificationAlgorithmOperators.CreatePostProcessingOperator();
    7531    }
    7632  }
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/HeuristicLab.GP.StructureIdentification.TimeSeries-3.3.csproj

    r2222 r2340  
    8383  <ItemGroup>
    8484    <Compile Include="AveragePercentageChangeEvaluator.cs" />
     85    <Compile Include="DefaultTimeSeriesOperators.cs" />
    8586    <Compile Include="HeuristicLabGPTimeSeriesPlugin.cs" />
    8687    <Compile Include="OffspringSelectionGP.cs" />
     
    102103      <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project>
    103104      <Name>HeuristicLab.Data-3.2</Name>
     105    </ProjectReference>
     106    <ProjectReference Include="..\..\HeuristicLab.GP.Algorithms\3.2\HeuristicLab.GP.Algorithms-3.2.csproj">
     107      <Project>{3127719F-110E-4558-8845-98559DBB422D}</Project>
     108      <Name>HeuristicLab.GP.Algorithms-3.2</Name>
    104109    </ProjectReference>
    105110    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/OffspringSelectionGP.cs

    r2335 r2340  
    2323using HeuristicLab.Modeling;
    2424using HeuristicLab.Operators;
     25using System;
     26using HeuristicLab.Data;
     27using HeuristicLab.GP.Algorithms;
    2528
    2629namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
    27   public class OffspringSelectionGP : HeuristicLab.GP.OffspringSelectionGP, ITimeSeriesAlgorithm {
    28     public override IOperator ProblemInjector {
    29       get {
    30         CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    31         return algo.OperatorGraph.InitialOperator.SubOperators[1];
    32       }
    33       set {
    34         CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    35         algo.OperatorGraph.InitialOperator.RemoveSubOperator(1);
    36         value.Name = "ProblemInjector";
    37         algo.OperatorGraph.InitialOperator.AddSubOperator(value, 1);
    38       }
     30  public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP, ITimeSeriesAlgorithm {
     31
     32    public int MinTimeOffset {
     33      get { return GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data; }
     34      set { GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data = value; }
     35    }
     36
     37    public int MaxTimeOffset {
     38      get { return GetVariableInjector().GetVariable("MaxTimeOffset").GetValue<IntData>().Data; }
     39      set { GetVariableInjector().GetVariable("MaxTimeOffset").GetValue<IntData>().Data = value; }
     40    }
     41
     42    public bool UseEstimatedTargetValue {
     43      get { return GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data; }
     44      set { GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data = value; }
     45    }
     46
     47    protected override IOperator CreateProblemInjector() {
     48      return DefaultTimeSeriesOperators.CreateProblemInjector();
    3949    }
    4050
    4151    protected override IOperator CreateFunctionLibraryInjector() {
    42       return new FunctionLibraryInjector();
     52      return DefaultTimeSeriesOperators.CreateFunctionLibraryInjector();
    4353    }
    4454
    45     protected override IOperator CreateProblemInjector() {
    46       return new ProblemInjector();
     55    protected override IOperator CreatePostProcessingOperator() {
     56      return DefaultTimeSeriesOperators.CreatePostProcessingOperator();
    4757    }
    4858
    49     protected override IOperator CreateBestSolutionProcessor() {
    50       SequentialProcessor seq = new SequentialProcessor();
    51       seq.AddSubOperator(base.CreateBestSolutionProcessor());
    52       seq.AddSubOperator(StandardGP.BestSolutionProcessor);
    53       return seq;
     59    protected override VariableInjector CreateGlobalInjector() {
     60      VariableInjector injector = base.CreateGlobalInjector();
     61      injector.AddVariable(new HeuristicLab.Core.Variable("MinTimeOffset", new IntData()));
     62      injector.AddVariable(new HeuristicLab.Core.Variable("MaxTimeOffset", new IntData()));
     63      injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));
     64      return injector;
    5465    }
    5566
    56     public override IEditor CreateEditor() {
    57       return new OffspringSelectionGpEditor(this);
    58     }
    59 
    60     public override IView CreateView() {
    61       return new OffspringSelectionGpEditor(this);
    62     }
    6367  }
    6468}
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/StandardGP.cs

    r2335 r2340  
    2525using HeuristicLab.Modeling;
    2626using HeuristicLab.Operators;
     27using System;
    2728
    2829namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
    29   public class StandardGP : HeuristicLab.GP.StandardGP, ITimeSeriesAlgorithm {
    30     public override IOperator ProblemInjector {
    31       get {
    32         CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    33         return algo.OperatorGraph.InitialOperator.SubOperators[1];
    34       }
    35       set {
    36         CombinedOperator algo = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
    37         algo.OperatorGraph.InitialOperator.RemoveSubOperator(1);
    38         value.Name = "ProblemInjector";
    39         algo.OperatorGraph.InitialOperator.AddSubOperator(value, 1);
    40       }
     30  public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, ITimeSeriesAlgorithm {
     31    public int MinTimeOffset {
     32      get { return GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data; }
     33      set { GetVariableInjector().GetVariable("MinTimeOffset").GetValue<IntData>().Data = value; }
    4134    }
    42    
    43     protected override IOperator CreateFunctionLibraryInjector() {
    44       return new FunctionLibraryInjector();
     35
     36    public int MaxTimeOffset {
     37      get { return GetVariableInjector().GetVariable("MaxTimeOffset").GetValue<IntData>().Data; }
     38      set { GetVariableInjector().GetVariable("MaxTimeOffset").GetValue<IntData>().Data = value; }
     39    }
     40
     41    public bool UseEstimatedTargetValue {
     42      get { return GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data; }
     43      set { GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data = value; }
    4544    }
    4645
    4746    protected override IOperator CreateProblemInjector() {
    48       return new ProblemInjector();
     47      return DefaultTimeSeriesOperators.CreateProblemInjector();
    4948    }
    5049
    51     protected override IOperator CreateBestSolutionProcessor() {
    52       SequentialProcessor seq = new SequentialProcessor();
    53       seq.AddSubOperator(base.CreateBestSolutionProcessor());
    54       seq.AddSubOperator(BestSolutionProcessor);
    55       return seq;
     50    protected override IOperator CreateFunctionLibraryInjector() {
     51      return DefaultTimeSeriesOperators.CreateFunctionLibraryInjector();
    5652    }
    5753
    58     public override IEditor CreateEditor() {
    59       return new StandardGpEditor(this);
     54    protected override IOperator CreatePostProcessingOperator() {
     55      return DefaultTimeSeriesOperators.CreatePostProcessingOperator();
    6056    }
    6157
    62     public override IView CreateView() {
    63       return new StandardGpEditor(this);
    64     }
    65 
    66     internal static IOperator BestSolutionProcessor {
    67       get {
    68         SequentialProcessor seq = new SequentialProcessor();
    69         TheilInequalityCoefficientEvaluator trainingTheil = new TheilInequalityCoefficientEvaluator();
    70         trainingTheil.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
    71         trainingTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    72         trainingTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TrainingTheilInequalityCoefficient";
    73         trainingTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TrainingTheilInequalityCoefficientBias";
    74         trainingTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TrainingTheilInequalityCoefficientVariance";
    75         trainingTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TrainingTheilInequalityCoefficientCovariance";
    76 
    77         TheilInequalityCoefficientEvaluator validationTheil = new TheilInequalityCoefficientEvaluator();
    78         validationTheil.GetVariableInfo("SamplesStart").ActualName = "ActualValidationSamplesStart";
    79         validationTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualValidationSamplesEnd";
    80         validationTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "ValidationTheilInequalityCoefficient";
    81         validationTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "ValidationTheilInequalityCoefficientBias";
    82         validationTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "ValidationTheilInequalityCoefficientVariance";
    83         validationTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "ValidationTheilInequalityCoefficientCovariance";
    84 
    85         TheilInequalityCoefficientEvaluator testTheil = new TheilInequalityCoefficientEvaluator();
    86         testTheil.GetVariableInfo("SamplesStart").ActualName = "ActualTestSamplesStart";
    87         testTheil.GetVariableInfo("SamplesEnd").ActualName = "ActualTestSamplesEnd";
    88         testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient";
    89         testTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TestTheilInequalityCoefficientBias";
    90         testTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TestTheilInequalityCoefficientVariance";
    91         testTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TestTheilInequalityCoefficientCovariance";
    92 
    93         SimpleEvaluator trainingEvaluator = new SimpleEvaluator();
    94         trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
    95         trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
    96         trainingEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTraining";
    97 
    98         SimpleEvaluator validationEvaluator = new SimpleEvaluator();
    99         validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
    100         validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
    101         validationEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesValidation";
    102 
    103         SimpleEvaluator testEvaluator = new SimpleEvaluator();
    104         testEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
    105         testEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
    106         testEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTest";
    107 
    108         LinechartInjector trainingChartInjector = new LinechartInjector();
    109         trainingChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
    110         trainingChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesTraining";
    111         trainingChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartTrainingPredictedValues";
    112 
    113         LinechartInjector validationChartInjector = new LinechartInjector();
    114         validationChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
    115         validationChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesValidation";
    116         validationChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartValidationPredictedValues";
    117 
    118         LinechartInjector testChartInjector = new LinechartInjector();
    119         testChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
    120         testChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesTest";
    121         testChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartTestPredictedValues";
    122 
    123         seq.AddSubOperator(trainingTheil);
    124         seq.AddSubOperator(validationTheil);
    125         seq.AddSubOperator(testTheil);
    126         seq.AddSubOperator(trainingEvaluator);
    127         seq.AddSubOperator(trainingChartInjector);
    128         seq.AddSubOperator(validationEvaluator);
    129         seq.AddSubOperator(validationChartInjector);
    130         seq.AddSubOperator(testEvaluator);
    131         seq.AddSubOperator(testChartInjector);
    132 
    133         return seq;
    134       }
     58    protected override VariableInjector CreateGlobalInjector() {
     59      VariableInjector injector = base.CreateGlobalInjector();
     60      injector.AddVariable(new HeuristicLab.Core.Variable("MinTimeOffset", new IntData()));
     61      injector.AddVariable(new HeuristicLab.Core.Variable("MaxTimeOffset", new IntData()));
     62      injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));
     63      return injector;
    13564    }
    13665  }
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs

    r2337 r2340  
    2626using HeuristicLab.Modeling;
    2727using HeuristicLab.Logging;
     28using HeuristicLab.Selection;
     29using HeuristicLab.Data;
    2830
    2931namespace HeuristicLab.GP.StructureIdentification {
    30   internal static class DefaultStructureIdentificationAlgorithmOperators {
    31     internal static IOperator CreateFunctionLibraryInjector() {
     32  public static class DefaultStructureIdentificationAlgorithmOperators {
     33    public static IOperator CreateFunctionLibraryInjector() {
    3234      CombinedOperator op = new CombinedOperator();
    3335      op.Name = "FunctionLibraryInjector";
    3436      SequentialProcessor seq = new SequentialProcessor();
    3537      seq.AddSubOperator(new FunctionLibraryInjector());
    36       seq.AddSubOperator(new HL2TreeEvaluatorInjector());
     38      seq.AddSubOperator(new HL3TreeEvaluatorInjector());
    3739      op.OperatorGraph.AddOperator(seq);
    3840      op.OperatorGraph.InitialOperator = seq;
     
    4042    }
    4143
    42     internal static IOperator CreateProblemInjector() {
    43       return new ProblemInjector();
    44     }
    45 
    46     internal static IOperator CreateInitialPopulationEvaluator() {
     44    public static IOperator CreateProblemInjector() {
     45      CombinedOperator op = new CombinedOperator();
     46      op.Name = "ProblemInjector";
     47      SequentialProcessor seq = new SequentialProcessor();
     48
     49      seq.AddSubOperator(new ProblemInjector());
     50      DatasetShuffler shuffler = new DatasetShuffler();
     51      shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart";
     52      shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd";
     53      seq.AddSubOperator(shuffler);
     54      op.OperatorGraph.AddOperator(seq);
     55      op.OperatorGraph.InitialOperator = seq;
     56      return op;
     57    }
     58
     59    public static IOperator CreateInitialPopulationEvaluator() {
    4760      MeanSquaredErrorEvaluator eval = new MeanSquaredErrorEvaluator();
    4861      eval.Name = "Evaluator";
     
    5366    }
    5467
    55     internal static IOperator CreateEvaluator() {
     68    public static IOperator CreateEvaluator() {
    5669      return CreateInitialPopulationEvaluator();
    5770    }
    5871
    59     internal static IOperator CreateGenerationStepHook() {
     72    public static IOperator CreateGenerationStepHook() {
    6073      CombinedOperator op = new CombinedOperator();
    6174      SequentialProcessor seq = new SequentialProcessor();
     
    91104      return op;
    92105    }
     106
     107    public static IOperator CreatePostProcessingOperator() {
     108      CombinedOperator op = new CombinedOperator();
     109      op.Name = "ModelAnalyser";
     110      SequentialProcessor seq = new SequentialProcessor();
     111      LeftReducer cleanUp = new LeftReducer();
     112      cleanUp.Name = "Reset Population";
     113      seq.AddSubOperator(cleanUp);
     114
     115      SolutionExtractor extractor = new SolutionExtractor();
     116      extractor.GetVariableInfo("Scope").ActualName = "BestValidationSolution";
     117      SequentialSubScopesProcessor seqSubScopeProc = new SequentialSubScopesProcessor();
     118      SequentialProcessor solutionProc = new SequentialProcessor();
     119
     120      seq.AddSubOperator(extractor);
     121      seq.AddSubOperator(seqSubScopeProc);
     122      seqSubScopeProc.AddSubOperator(solutionProc);
     123
     124      HL3TreeEvaluatorInjector evaluatorInjector = new HL3TreeEvaluatorInjector();
     125      evaluatorInjector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(1000.0)));
     126      evaluatorInjector.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     127
     128      #region MSE
     129      MeanSquaredErrorEvaluator trainingMseEvaluator = new MeanSquaredErrorEvaluator();
     130      trainingMseEvaluator.Name = "TrainingMseEvaluator";
     131      trainingMseEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     132      trainingMseEvaluator.GetVariableInfo("MSE").ActualName = "TrainingMSE";
     133      trainingMseEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
     134      trainingMseEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     135      MeanSquaredErrorEvaluator validationMseEvaluator = new MeanSquaredErrorEvaluator();
     136      validationMseEvaluator.Name = "ValidationMseEvaluator";
     137      validationMseEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     138      validationMseEvaluator.GetVariableInfo("MSE").ActualName = "ValidationMSE";
     139      validationMseEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
     140      validationMseEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
     141      MeanSquaredErrorEvaluator testMseEvaluator = new MeanSquaredErrorEvaluator();
     142      testMseEvaluator.Name = "TestMeanSquaredErrorEvaluator";
     143      testMseEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     144      testMseEvaluator.GetVariableInfo("MSE").ActualName = "TestMSE";
     145      testMseEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
     146      testMseEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     147      #endregion
     148      #region MAPE
     149      MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
     150      trainingMapeEvaluator.Name = "TrainingMapeEvaluator";
     151      trainingMapeEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     152      trainingMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TrainingMAPE";
     153      trainingMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
     154      trainingMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     155      MeanAbsolutePercentageErrorEvaluator validationMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
     156      validationMapeEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     157      validationMapeEvaluator.Name = "ValidationMapeEvaluator";
     158      validationMapeEvaluator.GetVariableInfo("MAPE").ActualName = "ValidationMAPE";
     159      validationMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
     160      validationMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
     161      MeanAbsolutePercentageErrorEvaluator testMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
     162      testMapeEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     163      testMapeEvaluator.Name = "TestMapeEvaluator";
     164      testMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TestMAPE";
     165      testMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
     166      testMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     167      #endregion
     168      #region MAPRE
     169      MeanAbsolutePercentageOfRangeErrorEvaluator trainingMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator();
     170      trainingMapreEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     171      trainingMapreEvaluator.Name = "TrainingMapreEvaluator";
     172      trainingMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TrainingMAPRE";
     173      trainingMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
     174      trainingMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     175      MeanAbsolutePercentageOfRangeErrorEvaluator validationMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator();
     176      validationMapreEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     177      validationMapreEvaluator.Name = "ValidationMapreEvaluator";
     178      validationMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "ValidationMAPRE";
     179      validationMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
     180      validationMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
     181      MeanAbsolutePercentageOfRangeErrorEvaluator testMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator();
     182      testMapreEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     183      testMapreEvaluator.Name = "TestMapreEvaluator";
     184      testMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TestMAPRE";
     185      testMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
     186      testMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     187      #endregion MAPRE
     188      #region R2
     189      CoefficientOfDeterminationEvaluator trainingR2Evaluator = new CoefficientOfDeterminationEvaluator();
     190      trainingR2Evaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     191      trainingR2Evaluator.Name = "TrainingR2Evaluator";
     192      trainingR2Evaluator.GetVariableInfo("R2").ActualName = "TrainingR2";
     193      trainingR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
     194      trainingR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     195      CoefficientOfDeterminationEvaluator validationR2Evaluator = new CoefficientOfDeterminationEvaluator();
     196      validationR2Evaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     197      validationR2Evaluator.Name = "ValidationR2Evaluator";
     198      validationR2Evaluator.GetVariableInfo("R2").ActualName = "ValidationR2";
     199      validationR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
     200      validationR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
     201      CoefficientOfDeterminationEvaluator testR2Evaluator = new CoefficientOfDeterminationEvaluator();
     202      testR2Evaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     203      testR2Evaluator.Name = "TestR2Evaluator";
     204      testR2Evaluator.GetVariableInfo("R2").ActualName = "TestR2";
     205      testR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
     206      testR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     207      #endregion
     208      #region VAF
     209      VarianceAccountedForEvaluator trainingVAFEvaluator = new VarianceAccountedForEvaluator();
     210      trainingVAFEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     211      trainingVAFEvaluator.Name = "TrainingVAFEvaluator";
     212      trainingVAFEvaluator.GetVariableInfo("VAF").ActualName = "TrainingVAF";
     213      trainingVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
     214      trainingVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     215      VarianceAccountedForEvaluator validationVAFEvaluator = new VarianceAccountedForEvaluator();
     216      validationVAFEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     217      validationVAFEvaluator.Name = "ValidationVAFEvaluator";
     218      validationVAFEvaluator.GetVariableInfo("VAF").ActualName = "ValidationVAF";
     219      validationVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
     220      validationVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
     221      VarianceAccountedForEvaluator testVAFEvaluator = new VarianceAccountedForEvaluator();
     222      testVAFEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     223      testVAFEvaluator.Name = "TestVAFEvaluator";
     224      testVAFEvaluator.GetVariableInfo("VAF").ActualName = "TestVAF";
     225      testVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
     226      testVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
     227      #endregion
     228
     229      solutionProc.AddSubOperator(evaluatorInjector);
     230      solutionProc.AddSubOperator(trainingMseEvaluator);
     231      solutionProc.AddSubOperator(validationMseEvaluator);
     232      solutionProc.AddSubOperator(testMseEvaluator);
     233      solutionProc.AddSubOperator(trainingMapeEvaluator);
     234      solutionProc.AddSubOperator(validationMapeEvaluator);
     235      solutionProc.AddSubOperator(testMapeEvaluator);
     236      solutionProc.AddSubOperator(trainingMapreEvaluator);
     237      solutionProc.AddSubOperator(validationMapreEvaluator);
     238      solutionProc.AddSubOperator(testMapreEvaluator);
     239      solutionProc.AddSubOperator(trainingR2Evaluator);
     240      solutionProc.AddSubOperator(validationR2Evaluator);
     241      solutionProc.AddSubOperator(testR2Evaluator);
     242      solutionProc.AddSubOperator(trainingVAFEvaluator);
     243      solutionProc.AddSubOperator(validationVAFEvaluator);
     244      solutionProc.AddSubOperator(testVAFEvaluator);
     245
     246      #region variable impacts
     247      // calculate and set variable impacts
     248      VariableNamesExtractor namesExtractor = new VariableNamesExtractor();
     249      namesExtractor.GetVariableInfo("VariableNames").ActualName = "InputVariableNames";
     250      PredictorBuilder predictorBuilder = new PredictorBuilder();
     251      predictorBuilder.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
     252
     253      VariableEvaluationImpactCalculator evaluationImpactCalculator = new VariableEvaluationImpactCalculator();
     254      evaluationImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
     255      evaluationImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     256      VariableQualityImpactCalculator qualityImpactCalculator = new VariableQualityImpactCalculator();
     257      qualityImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
     258      qualityImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
     259
     260      solutionProc.AddSubOperator(namesExtractor);
     261      solutionProc.AddSubOperator(predictorBuilder);
     262      solutionProc.AddSubOperator(evaluationImpactCalculator);
     263      solutionProc.AddSubOperator(qualityImpactCalculator);
     264      #endregion
     265
     266      op.OperatorGraph.AddOperator(seq);
     267      op.OperatorGraph.InitialOperator = seq;
     268      return op;
     269    }
     270
     271    public static IAnalyzerModel CreateGPModel(IScope bestModelScope) {
     272      IAnalyzerModel model = new AnalyzerModel();
     273      model.Predictor = bestModelScope.GetVariableValue<IPredictor>("Predictor", true);
     274      Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true);
     275      model.Dataset = ds;
     276      model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data);
     277      model.TrainingSamplesStart = bestModelScope.GetVariableValue<IntData>("TrainingSamplesStart", true).Data;
     278      model.TrainingSamplesEnd = bestModelScope.GetVariableValue<IntData>("TrainingSamplesEnd", true).Data;
     279      model.ValidationSamplesStart = bestModelScope.GetVariableValue<IntData>("ValidationSamplesStart", true).Data;
     280      model.ValidationSamplesEnd = bestModelScope.GetVariableValue<IntData>("ValidationSamplesEnd", true).Data;
     281      model.TestSamplesStart = bestModelScope.GetVariableValue<IntData>("TestSamplesStart", true).Data;
     282      model.TestSamplesEnd = bestModelScope.GetVariableValue<IntData>("TestSamplesEnd", true).Data;
     283
     284      model.TrainingMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("TrainingMSE", false).Data;
     285      model.ValidationMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("ValidationMSE", false).Data;
     286      model.TestMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("TestMSE", false).Data;
     287      model.TrainingCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TrainingR2", false).Data;
     288      model.ValidationCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data;
     289      model.TestCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TestR2", false).Data;
     290      model.TrainingMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TrainingMAPE", false).Data;
     291      model.ValidationMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data;
     292      model.TestMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data;
     293      model.TrainingMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TrainingMAPRE", false).Data;
     294      model.ValidationMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data;
     295      model.TestMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data;
     296      model.TrainingVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TrainingVAF", false).Data;
     297      model.ValidationVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data;
     298      model.TestVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data;
     299
     300      ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false);
     301      ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false);
     302      foreach (ItemList row in evaluationImpacts) {
     303        string variableName = ((StringData)row[0]).Data;
     304        double impact = ((DoubleData)row[1]).Data;
     305        model.SetVariableEvaluationImpact(variableName, impact);
     306        model.AddInputVariable(variableName);
     307      }
     308      foreach (ItemList row in qualityImpacts) {
     309        string variableName = ((StringData)row[0]).Data;
     310        double impact = ((DoubleData)row[1]).Data;
     311        model.SetVariableQualityImpact(variableName, impact);
     312        model.AddInputVariable(variableName);
     313      }
     314
     315      return model;
     316    }
    93317  }
    94318}
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs

    r2328 r2340  
    3636      AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
    3737      AddVariableInfo(new VariableInfo("SamplesEnd", "End index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
    38       AddVariableInfo(new VariableInfo("UseEstimatedTargetValue", "Wether to use the original (measured) or the estimated (calculated) value for the target variable for autoregressive modelling", typeof(BoolData), VariableKind.In));
     38      AddVariableInfo(new VariableInfo("UseEstimatedTargetValue", "(optional) Wether to use the original (measured) or the estimated (calculated) value for the target variable for autoregressive modelling", typeof(BoolData), VariableKind.In));
    3939    }
    4040
     
    4747      int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data;
    4848      int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data;
    49       bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, true).Data;
     49      BoolData useEstimatedValuesData = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, true, false);
     50      bool useEstimatedValues = useEstimatedValuesData == null ? false : useEstimatedValuesData.Data;
    5051      ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true);
    5152      evaluator.PrepareForEvaluation(dataset, gpModel.FunctionTree);
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj

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

    r2337 r2340  
    3030using HeuristicLab.Selection.OffspringSelection;
    3131using HeuristicLab.Modeling;
     32using HeuristicLab.DataAnalysis;
    3233
    3334namespace HeuristicLab.GP.StructureIdentification {
    34   public class OffspringSelectionGP : HeuristicLab.GP.Algorithms.OffspringSelectionGP {
     35  public class OffspringSelectionGP : HeuristicLab.GP.Algorithms.OffspringSelectionGP, IAlgorithm {
    3536    public override string Name { get { return "OffspringSelectionGP - StructureIdentification"; } }
    3637
    37     public HeuristicLab.DataAnalysis.Dataset Dataset {
    38       get {
    39         throw new NotImplementedException();
    40       }
    41       set {
    42         throw new NotImplementedException();
    43       }
     38    public virtual int TargetVariable {
     39      get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; }
     40      set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; }
    4441    }
    4542
    46     public int TargetVariable {
    47       get {
    48         throw new NotImplementedException();
    49       }
    50       set {
    51         throw new NotImplementedException();
    52       }
     43    public virtual Dataset Dataset {
     44      get { return ProblemInjector.GetVariableValue<Dataset>("Dataset", null, false); }
     45      set { ProblemInjector.GetVariable("Dataset").Value = value; }
    5346    }
    5447
    55     public IAnalyzerModel Model {
    56       get { throw new NotImplementedException(); }
     48    public virtual IAnalyzerModel Model {
     49      get {
     50        if (!Engine.Terminated)
     51          throw new InvalidOperationException("The algorithm is still running. Wait until the algorithm is terminated to retrieve the result.");
     52        else
     53          return CreateGPModel();
     54      }
    5755    }
    5856
     
    6058      get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; }
    6159      set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; }
     60    }
     61
     62    public override IOperator ProblemInjector {
     63      get { return GetProblemInjector().OperatorGraph.InitialOperator.SubOperators[0]; }
     64      set {
     65        value.Name = "ProblemInjector";
     66        CombinedOperator problemInjector = GetProblemInjector();
     67        problemInjector.OperatorGraph.RemoveOperator(ProblemInjector.Guid);
     68        problemInjector.OperatorGraph.AddOperator(value);
     69        problemInjector.OperatorGraph.InitialOperator.AddSubOperator(value, 0);
     70      }
    6271    }
    6372
     
    9099    protected override VariableInjector CreateGlobalInjector() {
    91100      VariableInjector injector = base.CreateGlobalInjector();
    92       injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));
    93101      injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData()));
    94102      return injector;
    95103    }
     104
    96105
    97106    protected override IOperator CreateLoggingOperator() {
     
    123132    }
    124133
     134    protected override IOperator CreatePostProcessingOperator() {
     135      return DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator();
     136    }
     137
    125138    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    126139      OffspringSelectionGP clone = (OffspringSelectionGP)base.Clone(clonedObjects);
     
    128141      return clone;
    129142    }
     143
     144    protected CombinedOperator GetProblemInjector() {
     145      return (CombinedOperator)GetInitializationOperator().SubOperators[0];
     146    }
     147
     148    private IAnalyzerModel CreateGPModel() {
     149      IScope bestModelScope = Engine.GlobalScope.SubScopes[0];
     150      return DefaultStructureIdentificationAlgorithmOperators.CreateGPModel(bestModelScope);
     151    }
    130152  }
    131153}
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGP.cs

    r2337 r2340  
    2929using System.Collections.Generic;
    3030using System;
     31using HeuristicLab.DataAnalysis;
    3132
    3233namespace HeuristicLab.GP.StructureIdentification {
     
    3536    public override string Name { get { return "StandardGP - StructureIdentification"; } }
    3637
    37     public HeuristicLab.DataAnalysis.Dataset Dataset {
    38       get {
    39         throw new NotImplementedException();
    40       }
    41       set {
    42         throw new NotImplementedException();
    43       }
     38    public virtual int TargetVariable {
     39      get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; }
     40      set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; }
    4441    }
    4542
    46     public int TargetVariable {
    47       get {
    48         throw new NotImplementedException();
    49       }
    50       set {
    51         throw new NotImplementedException();
    52       }
     43    public virtual Dataset Dataset {
     44      get { return ProblemInjector.GetVariableValue<Dataset>("Dataset", null, false); }
     45      set { ProblemInjector.GetVariable("Dataset").Value = value; }
    5346    }
    5447
    55     public IAnalyzerModel Model {
    56       get { throw new NotImplementedException(); }
     48    public virtual IAnalyzerModel Model {
     49      get {
     50        if (!Engine.Terminated)
     51          throw new InvalidOperationException("The algorithm is still running. Wait until the algorithm is terminated to retrieve the result.");
     52        else
     53          return CreateGPModel();
     54      }
    5755    }
    5856
     
    6058      get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; }
    6159      set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; }
     60    }
     61
     62    public override IOperator ProblemInjector {
     63      get { return GetProblemInjector().OperatorGraph.InitialOperator.SubOperators[0]; }
     64      set {
     65        value.Name = "ProblemInjector";
     66        CombinedOperator problemInjector = GetProblemInjector();
     67        problemInjector.OperatorGraph.RemoveOperator(ProblemInjector.Guid);
     68        problemInjector.OperatorGraph.AddOperator(value);
     69        problemInjector.OperatorGraph.InitialOperator.AddSubOperator(value, 0);
     70      }
    6271    }
    6372
     
    8190
    8291    protected override IOperator CreateEvaluationOperator() {
    83       return DefaultStructureIdentificationAlgorithmOperators.CreateEvaluator();     
     92      return DefaultStructureIdentificationAlgorithmOperators.CreateEvaluator();
    8493    }
    8594
     
    91100    protected override VariableInjector CreateGlobalInjector() {
    92101      VariableInjector injector = base.CreateGlobalInjector();
    93       injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));
    94102      injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData()));
    95103      return injector;
     
    123131    }
    124132
     133    protected override IOperator CreatePostProcessingOperator() {
     134      return DefaultStructureIdentificationAlgorithmOperators.CreatePostProcessingOperator();
     135    }
     136
    125137    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    126138      StandardGP clone = (StandardGP)base.Clone(clonedObjects);
     
    128140      return clone;
    129141    }
     142
     143    protected CombinedOperator GetProblemInjector() {
     144      return (CombinedOperator)GetInitializationOperator().SubOperators[0];
     145    }
     146
     147    private IAnalyzerModel CreateGPModel() {
     148      IScope bestModelScope = Engine.GlobalScope.SubScopes[0];
     149      return DefaultStructureIdentificationAlgorithmOperators.CreateGPModel(bestModelScope);
     150    }
    130151  }
    131152}
  • branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs

    r2328 r2340  
    125125      injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(1000)));
    126126      injector.AddVariable(new HeuristicLab.Core.Variable("TotalEvaluatedNodes", new DoubleData(0)));
    127       injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData(false)));
    128127
    129128      return injector;
Note: See TracChangeset for help on using the changeset viewer.