Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/09 12:26:42 (15 years ago)
Author:
gkronber
Message:

Merged changes from GP-refactoring branch back into the trunk #713.

Location:
trunk/sources/HeuristicLab.GP.SantaFe/3.3
Files:
7 deleted
5 edited
8 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.SantaFe/3.3/AntInterpreter.cs

    r1529 r2222  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    26 using HeuristicLab.DataAnalysis;
    27 using HeuristicLab.Core;
    28 using System.Xml;
    29 using System.Diagnostics;
     23using HeuristicLab.GP.Interfaces;
    3024
    3125namespace HeuristicLab.GP.SantaFe {
  • trunk/sources/HeuristicLab.GP.SantaFe/3.3/Evaluator.cs

    r1529 r2222  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2622using HeuristicLab.Core;
    2723using HeuristicLab.Data;
    28 using HeuristicLab.DataAnalysis;
     24using HeuristicLab.GP.Interfaces;
    2925
    3026namespace HeuristicLab.GP.SantaFe {
     
    3228    public Evaluator()
    3329      : base() {
    34       AddVariableInfo(new VariableInfo("FunctionTree", "The function tree representing the ant", typeof(IFunctionTree), VariableKind.In));
     30      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree representing the ant", typeof(IGeneticProgrammingModel), VariableKind.In));
    3531      AddVariableInfo(new VariableInfo("FoodEaten", "Number of food items that the ant found", typeof(DoubleData), VariableKind.New | VariableKind.Out));
    3632    }
    3733
    3834    public override IOperation Apply(IScope scope) {
    39       IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);
     35      IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, false);
    4036      AntInterpreter interpreter = new AntInterpreter();
    4137      interpreter.MaxTimeSteps = 600;
    42       interpreter.Run(tree);
     38      interpreter.Run(gpModel.FunctionTree);
    4339
    4440      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FoodEaten"), new DoubleData(interpreter.FoodEaten)));
  • trunk/sources/HeuristicLab.GP.SantaFe/3.3/FunctionLibraryInjector.cs

    r1529 r2222  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    26 using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    28 using HeuristicLab.DataAnalysis;
    29 using HeuristicLab.Constraints;
     22using HeuristicLab.GP.Interfaces;
    3023
    3124namespace HeuristicLab.GP.SantaFe {
    32   public class FunctionLibraryInjector : OperatorBase {
    33     private const string OPERATORLIBRARY = "FunctionLibrary";
    34 
    35     private GPOperatorLibrary operatorLibrary;
     25  public class FunctionLibraryInjector : FunctionLibraryInjectorBase {
    3626
    3727    public override string Description {
     
    4131    public FunctionLibraryInjector()
    4232      : base() {
    43       AddVariableInfo(new VariableInfo(OPERATORLIBRARY, "Preconfigured default operator library", typeof(GPOperatorLibrary), VariableKind.New));
    4433    }
    4534
    46     public override IOperation Apply(IScope scope) {
    47       InitDefaultOperatorLibrary();
    48       scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(OPERATORLIBRARY), operatorLibrary));
    49       return null;
    50     }
    51 
    52     private void InitDefaultOperatorLibrary() {
     35    protected override FunctionLibrary CreateFunctionLibrary() {
     36      FunctionLibrary funLib = new FunctionLibrary();
    5337      IfFoodAhead ifFoodAhead = new IfFoodAhead();
    5438      Prog2 prog2 = new Prog2();
     
    7155      SetAllowedSubOperators(prog3, allFunctions);
    7256
    73       operatorLibrary = new GPOperatorLibrary();
    74       operatorLibrary.GPOperatorGroup.AddOperator(ifFoodAhead);
    75       operatorLibrary.GPOperatorGroup.AddOperator(prog2);
    76       operatorLibrary.GPOperatorGroup.AddOperator(prog3);
    77       operatorLibrary.GPOperatorGroup.AddOperator(move);
    78       operatorLibrary.GPOperatorGroup.AddOperator(left);
    79       operatorLibrary.GPOperatorGroup.AddOperator(right);
    80     }
    81 
    82     private void SetAllowedSubOperators(IFunction f, IFunction[] gs) {
    83       foreach(IConstraint c in f.Constraints) {
    84         if(c is SubOperatorTypeConstraint) {
    85           SubOperatorTypeConstraint typeConstraint = c as SubOperatorTypeConstraint;
    86           typeConstraint.Clear();
    87           foreach(IFunction g in gs) {
    88             typeConstraint.AddOperator(g);
    89           }
    90         } else if(c is AllSubOperatorsTypeConstraint) {
    91           AllSubOperatorsTypeConstraint typeConstraint = c as AllSubOperatorsTypeConstraint;
    92           typeConstraint.Clear();
    93           foreach(IFunction g in gs) {
    94             typeConstraint.AddOperator(g);
    95           }
    96         }
    97       }
     57      funLib.AddFunction(ifFoodAhead);
     58      funLib.AddFunction(prog2);
     59      funLib.AddFunction(prog3);
     60      funLib.AddFunction(move);
     61      funLib.AddFunction(left);
     62      funLib.AddFunction(right);
     63      return funLib;
    9864    }
    9965  }
  • trunk/sources/HeuristicLab.GP.SantaFe/3.3/HeuristicLab.GP.SantaFe-3.3.csproj

    r1534 r2222  
    8383    <Compile Include="AntInterpreter.cs" />
    8484    <Compile Include="FunctionLibraryInjector.cs" />
    85     <Compile Include="Prog3.cs" />
    86     <Compile Include="Prog2.cs" />
    87     <Compile Include="IfFoodAhead.cs" />
    88     <Compile Include="Right.cs" />
    89     <Compile Include="Left.cs" />
    90     <Compile Include="Move.cs" />
    9185    <Compile Include="HeuristicLabGPSantaFePlugin.cs" />
    9286    <Compile Include="Properties\AssemblyInfo.cs" />
    9387    <Compile Include="Evaluator.cs" />
    94     <Compile Include="SymbolTable.cs" />
     88    <Compile Include="Symbols\IfFoodAhead.cs" />
     89    <Compile Include="Symbols\Left.cs" />
     90    <Compile Include="Symbols\Move.cs" />
     91    <Compile Include="Symbols\Prog2.cs" />
     92    <Compile Include="Symbols\Prog3.cs" />
     93    <Compile Include="Symbols\Right.cs" />
     94    <Compile Include="Symbols\SymbolTable.cs" />
    9595  </ItemGroup>
    9696  <ItemGroup>
    97     <ProjectReference Include="..\..\HeuristicLab.Constraints\3.2\HeuristicLab.Constraints-3.2.csproj">
    98       <Project>{FCD62C6F-4793-4593-AE9A-0BDCA256EE99}</Project>
    99       <Name>HeuristicLab.Constraints-3.2</Name>
    100     </ProjectReference>
    10197    <ProjectReference Include="..\..\HeuristicLab.Core\3.2\HeuristicLab.Core-3.2.csproj">
    10298      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
    10399      <Name>HeuristicLab.Core-3.2</Name>
    104100    </ProjectReference>
    105     <ProjectReference Include="..\..\HeuristicLab.DataAnalysis\3.2\HeuristicLab.DataAnalysis-3.2.csproj">
    106       <Project>{7DD3A97A-56E9-462F-90E2-A351FE7AF5C2}</Project>
    107       <Name>HeuristicLab.DataAnalysis-3.2</Name>
    108     </ProjectReference>
    109101    <ProjectReference Include="..\..\HeuristicLab.Data\3.2\HeuristicLab.Data-3.2.csproj">
    110102      <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project>
    111103      <Name>HeuristicLab.Data-3.2</Name>
     104    </ProjectReference>
     105    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
     106      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
     107      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
    112108    </ProjectReference>
    113109    <ProjectReference Include="..\..\HeuristicLab.GP\3.3\HeuristicLab.GP-3.3.csproj">
  • trunk/sources/HeuristicLab.GP.SantaFe/3.3/HeuristicLabGPSantaFePlugin.cs

    r1529 r2222  
    2828  [ClassInfo(Name = "HeuristicLab.GP.SantaFe-3.3")]
    2929  [PluginFile(Filename = "HeuristicLab.GP.SantaFe-3.3.dll", Filetype = PluginFileType.Assembly)]
    30   [Dependency(Dependency = "HeuristicLab.Constraints-3.2")]
    31   [Dependency(Dependency = "HeuristicLab.GP-3.3")]
    3230  [Dependency(Dependency = "HeuristicLab.Core-3.2")]
    3331  [Dependency(Dependency = "HeuristicLab.Data-3.2")]
     32  [Dependency(Dependency = "HeuristicLab.GP-3.3")]
     33  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
    3434  [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
    3535  [Dependency(Dependency = "HeuristicLab.Random-3.2")]
Note: See TracChangeset for help on using the changeset viewer.