- Timestamp:
- 07/28/09 19:24:23 (15 years ago)
- Location:
- branches/GP-Refactoring-713
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/ChangeNodeTypeManipulation.cs
r656 r2202 45 45 : base() { 46 46 AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In)); 47 AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof( GPOperatorLibrary), VariableKind.In));47 AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In)); 48 48 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 49 49 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 57 57 IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, false); 58 58 MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true); 59 GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);59 FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true); 60 60 IntData treeSize = GetVariableValue<IntData>("TreeSize", scope, false); 61 61 IntData treeHeight = GetVariableValue<IntData>("TreeHeight", scope, false); … … 148 148 // first let's choose the function we want to use instead of the old child. For this we have to determine the 149 149 // pool of allowed functions based on constraints of the parent if there is one. 150 IList<IFunction> allowedFunctions = gardener.GetAllowedSubFunctions(parent!=null?parent.Function:null, childIndex);150 List<IFunction> allowedFunctions = new List<IFunction>(gardener.GetAllowedSubFunctions(parent != null ? parent.Function : null, childIndex)); 151 151 // try to make a tree with the same arity as the old child. 152 152 int actualArity = child.SubTrees.Count; -
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/CutOutNodeManipulation.cs
r656 r2202 50 50 : base() { 51 51 AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In)); 52 AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof( GPOperatorLibrary), VariableKind.In));52 AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In)); 53 53 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 54 54 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 62 62 IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); 63 63 MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true); 64 GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);64 FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true); 65 65 int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data; 66 66 int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data; -
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/DeleteSubTreeManipulation.cs
r656 r2202 40 40 : base() { 41 41 AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In)); 42 AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof( GPOperatorLibrary), VariableKind.In));42 AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In)); 43 43 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 44 44 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 52 52 IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); 53 53 MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true); 54 GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);54 FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true); 55 55 TreeGardener gardener = new TreeGardener(random, library); 56 56 IFunctionTree parent = gardener.GetRandomParentNode(root); -
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/FullTreeShaker.cs
r706 r2202 33 33 public class FullTreeShaker : DelegatingOperator { 34 34 public override string Description { 35 get { return "Manipulates all tree nodes for which a '" + FunctionBase.MANIPULATION + "' variableis defined."; }35 get { return "Manipulates all tree nodes for which a manipulator is defined."; } 36 36 } 37 37 … … 39 39 : base() { 40 40 AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In)); 41 AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines operator mutations", typeof( GPOperatorLibrary), VariableKind.In));41 AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines operator mutations", typeof(FunctionLibrary), VariableKind.In)); 42 42 AddVariableInfo(new VariableInfo("ShakingFactor", "Variable that determines the force of the shaking operation", typeof(DoubleData), VariableKind.In)); 43 43 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be mutated", typeof(IFunctionTree), VariableKind.In | VariableKind.Out)); … … 45 45 46 46 public override IOperation Apply(IScope scope) { 47 GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);47 FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true); 48 48 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false); 49 49 MersenneTwister mt = GetVariableValue<MersenneTwister>("Random", scope, true); … … 56 56 57 57 TreeGardener gardener = new TreeGardener(mt, library); 58 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch. Function.GetVariable(FunctionBase.MANIPULATION)!= null);58 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Manipulator!= null); 59 59 foreach(IFunctionTree subTree in parametricBranches) { 60 IOperator mutation = (IOperator)subTree.Function.GetVariable(FunctionBase.MANIPULATION).Value;60 IOperator mutation = subTree.Manipulator; 61 61 62 62 // store all local variables into a temporary scope -
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/OnePointShaker.cs
r1039 r2202 33 33 public class OnePointShaker : DelegatingOperator { 34 34 public override string Description { 35 get { return "Selects a random node of all tree-nodes that have a '"+FunctionBase.MANIPULATION+"' variabledefined and manipulates the selected node."; }35 get { return "Selects a random node of all tree-nodes that have a manipulator defined and manipulates the selected node."; } 36 36 } 37 37 38 38 public OnePointShaker() 39 39 : base() { 40 AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines mutation operations for operators", typeof( GPOperatorLibrary), VariableKind.In));40 AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines mutation operations for operators", typeof(FunctionLibrary), VariableKind.In)); 41 41 AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In)); 42 42 AddVariableInfo(new VariableInfo("ShakingFactor", "Factor that determines the force of the shaking operation", typeof(DoubleData), VariableKind.In)); … … 45 45 46 46 public override IOperation Apply(IScope scope) { 47 GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);47 FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true); 48 48 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false); 49 49 MersenneTwister mt = GetVariableValue<MersenneTwister>("Random", scope, true); … … 51 51 52 52 // get all nodes for which a manipulation is defined 53 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch. Function.GetVariable(FunctionBase.MANIPULATION)!= null);53 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Manipulator != null); 54 54 55 55 if(parametricBranches.Count() == 0) return null; // don't manipulate anything if there are no nodes with a manipulation operator 56 56 57 57 IFunctionTree selectedBranch = parametricBranches.ElementAt(mt.Next(parametricBranches.Count())); 58 IOperator mutation = (IOperator)selectedBranch.Function.GetVariable(FunctionBase.MANIPULATION).Value;58 IOperator mutation = selectedBranch.Manipulator; 59 59 CompositeOperation next = new CompositeOperation(); 60 60 -
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/SubstituteSubTreeManipulation.cs
r656 r2202 39 39 : base() { 40 40 AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In)); 41 AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof( GPOperatorLibrary), VariableKind.In));41 AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In)); 42 42 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 43 43 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 50 50 IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); 51 51 MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true); 52 GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);52 FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true); 53 53 int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data; 54 54 int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
Note: See TracChangeset
for help on using the changeset viewer.