Changeset 2235
- Timestamp:
- 08/05/09 11:17:08 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 2 deleted
- 32 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.Interfaces/3.3/HeuristicLab.GP.Interfaces-3.3.csproj
r2222 r2235 80 80 </ItemGroup> 81 81 <ItemGroup> 82 <Compile Include="IFunctionTreeNameGenerator.cs">83 <SubType>Code</SubType>84 </Compile>85 82 <Compile Include="IFunctionTreeSerializer.cs"> 86 83 <SubType>Code</SubType> -
trunk/sources/HeuristicLab.GP.Interfaces/3.3/IFunctionTree.cs
r2222 r2235 37 37 void InsertSubTree(int index, IFunctionTree tree); 38 38 void RemoveSubTree(int index); 39 string ToString(); 39 40 } 40 41 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj
r2222 r2235 83 83 <ItemGroup> 84 84 <Compile Include="AlgorithmBase.cs" /> 85 <Compile Include="BaseClasses\FunctionTreeBase.cs" /> 85 86 <Compile Include="Evaluators\SimpleGPEvaluatorBase.cs" /> 86 87 <Compile Include="HL3TreeEvaluator.cs" /> -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ModelAnalyzerExporter.cs
r2222 r2235 24 24 25 25 namespace HeuristicLab.GP.StructureIdentification { 26 public class ModelAnalyzerExporter : IFunctionTreeSerializer , IFunctionTreeNameGenerator{26 public class ModelAnalyzerExporter : IFunctionTreeSerializer { 27 27 #region IFunctionTreeExporter Members 28 28 … … 73 73 #endregion 74 74 75 private st ring ExportFunction(IFunction function, IFunctionTree tree) {75 private static string ExportFunction(IFunction function, IFunctionTree tree) { 76 76 // this is smelly, if there is a cleaner way to have a 'dynamic' visitor 77 77 // please let me know! (gkronber 14.10.2008) … … 103 103 } 104 104 105 #region IFunctionTreeNameGenerator Members 106 107 string IFunctionTreeNameGenerator.Name { 108 get { return "HL2 Representation"; } 109 } 110 111 public string GetName(IFunctionTree tree) { 105 public static string GetName(IFunctionTree tree) { 112 106 string name = ""; 113 107 try { … … 118 112 return name; 119 113 } 120 121 #endregion122 123 124 114 } 125 115 -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolicExpressionExporter.cs
r2222 r2235 26 26 27 27 namespace HeuristicLab.GP.StructureIdentification { 28 public class SymbolicExpressionExporter : IFunctionTreeSerializer , IFunctionTreeNameGenerator{28 public class SymbolicExpressionExporter : IFunctionTreeSerializer { 29 29 private StringBuilder builder; 30 30 private string currentIndent; … … 66 66 } 67 67 68 private st ring ExportFunction(IFunction function, IFunctionTree tree) {68 private static string ExportFunction(IFunction function, IFunctionTree tree) { 69 69 // this is smelly, if there is a cleaner way to have a 'dynamic' visitor 70 70 // please let me know! (gkronber 14.10.2008) … … 99 99 #endregion 100 100 101 #region IFunctionTreeNameGenerator Members 102 103 string IFunctionTreeNameGenerator.Name { 104 get { return "Symbolic Expression"; } 105 } 106 107 public string GetName(IFunctionTree tree) { 101 public static string GetName(IFunctionTree tree) { 108 102 string name = ""; 109 103 try { 110 104 name = ExportFunction(tree.Function, tree); 111 } catch(UnknownFunctionException) { 105 } 106 catch (UnknownFunctionException) { 112 107 name = "N/A"; 113 108 } … … 115 110 } 116 111 117 #endregion 112 //public string GetName(IFunctionTree tree) { 113 // return SymbolicExpressionExporter.GetName(tree); 114 //} 118 115 } 119 116 -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Addition.cs
r2222 r2235 38 38 MaxSubTrees = 3; 39 39 } 40 41 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 42 return new FunctionTreeBase(this); 43 } 40 44 } 41 45 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/And.cs
r2222 r2235 35 35 MinSubTrees = 2; MaxSubTrees = 3; 36 36 } 37 38 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 39 return new FunctionTreeBase(this); 40 } 37 41 } 38 42 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Average.cs
r2222 r2235 33 33 MinSubTrees = 2; MaxSubTrees = 3; 34 34 } 35 36 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 37 return new FunctionTreeBase(this); 38 } 35 39 } 36 40 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/ConstantFunctionTree.cs
r2222 r2235 30 30 public double Value { get; set; } 31 31 32 public ConstantFunctionTree(Constant constant) : base(constant){ 32 public ConstantFunctionTree(Constant constant) 33 : base(constant) { 33 34 } 34 35 35 protected ConstantFunctionTree(ConstantFunctionTree original) : base(original){ 36 protected ConstantFunctionTree(ConstantFunctionTree original) 37 : base(original) { 36 38 Value = original.Value; 37 39 } … … 57 59 } 58 60 61 public override string ToString() { 62 return SymbolicExpressionExporter.GetName(this); 63 } 64 65 #region serialization 59 66 public override object Clone() { 60 67 return new ConstantFunctionTree(this); … … 73 80 Value = XmlConvert.ToDouble(node.Attributes["Value"].Value); 74 81 } 82 #endregion 75 83 76 84 private IVariable CreateValueVariable() { -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Cosinus.cs
r2222 r2235 30 30 : base() { 31 31 } 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 32 36 } 33 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Division.cs
r2222 r2235 37 37 38 38 public Division() : base() { } 39 40 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 41 return new FunctionTreeBase(this); 42 } 39 43 } 40 44 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Equal.cs
r2222 r2235 30 30 31 31 public Equal() : base() { } 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 32 36 } 33 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Exponential.cs
r2222 r2235 28 28 29 29 public Exponential() : base() { } 30 31 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 32 return new FunctionTreeBase(this); 33 } 30 34 } 31 35 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/GreaterThan.cs
r2222 r2235 31 31 public GreaterThan() : base() { } 32 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 33 36 } 34 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/IfThenElse.cs
r2222 r2235 34 34 MinSubTrees = 3; MaxSubTrees = 3; 35 35 } 36 37 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 38 return new FunctionTreeBase(this); 39 } 36 40 } 37 41 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/LessThan.cs
r2222 r2235 32 32 : base() { 33 33 } 34 35 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 36 return new FunctionTreeBase(this); 37 } 34 38 } 35 39 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Logarithm.cs
r2222 r2235 30 30 : base() { 31 31 } 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 32 36 } 33 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Multiplication.cs
r2222 r2235 37 37 MinSubTrees = 2; MaxSubTrees = 3; 38 38 } 39 40 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 41 return new FunctionTreeBase(this); 42 } 39 43 } 40 44 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Not.cs
r2222 r2235 31 31 : base() { 32 32 } 33 34 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 35 return new FunctionTreeBase(this); 36 } 33 37 } 34 38 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Or.cs
r2222 r2235 33 33 MinSubTrees = 2; MaxSubTrees = 3; 34 34 } 35 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 36 return new FunctionTreeBase(this); 37 } 35 38 } 36 39 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Power.cs
r2222 r2235 30 30 : base() { 31 31 } 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 32 36 } 33 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Signum.cs
r2222 r2235 30 30 : base() { 31 31 } 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 32 36 } 33 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Sinus.cs
r2222 r2235 30 30 : base() { 31 31 } 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 32 36 } 33 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Sqrt.cs
r2222 r2235 30 30 : base() { 31 31 } 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 32 36 } 33 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Subtraction.cs
r2222 r2235 35 35 : base() { 36 36 } 37 38 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 39 return new FunctionTreeBase(this); 40 } 37 41 } 38 42 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Tangens.cs
r2222 r2235 30 30 : base() { 31 31 } 32 33 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 34 return new FunctionTreeBase(this); 35 } 32 36 } 33 37 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/VariableFunctionTree.cs
r2222 r2235 67 67 } 68 68 69 public override string ToString() { 70 return SymbolicExpressionExporter.GetName(this); 71 } 72 73 #region serialization 69 74 public override object Clone() { 70 75 return new VariableFunctionTree(this); … … 91 96 VariableName = node.Attributes["Variable"].Value; 92 97 } 98 #endregion 93 99 94 100 private IVariable CreateSampleOffsetVariable() { -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Xor.cs
r2222 r2235 32 32 : base() { 33 33 } 34 35 public override HeuristicLab.GP.Interfaces.IFunctionTree GetTreeNode() { 36 return new FunctionTreeBase(this); 37 } 34 38 } 35 39 } -
trunk/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs
r2222 r2235 94 94 } 95 95 96 public virtual string ToString() { 97 return Function.Name; 98 } 99 96 100 #endregion 97 101 -
trunk/sources/HeuristicLab.GP/3.3/FunctionTreeView.cs
r2222 r2235 30 30 private IFunctionTree functionTree; 31 31 private IFunctionTree selectedBranch; 32 private IFunctionTreeNameGenerator nameGenerator;33 private IFunctionTreeNameGenerator[] allNameGenerators;34 private MenuItem representationsMenu;32 //private IFunctionTreeNameGenerator nameGenerator; 33 //private IFunctionTreeNameGenerator[] allNameGenerators; 34 //private MenuItem representationsMenu; 35 35 36 36 public FunctionTreeView() { 37 nameGenerator = new DefaultFunctionTreeNameGenerator();37 //nameGenerator = new DefaultFunctionTreeNameGenerator(); 38 38 InitializeComponent(); 39 39 40 40 DiscoveryService discoveryService = new DiscoveryService(); 41 allNameGenerators = discoveryService.GetInstances<IFunctionTreeNameGenerator>();42 representationsMenu = new MenuItem();43 representationsMenu.Text = "Tree representation";44 representationsMenu.Name = "Tree representation";45 foreach (IFunctionTreeNameGenerator generator in allNameGenerators) {46 MenuItem mi = new MenuItem(generator.Name, MakeNameGeneratorDelegate(generator), Shortcut.None);47 if (generator is DefaultFunctionTreeNameGenerator) mi.Checked = true;48 else mi.Checked = false;49 mi.Tag = generator;50 representationsMenu.MenuItems.Add(mi);51 }41 //allNameGenerators = discoveryService.GetInstances<IFunctionTreeNameGenerator>(); 42 //representationsMenu = new MenuItem(); 43 //representationsMenu.Text = "Tree representation"; 44 //representationsMenu.Name = "Tree representation"; 45 //foreach (IFunctionTreeNameGenerator generator in allNameGenerators) { 46 // MenuItem mi = new MenuItem(generator.Name, MakeNameGeneratorDelegate(generator), Shortcut.None); 47 // if (generator is DefaultFunctionTreeNameGenerator) mi.Checked = true; 48 // else mi.Checked = false; 49 // mi.Tag = generator; 50 // representationsMenu.MenuItems.Add(mi); 51 //} 52 52 } 53 53 … … 61 61 funTreeView.Nodes.Clear(); 62 62 TreeNode rootNode = new TreeNode(); 63 rootNode.Name = functionTree. Function.Name;64 rootNode.Text = nameGenerator.GetName(functionTree);63 rootNode.Name = functionTree.ToString(); // functionTree.Function.Name; 64 rootNode.Text = functionTree.ToString(); // nameGenerator.GetName(functionTree); 65 65 rootNode.Tag = functionTree; 66 66 treeNodeContextMenu.MenuItems.Clear(); 67 treeNodeContextMenu.MenuItems.Add(representationsMenu);67 //treeNodeContextMenu.MenuItems.Add(representationsMenu); 68 68 DiscoveryService discoveryService = new DiscoveryService(); 69 69 IFunctionTreeSerializer[] exporters = discoveryService.GetInstances<IFunctionTreeSerializer>(); … … 91 91 } 92 92 93 private EventHandler MakeNameGeneratorDelegate(IFunctionTreeNameGenerator generator) {94 return delegate(object source, EventArgs args) {95 IFunctionTreeNameGenerator g = (IFunctionTreeNameGenerator)((MenuItem)source).Tag;96 this.nameGenerator = g;97 foreach (MenuItem otherMenuItem in representationsMenu.MenuItems) otherMenuItem.Checked = false;98 ((MenuItem)source).Checked = true;99 UpdateControls();100 };101 }93 //private EventHandler MakeNameGeneratorDelegate(IFunctionTreeNameGenerator generator) { 94 // return delegate(object source, EventArgs args) { 95 // IFunctionTreeNameGenerator g = (IFunctionTreeNameGenerator)((MenuItem)source).Tag; 96 // this.nameGenerator = g; 97 // foreach (MenuItem otherMenuItem in representationsMenu.MenuItems) otherMenuItem.Checked = false; 98 // ((MenuItem)source).Checked = true; 99 // UpdateControls(); 100 // }; 101 //} 102 102 103 103 private EventHandler MakeExporterDelegate(IFunctionTreeSerializer exporter) { … … 111 111 private void CreateTree(TreeNode rootNode, IFunctionTree functionTree) { 112 112 TreeNode node = new TreeNode(); 113 node.Name = functionTree. Function.Name;114 node.Text = nameGenerator.GetName(functionTree);113 node.Name = functionTree.ToString(); 114 node.Text = functionTree.ToString(); 115 115 node.Tag = functionTree; 116 116 node.ContextMenu = treeNodeContextMenu; -
trunk/sources/HeuristicLab.GP/3.3/GeneticProgrammingModel.cs
r2222 r2235 47 47 } 48 48 49 public GeneticProgrammingModel(IFunctionTree tree) : base() { 49 public GeneticProgrammingModel(IFunctionTree tree) 50 : base() { 50 51 FunctionTree = tree; 51 52 } … … 87 88 IFunction f = (IFunction)PersistenceManager.Restore(fNode, restoredObjects); 88 89 IFunctionTree tree = f.GetTreeNode(); 89 if (fNode.ChildNodes.Count>0) tree.Populate(fNode.ChildNodes[0], restoredObjects);90 if (fNode.ChildNodes.Count > 0) tree.Populate(fNode.ChildNodes[0], restoredObjects); 90 91 nodeIndex++; 91 92 for (int i = 0; i < subTrees; i++) { -
trunk/sources/HeuristicLab.GP/3.3/HeuristicLab.GP-3.3.csproj
r2222 r2235 103 103 </Compile> 104 104 <Compile Include="GeneticProgrammingModel.cs" /> 105 <Compile Include="DefaultFunctionTreeNameGenerator.cs" />106 105 <Compile Include="UnknownFunctionException.cs" /> 107 106 <Compile Include="HeuristicLabGPPlugin.cs" />
Note: See TracChangeset
for help on using the changeset viewer.