Changeset 429
- Timestamp:
- 08/03/08 23:00:48 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/FunctionBase.cs
r425 r429 34 34 /// </summary> 35 35 public abstract class FunctionBase : OperatorBase, IFunction { 36 p rotectedconst string INITIALIZATION = "Initialization";37 p rotectedconst string MANIPULATION = "Manipulation";36 public const string INITIALIZATION = "Initialization"; 37 public const string MANIPULATION = "Manipulation"; 38 38 39 39 -
trunk/sources/HeuristicLab.StructureIdentification/GPOperatorGroup.cs
r425 r429 40 40 41 41 var localVariableInfos = op.VariableInfos.Where(f => f.Local); 42 43 //if(op.GetVariable(GPOperatorLibrary.MANIPULATION) == null) {44 // CombinedOperator manipulationOperator = new CombinedOperator();45 // SequentialProcessor manipulationSequence = new SequentialProcessor();46 // foreach(IVariableInfo variableInfo in localVariableInfos) {47 // IOperator manipulator = GetDefaultManipulationOperator(variableInfo);48 // if (manipulator != null) {49 // manipulationSequence.AddSubOperator(manipulator);50 // }51 // }52 // if(manipulationSequence.SubOperators.Count > 0) {53 // op.AddVariable(new Variable(GPOperatorLibrary.MANIPULATION, manipulationOperator));54 55 // manipulationOperator.OperatorGraph.AddOperator(manipulationSequence);56 // manipulationOperator.OperatorGraph.InitialOperator = manipulationSequence;57 // foreach(IOperator subOp in manipulationSequence.SubOperators) {58 // manipulationOperator.OperatorGraph.AddOperator(subOp);59 // }60 // }61 //}62 63 //if(op.GetVariable(GPOperatorLibrary.INITIALIZATION) == null) {64 // CombinedOperator initOperator = new CombinedOperator();65 // SequentialProcessor initSequence = new SequentialProcessor();66 // foreach(IVariableInfo variableInfo in localVariableInfos) {67 // IOperator initializer = GetDefaultInitOperator(variableInfo);68 // if (initializer != null) {69 // initSequence.AddSubOperator(initializer);70 // }71 // }72 // if(initSequence.SubOperators.Count > 0) {73 // op.AddVariable(new Variable(GPOperatorLibrary.INITIALIZATION, initOperator));74 // initOperator.OperatorGraph.AddOperator(initSequence);75 // initOperator.OperatorGraph.InitialOperator = initSequence;76 // foreach(IOperator subOp in initSequence.SubOperators) {77 // initOperator.OperatorGraph.AddOperator(subOp);78 // }79 // }80 //}81 42 82 43 // add a new typeid if necessary … … 243 204 } 244 205 245 246 //private IOperator GetDefaultManipulationOperator(IVariableInfo variableInfo) {247 // IOperator shaker;248 // if(variableInfo.DataType == typeof(ConstrainedDoubleData) ||249 // variableInfo.DataType == typeof(ConstrainedIntData) ||250 // variableInfo.DataType == typeof(DoubleData) ||251 // variableInfo.DataType == typeof(IntData)) {252 // shaker = new NormalRandomAdder();253 // } else {254 // return null;255 // }256 // shaker.GetVariableInfo("Value").ActualName = variableInfo.FormalName;257 // shaker.Name = variableInfo.FormalName + " manipulation";258 // return shaker;259 //}260 261 //private IOperator GetDefaultInitOperator(IVariableInfo variableInfo) {262 // IOperator shaker;263 // if(variableInfo.DataType == typeof(ConstrainedDoubleData) ||264 // variableInfo.DataType == typeof(ConstrainedIntData) ||265 // variableInfo.DataType == typeof(DoubleData) ||266 // variableInfo.DataType == typeof(IntData)) {267 // shaker = new UniformRandomizer();268 // } else {269 // return null;270 // }271 // shaker.GetVariableInfo("Value").ActualName = variableInfo.FormalName;272 // shaker.Name = variableInfo.FormalName + " initialization";273 // return shaker;274 //}275 276 206 public override void AddSubGroup(IOperatorGroup group) { 277 207 throw new NotSupportedException(); -
trunk/sources/HeuristicLab.StructureIdentification/GPOperatorLibraryEditor.cs
r423 r429 33 33 using HeuristicLab.Operators; 34 34 using HeuristicLab.Random; 35 using HeuristicLab.Functions; 35 36 36 37 namespace HeuristicLab.StructureIdentification { … … 54 55 55 56 foreach(IOperator op in library.Group.Operators) { 56 if(op.GetVariable( GPOperatorLibrary.MANIPULATION) != null) {57 if(op.GetVariable(FunctionBase.MANIPULATION) != null) { 57 58 ListViewItem item = new ListViewItem(); 58 59 item.Text = op.Name; … … 61 62 mutationListView.Items.Add(item); 62 63 } 63 if(op.GetVariable( GPOperatorLibrary.INITIALIZATION) != null) {64 if(op.GetVariable(FunctionBase.INITIALIZATION) != null) { 64 65 ListViewItem item = new ListViewItem(); 65 66 item.Name = op.Name; … … 74 75 private void GPOperatorLibraryView_OperatorAdded(object sender, EventArgs e) { 75 76 IOperator op = ((OperatorEventArgs)e).op; 76 if (op.GetVariable(GPOperatorLibrary.MANIPULATION) != null) {77 if(op.GetVariable(FunctionBase.MANIPULATION) != null) { 77 78 ListViewItem operatorMutationItem = new ListViewItem(); 78 79 operatorMutationItem.Name = op.Name; … … 82 83 } 83 84 84 if (op.GetVariable(GPOperatorLibrary.INITIALIZATION) != null) {85 if(op.GetVariable(FunctionBase.INITIALIZATION) != null) { 85 86 ListViewItem operatorInitItem = new ListViewItem(); 86 87 operatorInitItem.Name = op.Name; … … 133 134 private void mutationListView_SelectedIndexChanged(object sender, EventArgs e) { 134 135 if(mutationListView.SelectedItems.Count>0 && mutationListView.SelectedItems[0].Tag != null) { 135 IVariable variable = ((IOperator)mutationListView.SelectedItems[0].Tag).GetVariable( GPOperatorLibrary.MANIPULATION);136 IVariable variable = ((IOperator)mutationListView.SelectedItems[0].Tag).GetVariable(FunctionBase.MANIPULATION); 136 137 mutationVariableView.Enabled = true; 137 138 mutationVariableView.Variable = variable; … … 143 144 private void initListView_SelectedIndexChanged(object sender, EventArgs e) { 144 145 if(initListView.SelectedItems.Count>0 && initListView.SelectedItems[0].Tag != null) { 145 IVariable variable = ((IOperator)initListView.SelectedItems[0].Tag).GetVariable( GPOperatorLibrary.INITIALIZATION);146 IVariable variable = ((IOperator)initListView.SelectedItems[0].Tag).GetVariable(FunctionBase.INITIALIZATION); 146 147 initVariableView.Enabled = true; 147 148 initVariableView.Variable = variable; -
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/FullTreeShaker.cs
r155 r429 34 34 public class FullTreeShaker : DelegatingOperator { 35 35 public override string Description { 36 get { return "Manipulates all tree nodes for which a '" +GPOperatorLibrary.MANIPULATION+"' variable is defined."; }36 get { return "Manipulates all tree nodes for which a '" + FunctionBase.MANIPULATION + "' variable is defined."; } 37 37 } 38 38 … … 57 57 58 58 TreeGardener gardener = new TreeGardener(mt, library); 59 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Function.GetVariable( GPOperatorLibrary.MANIPULATION) != null);59 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Function.GetVariable(FunctionBase.MANIPULATION) != null); 60 60 foreach(IFunctionTree subTree in parametricBranches) { 61 IOperator mutation = (IOperator)subTree.Function.GetVariable(GPOperatorLibrary.MANIPULATION).Value;61 IOperator mutation = (IOperator)subTree.Function.GetVariable(FunctionBase.MANIPULATION).Value; 62 62 63 63 // store all local variables into a temporary scope … … 73 73 // save all existing sub-scopes in a backup scope 74 74 Scope backupScope = new Scope("backup"); 75 foreach 75 foreach(Scope subScope in scope.SubScopes) { 76 76 backupScope.AddSubScope(subScope); 77 77 } -
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/OnePointShaker.cs
r155 r429 34 34 public class OnePointShaker : DelegatingOperator { 35 35 public override string Description { 36 get { return "Selects a random node of all tree-nodes that have a '"+ GPOperatorLibrary.MANIPULATION+"' variable defined and manipulates the selected node."; }36 get { return "Selects a random node of all tree-nodes that have a '"+FunctionBase.MANIPULATION+"' variable defined and manipulates the selected node."; } 37 37 } 38 38 … … 52 52 53 53 // get all nodes for which a manipulation is defined 54 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Function.GetVariable( GPOperatorLibrary.MANIPULATION) != null);54 var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Function.GetVariable(FunctionBase.MANIPULATION) != null); 55 55 IFunctionTree selectedBranch = parametricBranches.ElementAt(mt.Next(parametricBranches.Count())); 56 IOperator mutation = (IOperator)selectedBranch.Function.GetVariable( GPOperatorLibrary.MANIPULATION).Value;56 IOperator mutation = (IOperator)selectedBranch.Function.GetVariable(FunctionBase.MANIPULATION).Value; 57 57 CompositeOperation next = new CompositeOperation(); 58 58 -
trunk/sources/HeuristicLab.StructureIdentification/TreeGardener.cs
r325 r429 216 216 Scope tempScope = new Scope("Temp. initialization scope"); 217 217 218 var parametricTrees = trees.Where(t => t.Function.GetVariable( GPOperatorLibrary.INITIALIZATION) != null);218 var parametricTrees = trees.Where(t => t.Function.GetVariable(FunctionBase.INITIALIZATION) != null); 219 219 foreach(IFunctionTree tree in parametricTrees) { 220 220 // enqueue an initialization operation for each operator with local variables 221 IOperator initialization = (IOperator)tree.Function.GetVariable( GPOperatorLibrary.INITIALIZATION).Value;221 IOperator initialization = (IOperator)tree.Function.GetVariable(FunctionBase.INITIALIZATION).Value; 222 222 Scope initScope = new Scope(); 223 223 // copy the local variables into a temporary scope used for initialization
Note: See TracChangeset
for help on using the changeset viewer.