Changeset 2222 for trunk/sources/HeuristicLab.GP.SantaFe
- Timestamp:
- 08/03/09 12:26:42 (15 years ago)
- 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 21 21 22 22 using 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; 23 using HeuristicLab.GP.Interfaces; 30 24 31 25 namespace HeuristicLab.GP.SantaFe { -
trunk/sources/HeuristicLab.GP.SantaFe/3.3/Evaluator.cs
r1529 r2222 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 27 23 using HeuristicLab.Data; 28 using HeuristicLab. DataAnalysis;24 using HeuristicLab.GP.Interfaces; 29 25 30 26 namespace HeuristicLab.GP.SantaFe { … … 32 28 public Evaluator() 33 29 : base() { 34 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree representing the ant", typeof(I FunctionTree), VariableKind.In));30 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree representing the ant", typeof(IGeneticProgrammingModel), VariableKind.In)); 35 31 AddVariableInfo(new VariableInfo("FoodEaten", "Number of food items that the ant found", typeof(DoubleData), VariableKind.New | VariableKind.Out)); 36 32 } 37 33 38 34 public override IOperation Apply(IScope scope) { 39 I FunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);35 IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, false); 40 36 AntInterpreter interpreter = new AntInterpreter(); 41 37 interpreter.MaxTimeSteps = 600; 42 interpreter.Run( tree);38 interpreter.Run(gpModel.FunctionTree); 43 39 44 40 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FoodEaten"), new DoubleData(interpreter.FoodEaten))); -
trunk/sources/HeuristicLab.GP.SantaFe/3.3/FunctionLibraryInjector.cs
r1529 r2222 20 20 #endregion 21 21 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; 22 using HeuristicLab.GP.Interfaces; 30 23 31 24 namespace HeuristicLab.GP.SantaFe { 32 public class FunctionLibraryInjector : OperatorBase { 33 private const string OPERATORLIBRARY = "FunctionLibrary"; 34 35 private GPOperatorLibrary operatorLibrary; 25 public class FunctionLibraryInjector : FunctionLibraryInjectorBase { 36 26 37 27 public override string Description { … … 41 31 public FunctionLibraryInjector() 42 32 : base() { 43 AddVariableInfo(new VariableInfo(OPERATORLIBRARY, "Preconfigured default operator library", typeof(GPOperatorLibrary), VariableKind.New));44 33 } 45 34 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(); 53 37 IfFoodAhead ifFoodAhead = new IfFoodAhead(); 54 38 Prog2 prog2 = new Prog2(); … … 71 55 SetAllowedSubOperators(prog3, allFunctions); 72 56 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; 98 64 } 99 65 } -
trunk/sources/HeuristicLab.GP.SantaFe/3.3/HeuristicLab.GP.SantaFe-3.3.csproj
r1534 r2222 83 83 <Compile Include="AntInterpreter.cs" /> 84 84 <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" />91 85 <Compile Include="HeuristicLabGPSantaFePlugin.cs" /> 92 86 <Compile Include="Properties\AssemblyInfo.cs" /> 93 87 <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" /> 95 95 </ItemGroup> 96 96 <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>101 97 <ProjectReference Include="..\..\HeuristicLab.Core\3.2\HeuristicLab.Core-3.2.csproj"> 102 98 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 103 99 <Name>HeuristicLab.Core-3.2</Name> 104 100 </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>109 101 <ProjectReference Include="..\..\HeuristicLab.Data\3.2\HeuristicLab.Data-3.2.csproj"> 110 102 <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project> 111 103 <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> 112 108 </ProjectReference> 113 109 <ProjectReference Include="..\..\HeuristicLab.GP\3.3\HeuristicLab.GP-3.3.csproj"> -
trunk/sources/HeuristicLab.GP.SantaFe/3.3/HeuristicLabGPSantaFePlugin.cs
r1529 r2222 28 28 [ClassInfo(Name = "HeuristicLab.GP.SantaFe-3.3")] 29 29 [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")]32 30 [Dependency(Dependency = "HeuristicLab.Core-3.2")] 33 31 [Dependency(Dependency = "HeuristicLab.Data-3.2")] 32 [Dependency(Dependency = "HeuristicLab.GP-3.3")] 33 [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")] 34 34 [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")] 35 35 [Dependency(Dependency = "HeuristicLab.Random-3.2")]
Note: See TracChangeset
for help on using the changeset viewer.