- Timestamp:
- 08/03/08 10:51:50 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/Constant.cs
r229 r425 28 28 using HeuristicLab.Constraints; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.Operators; 31 using HeuristicLab.Random; 30 32 31 33 namespace HeuristicLab.Functions { … … 48 50 AddVariable(value); 49 51 52 SetupInitialization(); 53 SetupManipulation(); 54 50 55 // constant can't have suboperators 51 56 AddConstraint(new NumberOfSubOperatorsConstraint(0, 0)); 52 57 } 58 59 private void SetupInitialization() { 60 // initialization operator 61 AddVariableInfo(new VariableInfo(INITIALIZATION, "Initialization operator-graph for constants", typeof(IOperatorGraph), VariableKind.None)); 62 GetVariableInfo(INITIALIZATION).Local = false; 63 CombinedOperator combinedOp = new CombinedOperator(); 64 SequentialProcessor initSeq = new SequentialProcessor(); 65 UniformRandomizer randomizer = new UniformRandomizer(); 66 randomizer.Min = -20.0; 67 randomizer.Max = 20.0; 68 69 combinedOp.OperatorGraph.AddOperator(initSeq); 70 combinedOp.OperatorGraph.AddOperator(randomizer); 71 combinedOp.OperatorGraph.InitialOperator = initSeq; 72 initSeq.AddSubOperator(randomizer); 73 AddVariable(new HeuristicLab.Core.Variable(INITIALIZATION, combinedOp)); 74 } 75 76 private void SetupManipulation() { 77 // manipulation operator 78 AddVariableInfo(new VariableInfo(MANIPULATION, "Manipulation operator-graph for constants", typeof(IOperatorGraph), VariableKind.None)); 79 GetVariableInfo(MANIPULATION).Local = false; 80 CombinedOperator combinedOp = new CombinedOperator(); 81 SequentialProcessor manipulationSeq = new SequentialProcessor(); 82 NormalRandomAdder valueAdder = new NormalRandomAdder(); 83 valueAdder.Mu = 0.0; 84 valueAdder.Sigma = 0.1; 85 86 combinedOp.OperatorGraph.AddOperator(manipulationSeq); 87 combinedOp.OperatorGraph.AddOperator(valueAdder); 88 combinedOp.OperatorGraph.InitialOperator = manipulationSeq; 89 manipulationSeq.AddSubOperator(valueAdder); 90 AddVariable(new HeuristicLab.Core.Variable(MANIPULATION, combinedOp)); 91 } 92 53 93 public override void Accept(IFunctionVisitor visitor) { 54 94 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Differential.cs
r365 r425 28 28 using HeuristicLab.Constraints; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.Operators; 31 using HeuristicLab.Random; 30 32 31 33 namespace HeuristicLab.Functions { … … 60 62 61 63 ConstrainedIntData sampleOffset = new ConstrainedIntData(); 62 // initialize a totally arbitrary default range for sampleoffset = [-10, 10] 63 sampleOffset.AddConstraint(new IntBoundedConstraint(0, 0)); 64 // initialize a sample offset for static models 65 IntBoundedConstraint offsetConstraint = new IntBoundedConstraint(0, 0); 66 offsetConstraint.LowerBoundIncluded = true; 67 offsetConstraint.UpperBoundIncluded = true; 68 sampleOffset.AddConstraint(offsetConstraint); 64 69 AddVariable(new HeuristicLab.Core.Variable(OFFSET, sampleOffset)); 70 71 SetupInitialization(); 72 SetupManipulation(); 65 73 66 74 // variable can't have suboperators 67 75 AddConstraint(new NumberOfSubOperatorsConstraint(0, 0)); 76 } 77 78 private void SetupInitialization() { 79 AddVariableInfo(new VariableInfo(INITIALIZATION, "Initialization operator for differentials", typeof(CombinedOperator), VariableKind.None)); 80 GetVariableInfo(INITIALIZATION).Local = false; 81 CombinedOperator combinedOp = new CombinedOperator(); 82 SequentialProcessor seq = new SequentialProcessor(); 83 UniformRandomizer indexRandomizer = new UniformRandomizer(); 84 indexRandomizer.Min = 0; 85 indexRandomizer.Max = 10; 86 indexRandomizer.GetVariableInfo("Value").ActualName = INDEX; 87 indexRandomizer.Name = "Index Randomizer"; 88 NormalRandomizer weightRandomizer = new NormalRandomizer(); 89 weightRandomizer.Mu = 1.0; 90 weightRandomizer.Sigma = 1.0; 91 weightRandomizer.GetVariableInfo("Value").ActualName = WEIGHT; 92 weightRandomizer.Name = "Weight Randomizer"; 93 UniformRandomizer offsetRandomizer = new UniformRandomizer(); 94 offsetRandomizer.Min = 0.0; 95 offsetRandomizer.Max = 1.0; 96 offsetRandomizer.GetVariableInfo("Value").ActualName = OFFSET; 97 offsetRandomizer.Name = "Offset Randomizer"; 98 99 combinedOp.OperatorGraph.AddOperator(seq); 100 combinedOp.OperatorGraph.AddOperator(indexRandomizer); 101 combinedOp.OperatorGraph.AddOperator(weightRandomizer); 102 combinedOp.OperatorGraph.AddOperator(offsetRandomizer); 103 combinedOp.OperatorGraph.InitialOperator = seq; 104 seq.AddSubOperator(indexRandomizer); 105 seq.AddSubOperator(weightRandomizer); 106 seq.AddSubOperator(offsetRandomizer); 107 AddVariable(new HeuristicLab.Core.Variable(INITIALIZATION, combinedOp)); 108 } 109 110 private void SetupManipulation() { 111 // manipulation operator 112 AddVariableInfo(new VariableInfo(MANIPULATION, "Manipulation operator for differentials", typeof(CombinedOperator), VariableKind.None)); 113 GetVariableInfo(MANIPULATION).Local = false; 114 CombinedOperator combinedOp = new CombinedOperator(); 115 SequentialProcessor seq = new SequentialProcessor(); 116 UniformRandomizer indexRandomizer = new UniformRandomizer(); 117 indexRandomizer.Min = 0; 118 indexRandomizer.Max = 10; 119 indexRandomizer.GetVariableInfo("Value").ActualName = INDEX; 120 indexRandomizer.Name = "Index Randomizer"; 121 NormalRandomAdder weightRandomAdder = new NormalRandomAdder(); 122 weightRandomAdder.Mu = 0.0; 123 weightRandomAdder.Sigma = 0.1; 124 weightRandomAdder.GetVariableInfo("Value").ActualName = WEIGHT; 125 weightRandomAdder.Name = "Weight Adder"; 126 NormalRandomAdder offsetRandomAdder = new NormalRandomAdder(); 127 offsetRandomAdder.Mu = 0.0; 128 offsetRandomAdder.Sigma = 1.0; 129 offsetRandomAdder.GetVariableInfo("Value").ActualName = OFFSET; 130 offsetRandomAdder.Name = "Offset Adder"; 131 132 combinedOp.OperatorGraph.AddOperator(seq); 133 combinedOp.OperatorGraph.AddOperator(indexRandomizer); 134 combinedOp.OperatorGraph.AddOperator(weightRandomAdder); 135 combinedOp.OperatorGraph.AddOperator(offsetRandomAdder); 136 combinedOp.OperatorGraph.InitialOperator = seq; 137 seq.AddSubOperator(indexRandomizer); 138 seq.AddSubOperator(weightRandomAdder); 139 seq.AddSubOperator(offsetRandomAdder); 140 AddVariable(new HeuristicLab.Core.Variable(MANIPULATION, combinedOp)); 68 141 } 69 142 -
trunk/sources/HeuristicLab.Functions/FunctionBase.cs
r229 r425 34 34 /// </summary> 35 35 public abstract class FunctionBase : OperatorBase, IFunction { 36 protected const string INITIALIZATION = "Initialization"; 37 protected const string MANIPULATION = "Manipulation"; 38 36 39 37 40 public virtual double Apply(Dataset dataset, int sampleIndex, double[] args) { -
trunk/sources/HeuristicLab.Functions/HeuristicLab.Functions.csproj
r396 r425 118 118 <Name>HeuristicLab.Operators.Programmable</Name> 119 119 </ProjectReference> 120 <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj"> 121 <Project>{A9983BA2-B3B2-475E-8E2C-62050B71D1C5}</Project> 122 <Name>HeuristicLab.Operators</Name> 123 </ProjectReference> 120 124 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 121 125 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 122 126 <Name>HeuristicLab.PluginInfrastructure</Name> 127 </ProjectReference> 128 <ProjectReference Include="..\HeuristicLab.Random\HeuristicLab.Random.csproj"> 129 <Project>{47019A74-F7F7-482E-83AA-D3F4F777E879}</Project> 130 <Name>HeuristicLab.Random</Name> 123 131 </ProjectReference> 124 132 </ItemGroup> -
trunk/sources/HeuristicLab.Functions/HeuristicLabFunctionsPlugin.cs
r165 r425 32 32 [Dependency(Dependency = "HeuristicLab.Data")] 33 33 [Dependency(Dependency = "HeuristicLab.DataAnalysis")] 34 [Dependency(Dependency = "HeuristicLab.Operators")] 34 35 [Dependency(Dependency = "HeuristicLab.Operators.Programmable")] 36 [Dependency(Dependency = "HeuristicLab.Random")] 35 37 public class HeuristicLabFunctionsPlugin : PluginBase { 36 38 } -
trunk/sources/HeuristicLab.Functions/Variable.cs
r229 r425 28 28 using HeuristicLab.Constraints; 29 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.Random; 31 using HeuristicLab.Operators; 30 32 31 33 namespace HeuristicLab.Functions { … … 62 64 63 65 ConstrainedIntData sampleOffset = new ConstrainedIntData(); 64 // initialize a totally arbitrary default range for sampleoffset = [-10, 10] 65 sampleOffset.AddConstraint(new IntBoundedConstraint(0, 0)); 66 // initialize a sample offset for static models 67 IntBoundedConstraint offsetConstraint = new IntBoundedConstraint(0, 0); 68 offsetConstraint.LowerBoundIncluded = true; 69 offsetConstraint.UpperBoundIncluded = true; 70 sampleOffset.AddConstraint(offsetConstraint); 66 71 AddVariable(new HeuristicLab.Core.Variable(OFFSET, sampleOffset)); 72 73 SetupInitialization(); 74 SetupManipulation(); 67 75 68 76 // variable can't have suboperators 69 77 AddConstraint(new NumberOfSubOperatorsConstraint(0, 0)); 78 } 79 80 private void SetupInitialization() { 81 AddVariableInfo(new VariableInfo(INITIALIZATION, "Initialization operator for variables", typeof(CombinedOperator), VariableKind.None)); 82 GetVariableInfo(INITIALIZATION).Local = false; 83 CombinedOperator combinedOp = new CombinedOperator(); 84 SequentialProcessor seq = new SequentialProcessor(); 85 UniformRandomizer indexRandomizer = new UniformRandomizer(); 86 indexRandomizer.Min = 0; 87 indexRandomizer.Max = 10; 88 indexRandomizer.GetVariableInfo("Value").ActualName = INDEX; 89 indexRandomizer.Name = "Index Randomizer"; 90 NormalRandomizer weightRandomizer = new NormalRandomizer(); 91 weightRandomizer.Mu = 1.0; 92 weightRandomizer.Sigma = 1.0; 93 weightRandomizer.GetVariableInfo("Value").ActualName = WEIGHT; 94 weightRandomizer.Name = "Weight Randomizer"; 95 UniformRandomizer offsetRandomizer = new UniformRandomizer(); 96 offsetRandomizer.Min = 0.0; 97 offsetRandomizer.Max = 1.0; 98 offsetRandomizer.GetVariableInfo("Value").ActualName = OFFSET; 99 offsetRandomizer.Name = "Offset Randomizer"; 100 101 combinedOp.OperatorGraph.AddOperator(seq); 102 combinedOp.OperatorGraph.AddOperator(indexRandomizer); 103 combinedOp.OperatorGraph.AddOperator(weightRandomizer); 104 combinedOp.OperatorGraph.AddOperator(offsetRandomizer); 105 combinedOp.OperatorGraph.InitialOperator = seq; 106 seq.AddSubOperator(indexRandomizer); 107 seq.AddSubOperator(weightRandomizer); 108 seq.AddSubOperator(offsetRandomizer); 109 AddVariable(new HeuristicLab.Core.Variable(INITIALIZATION, combinedOp)); 110 } 111 112 private void SetupManipulation() { 113 // manipulation operator 114 AddVariableInfo(new VariableInfo(MANIPULATION, "Manipulation operator for variables", typeof(CombinedOperator), VariableKind.None)); 115 GetVariableInfo(MANIPULATION).Local = false; 116 CombinedOperator combinedOp = new CombinedOperator(); 117 SequentialProcessor seq = new SequentialProcessor(); 118 UniformRandomizer indexRandomizer = new UniformRandomizer(); 119 indexRandomizer.Min = 0; 120 indexRandomizer.Max = 10; 121 indexRandomizer.GetVariableInfo("Value").ActualName = INDEX; 122 indexRandomizer.Name = "Index Randomizer"; 123 NormalRandomAdder weightRandomAdder = new NormalRandomAdder(); 124 weightRandomAdder.Mu = 0.0; 125 weightRandomAdder.Sigma = 0.1; 126 weightRandomAdder.GetVariableInfo("Value").ActualName = WEIGHT; 127 weightRandomAdder.Name = "Weight Adder"; 128 NormalRandomAdder offsetRandomAdder = new NormalRandomAdder(); 129 offsetRandomAdder.Mu = 0.0; 130 offsetRandomAdder.Sigma = 1.0; 131 offsetRandomAdder.GetVariableInfo("Value").ActualName = OFFSET; 132 offsetRandomAdder.Name = "Offset Adder"; 133 134 combinedOp.OperatorGraph.AddOperator(seq); 135 combinedOp.OperatorGraph.AddOperator(indexRandomizer); 136 combinedOp.OperatorGraph.AddOperator(weightRandomAdder); 137 combinedOp.OperatorGraph.AddOperator(offsetRandomAdder); 138 combinedOp.OperatorGraph.InitialOperator = seq; 139 seq.AddSubOperator(indexRandomizer); 140 seq.AddSubOperator(weightRandomAdder); 141 seq.AddSubOperator(offsetRandomAdder); 142 AddVariable(new HeuristicLab.Core.Variable(MANIPULATION, combinedOp)); 70 143 } 71 144 -
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.