- Timestamp:
- 04/22/08 18:05:14 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/FullTreeShaker.cs
r88 r155 29 29 using HeuristicLab.Data; 30 30 using HeuristicLab.Selection; 31 using HeuristicLab.Functions; 31 32 32 33 namespace HeuristicLab.StructureIdentification { … … 38 39 public FullTreeShaker() 39 40 : base() { 41 AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In)); 40 42 AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines operator mutations", typeof(GPOperatorLibrary), VariableKind.In)); 41 AddVariableInfo(new VariableInfo("OperatorTree", "The operator tree that should be mutated", typeof(IOperator), VariableKind.In)); 42 AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In)); 43 AddVariableInfo(new VariableInfo("ShakingFactor", "Variable that determines the force of the shakeing operation", typeof(DoubleData), VariableKind.In)); 43 AddVariableInfo(new VariableInfo("ShakingFactor", "Variable that determines the force of the shaking operation", typeof(DoubleData), VariableKind.In)); 44 AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be mutated", typeof(IFunctionTree), VariableKind.In | VariableKind.Out)); 44 45 } 45 46 46 47 public override IOperation Apply(IScope scope) { 47 48 GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true); 48 I Operator op = GetVariableValue<IOperator>("OperatorTree", scope, false);49 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false); 49 50 MersenneTwister mt = GetVariableValue<MersenneTwister>("Random", scope, true); 50 51 … … 56 57 57 58 TreeGardener gardener = new TreeGardener(mt, library); 58 var parametric Nodes = gardener.GetAllOperators(op).Where(o => o.GetVariable(GPOperatorLibrary.MANIPULATION) != null);59 foreach(I Operator subOperator in parametricNodes) {60 IOperator mutation =(IOperator)sub Operator.GetVariable(GPOperatorLibrary.MANIPULATION).Value;59 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Function.GetVariable(GPOperatorLibrary.MANIPULATION) != null); 60 foreach(IFunctionTree subTree in parametricBranches) { 61 IOperator mutation =(IOperator)subTree.Function.GetVariable(GPOperatorLibrary.MANIPULATION).Value; 61 62 62 63 // store all local variables into a temporary scope 63 64 Scope mutationScope = new Scope(); 64 foreach(IVariableInfo info in subOperator.VariableInfos) { 65 if(info.Local) { 66 mutationScope.AddVariable(subOperator.GetVariable(info.FormalName)); 67 } 65 foreach(IVariable variable in subTree.LocalVariables) { 66 mutationScope.AddVariable(variable); 68 67 } 69 68
Note: See TracChangeset
for help on using the changeset viewer.