- Timestamp:
- 07/30/09 19:41:58 (15 years ago)
- Location:
- branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3
- Files:
-
- 1 added
- 5 edited
- 7 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/AntInterpreter.cs
r1529 r2216 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 { -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/Evaluator.cs
r1529 r2216 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))); -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/FunctionLibraryInjector.cs
r2202 r2216 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 FunctionLibrary 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(FunctionLibrary), 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 FunctionLibrary(); 74 operatorLibrary.FunctionGroup.AddFunction(ifFoodAhead); 75 operatorLibrary.FunctionGroup.AddFunction(prog2); 76 operatorLibrary.FunctionGroup.AddFunction(prog3); 77 operatorLibrary.FunctionGroup.AddFunction(move); 78 operatorLibrary.FunctionGroup.AddFunction(left); 79 operatorLibrary.FunctionGroup.AddFunction(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 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/HeuristicLab.GP.SantaFe-3.3.csproj
r1534 r2216 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"> -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/HeuristicLabGPSantaFePlugin.cs
r1529 r2216 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")] -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/Symbols/IfFoodAhead.cs
r2211 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 using HeuristicLab.Data;26 using HeuristicLab.Core;27 using System.Xml;28 using HeuristicLab.Constraints;29 using HeuristicLab.DataAnalysis;30 using HeuristicLab.Random;31 32 22 namespace HeuristicLab.GP.SantaFe { 33 public sealed class IfFoodAhead : FunctionBase { 34 35 public override string Description { 36 get { return ""; } 37 } 38 39 public IfFoodAhead() 40 : base() { 41 MinArity = 2; MaxArity = 2; 42 } 23 public sealed class IfFoodAhead : BinaryFunction { 43 24 } 44 25 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/Symbols/Left.cs
r2211 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 using HeuristicLab.Data;26 using HeuristicLab.Core;27 using System.Xml;28 using HeuristicLab.Constraints;29 using HeuristicLab.DataAnalysis;30 using HeuristicLab.Random;31 32 22 namespace HeuristicLab.GP.SantaFe { 33 public sealed class Left : FunctionBase { 34 35 public override string Description { 36 get { return ""; } 37 } 38 39 public Left() 40 : base() { 41 MinArity = 0; MaxArity = 0; 42 } 23 public sealed class Left : Terminal { 43 24 } 44 25 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/Symbols/Move.cs
r2211 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 using HeuristicLab.Data;26 using HeuristicLab.Core;27 using System.Xml;28 using HeuristicLab.Constraints;29 using HeuristicLab.DataAnalysis;30 using HeuristicLab.Random;31 32 22 namespace HeuristicLab.GP.SantaFe { 33 public sealed class Move : FunctionBase { 34 35 public override string Description { 36 get { return ""; } 37 } 38 39 public Move() 40 : base() { 41 MinArity = 0; MaxArity = 0; 42 } 23 public sealed class Move : Terminal { 43 24 } 44 25 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/Symbols/Prog2.cs
r2211 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 using HeuristicLab.Data;26 using HeuristicLab.Core;27 using System.Xml;28 using HeuristicLab.Constraints;29 using HeuristicLab.DataAnalysis;30 using HeuristicLab.Random;31 22 32 23 namespace HeuristicLab.GP.SantaFe { 33 public sealed class Prog2 : FunctionBase { 34 35 public override string Description { 36 get { return ""; } 37 } 38 39 public Prog2() 40 : base() { 41 MinArity = 2; MaxArity = 2; 42 } 24 public sealed class Prog2 : BinaryFunction { 43 25 } 44 26 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/Symbols/Prog3.cs
r2211 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 using HeuristicLab.Data;26 using HeuristicLab.Core;27 using System.Xml;28 using HeuristicLab.Constraints;29 using HeuristicLab.DataAnalysis;30 using HeuristicLab.Random;31 32 22 namespace HeuristicLab.GP.SantaFe { 33 23 public sealed class Prog3 : FunctionBase { 34 24 35 public override string Description {36 get { return ""; }37 }38 39 25 public Prog3() 40 26 : base() { 41 Min Arity = 3; MaxArity= 3;27 MinSubTrees = 3; MaxSubTrees = 3; 42 28 } 43 29 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/Symbols/Right.cs
r2211 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 using HeuristicLab.Data;26 using HeuristicLab.Core;27 using System.Xml;28 using HeuristicLab.Constraints;29 using HeuristicLab.DataAnalysis;30 using HeuristicLab.Random;31 32 22 namespace HeuristicLab.GP.SantaFe { 33 public sealed class Right : FunctionBase { 34 public override string Description { 35 get { return ""; } 36 } 37 38 public Right() 39 : base() { 40 MinArity = 0; MaxArity = 0; 41 } 23 public sealed class Right : Terminal { 42 24 } 43 25 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.SantaFe/3.3/Symbols/SymbolTable.cs
r2211 r2216 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq;25 using System.Text;26 24 using HeuristicLab.Core; 27 using System.Xml;25 using HeuristicLab.GP.Interfaces; 28 26 29 27 namespace HeuristicLab.GP.SantaFe {
Note: See TracChangeset
for help on using the changeset viewer.