- Timestamp:
- 08/03/08 10:51:50 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/GPOperatorGroup.cs
r423 r425 41 41 var localVariableInfos = op.VariableInfos.Where(f => f.Local); 42 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 }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 81 82 82 // add a new typeid if necessary … … 97 97 op.AddVariable(new Variable(GPOperatorLibrary.TICKETS, new DoubleData(1.0))); 98 98 } 99 100 //RecalculateAllowedSuboperators();101 //RecalculateMinimalTreeBounds();102 103 99 OnOperatorAdded(op); 104 100 } … … 248 244 249 245 250 private IOperator GetDefaultManipulationOperator(IVariableInfo variableInfo) {251 IOperator shaker;252 if(variableInfo.DataType == typeof(ConstrainedDoubleData) ||253 variableInfo.DataType == typeof(ConstrainedIntData) ||254 variableInfo.DataType == typeof(DoubleData) ||255 variableInfo.DataType == typeof(IntData)) {256 shaker = new NormalRandomAdder();257 } else {258 return null;259 }260 shaker.GetVariableInfo("Value").ActualName = variableInfo.FormalName;261 shaker.Name = variableInfo.FormalName + " manipulation";262 return shaker;263 }264 265 private IOperator GetDefaultInitOperator(IVariableInfo variableInfo) {266 IOperator shaker;267 if(variableInfo.DataType == typeof(ConstrainedDoubleData) ||268 variableInfo.DataType == typeof(ConstrainedIntData) ||269 variableInfo.DataType == typeof(DoubleData) ||270 variableInfo.DataType == typeof(IntData)) {271 shaker = new UniformRandomizer();272 } else {273 return null;274 }275 shaker.GetVariableInfo("Value").ActualName = variableInfo.FormalName;276 shaker.Name = variableInfo.FormalName + " initialization";277 return shaker;278 }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 //} 279 275 280 276 public override void AddSubGroup(IOperatorGroup group) { … … 284 280 public override void RemoveOperator(IOperator op) { 285 281 base.RemoveOperator(op); 286 op.RemoveVariable(GPOperatorLibrary.MANIPULATION);287 op.RemoveVariable(GPOperatorLibrary.INITIALIZATION);288 282 op.RemoveVariable(GPOperatorLibrary.TYPE_ID); 289 283 op.RemoveVariable(GPOperatorLibrary.MIN_TREE_SIZE);
Note: See TracChangeset
for help on using the changeset viewer.