Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/29/09 18:28:45 (15 years ago)
Author:
gkronber
Message:

GP Refactoring #713

  • introduced a plugin for GP interfaces
  • created a new interface IGeneticProgrammingModel which represents GP models in HL scopes instead of IFunctionTree
  • changed interfaces IFunction and IFunctionTree
  • moved some files to new directories (general housekeeping)
  • changed all GP operators and engines to work with IGeneticProgrammingModels
  • removed parameters TreeSize and TreeHeight in all GP operators
  • changed parameter OperatorLibrary to FunctionLibrary in all GP operators
Location:
branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/HeuristicLab.LinearRegression-3.2.csproj

    r2161 r2210  
    113113      <Name>HeuristicLab.Data-3.2</Name>
    114114    </ProjectReference>
     115    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
     116      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
     117      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
     118    </ProjectReference>
    115119    <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification\3.3\HeuristicLab.GP.StructureIdentification-3.3.csproj">
    116120      <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project>
  • branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/HeuristicLabLinearRegressionPlugin.cs

    r2161 r2210  
    3232  [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
    3333  [Dependency(Dependency = "HeuristicLab.GP-3.3")]
     34  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
    3435  [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.3")]
    3536  [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
  • branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegression.cs

    r2164 r2210  
    3434using HeuristicLab.GP;
    3535using HeuristicLab.Random;
     36using HeuristicLab.GP.Interfaces;
    3637
    3738namespace HeuristicLab.LinearRegression {
     
    281282      model.TestVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data;
    282283
    283       model.Data = bestModelScope.GetVariableValue<IFunctionTree>("LinearRegressionModel", false);
     284      model.Data = bestModelScope.GetVariableValue<IGeneticProgrammingModel>("LinearRegressionModel", false);
    284285      HeuristicLab.DataAnalysis.Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true);
    285286      model.Dataset = ds;
  • branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs

    r2202 r2210  
    2828using HeuristicLab.GP;
    2929using HeuristicLab.GP.StructureIdentification;
     30using HeuristicLab.GP.Interfaces;
    3031
    3132namespace HeuristicLab.LinearRegression {
     
    3839      AddVariableInfo(new VariableInfo("SamplesStart", "Start index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
    3940      AddVariableInfo(new VariableInfo("SamplesEnd", "End index of samples in dataset to evaluate", typeof(IntData), VariableKind.In));
    40       AddVariableInfo(new VariableInfo("LinearRegressionModel", "Formula that was calculated by linear regression", typeof(IFunctionTree), VariableKind.Out | VariableKind.New));
    41       AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
    42       AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
     41      AddVariableInfo(new VariableInfo("LinearRegressionModel", "Formula that was calculated by linear regression", typeof(IGeneticProgrammingModel), VariableKind.Out | VariableKind.New));
    4342    }
    4443
     
    5554      double[] coefficients = CalculateCoefficients(inputMatrix, targetVector);
    5655      IFunctionTree tree = CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList());
    57 
    58       scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), tree));
    59       scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeSize"), new IntData(tree.Size)));
    60       scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeHeight"), new IntData(tree.Height)));
     56     
     57      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), new GeneticProgrammingModel(tree)));
    6158      return null;
    6259    }
     
    7370      GP.StructureIdentification.Variable v;
    7471      for (int i = 0; i < coefficients.Length - 1; i++) {
    75         var vNode = new GP.StructureIdentification.Variable().GetTreeNode();
    76         vNode.GetLocalVariable(GP.StructureIdentification.Variable.INDEX).Value = new StringData(allowedVariables[i]);
    77         vNode.GetLocalVariable(GP.StructureIdentification.Variable.WEIGHT).Value = new DoubleData(coefficients[i]);
    78         vNode.GetLocalVariable(GP.StructureIdentification.Variable.OFFSET).Value = new ConstrainedIntData(0);
     72        var vNode = (VariableFunctionTree)new GP.StructureIdentification.Variable().GetTreeNode();
     73        vNode.VariableName = allowedVariables[i];
     74        vNode.Weight = coefficients[i];
     75        vNode.SampleOffset = 0;
    7976        nodes.Enqueue(vNode);
    8077      }
    81       var cNode = new Constant().GetTreeNode();
     78      var cNode = (ConstantFunctionTree)new Constant().GetTreeNode();
    8279
    83       cNode.GetLocalVariable(GP.StructureIdentification.Constant.VALUE).Value = new DoubleData(coefficients[coefficients.Length - 1]);
     80      cNode.Value = coefficients[coefficients.Length - 1];
    8481      nodes.Enqueue(cNode);
    8582
Note: See TracChangeset for help on using the changeset viewer.