- Timestamp:
- 07/20/09 20:14:47 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.Boolean/3.3/BooleanTreeInterpreter.cs
r1529 r2174 67 67 case SymbolTable.NOR: return !(Step() | Step()); 68 68 case SymbolTable.VARIABLE: 69 return dataset.GetValue(currentRow, (int)curFun. data[0]) != 0.0;69 return dataset.GetValue(currentRow, (int)curFun.localData[0]) != 0.0; 70 70 case SymbolTable.UNKNOWN: 71 71 default: -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Constant.cs
r2166 r2174 41 41 public Constant() 42 42 : base() { 43 AddVariableInfo(new VariableInfo(VALUE, "The constant value", typeof( ConstrainedDoubleData), VariableKind.None));43 AddVariableInfo(new VariableInfo(VALUE, "The constant value", typeof(DoubleData), VariableKind.None)); 44 44 GetVariableInfo(VALUE).Local = true; 45 45 -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs
r2165 r2174 32 32 namespace HeuristicLab.GP.StructureIdentification { 33 33 public class FunctionLibraryInjector : OperatorBase { 34 private const string NUMBEROFINPUTVARIABLES = "NumberOfInputVariables";35 34 private const string FUNCTIONLIBRARY = "FunctionLibrary"; 36 35 private const string TARGETVARIABLE = "TargetVariable"; … … 70 69 public FunctionLibraryInjector() 71 70 : base() { 72 AddVariableInfo(new VariableInfo(NUMBEROFINPUTVARIABLES, "The number of available input variables", typeof(IntData), VariableKind.In));73 71 AddVariableInfo(new VariableInfo(TARGETVARIABLE, "The target variable", typeof(IntData), VariableKind.In)); 74 72 AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In)); … … 111 109 StructId.Variable variable; 112 110 GPOperatorLibrary operatorLibrary; 113 int nInputVariables = GetVariableValue<IntData>(NUMBEROFINPUTVARIABLES, scope, true).Data;114 111 int targetVariable = GetVariableValue<IntData>(TARGETVARIABLE, scope, true).Data; 115 112 … … 225 222 ConditionalAddOperator(XOR_ALLOWED, operatorLibrary, xor); 226 223 227 variable.SetConstraints( 1, nInputVariables,minTimeOffset, maxTimeOffset);228 differential.SetConstraints( 1, nInputVariables,minTimeOffset, maxTimeOffset);224 variable.SetConstraints(minTimeOffset, maxTimeOffset); 225 differential.SetConstraints(minTimeOffset, maxTimeOffset); 229 226 230 227 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(FUNCTIONLIBRARY), operatorLibrary)); -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ModelAnalyzerExporter.cs
r2167 r2174 196 196 weight = ((DoubleData)weightItem).Data; 197 197 } 198 double index = ((ConstrainedIntData)tree.GetLocalVariable(Variable.INDEX).Value).Data;198 string index = ((StringData)tree.GetLocalVariable(Variable.INDEX).Value).Data; 199 199 double offset = ((ConstrainedIntData)tree.GetLocalVariable(Variable.OFFSET).Value).Data; 200 200 -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/TreeEvaluatorBase.cs
r2034 r2174 78 78 case EvaluatorSymbolTable.DIFFERENTIAL: 79 79 case EvaluatorSymbolTable.VARIABLE: { 80 instr.i_arg0 = (short) f.data[0]; // var81 instr.d_arg0 = f.data[1]; // weight82 instr.i_arg1 = (short) f.data[2]; // sample-offset80 instr.i_arg0 = (short)dataset.GetVariableIndex((string)f.localData[0]); // var 81 instr.d_arg0 = (double)f.localData[1]; // weight 82 instr.i_arg1 = (short)(int)f.localData[2]; // sample-offset 83 83 break; 84 84 } 85 85 case EvaluatorSymbolTable.CONSTANT: { 86 instr.d_arg0 = f.data[0]; // value86 instr.d_arg0 = (double)f.localData[0]; // value 87 87 break; 88 88 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs
r2166 r2174 38 38 public const string INDEX = "Variable"; 39 39 40 private int minIndex;41 private int maxIndex;42 40 private int minOffset; 43 41 private int maxOffset; … … 53 51 public Variable() 54 52 : base() { 55 AddVariableInfo(new VariableInfo(INDEX, " Index of the variable in the dataset representing this feature", typeof(ConstrainedIntData), VariableKind.None));53 AddVariableInfo(new VariableInfo(INDEX, "The variable name", typeof(StringData), VariableKind.None)); 56 54 GetVariableInfo(INDEX).Local = true; 57 AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof( ConstrainedDoubleData), VariableKind.None));55 AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof(DoubleData), VariableKind.None)); 58 56 GetVariableInfo(WEIGHT).Local = true; 59 57 AddVariableInfo(new VariableInfo(OFFSET, "SampleOffset is added to the sample index", typeof(ConstrainedIntData), VariableKind.None)); … … 67 65 AddVariable(new HeuristicLab.Core.Variable(WEIGHT, weight)); 68 66 69 ConstrainedIntData variable = new ConstrainedIntData();67 StringData variable = new StringData(); 70 68 AddVariable(new HeuristicLab.Core.Variable(INDEX, variable)); 71 minIndex = 0; maxIndex = 1000;72 69 73 70 ConstrainedIntData sampleOffset = new ConstrainedIntData(); … … 84 81 CombinedOperator combinedOp = new CombinedOperator(); 85 82 SequentialProcessor seq = new SequentialProcessor(); 86 UniformRandomizer indexRandomizer = new UniformRandomizer(); 87 indexRandomizer.Min = minIndex; 88 indexRandomizer.Max = maxIndex + 1; // uniform randomizer generates numbers in the range [min, max[ 89 indexRandomizer.GetVariableInfo("Value").ActualName = INDEX; 90 indexRandomizer.Name = "Index Randomizer"; 83 UniformItemChooser variableRandomizer = new UniformItemChooser(); 84 variableRandomizer.GetVariableInfo("Value").ActualName = INDEX; 85 variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables"; 86 variableRandomizer.Name = "Variable randomizer"; 91 87 NormalRandomizer weightRandomizer = new NormalRandomizer(); 92 88 weightRandomizer.Mu = 0.0; … … 101 97 102 98 combinedOp.OperatorGraph.AddOperator(seq); 103 combinedOp.OperatorGraph.AddOperator( indexRandomizer);99 combinedOp.OperatorGraph.AddOperator(variableRandomizer); 104 100 combinedOp.OperatorGraph.AddOperator(weightRandomizer); 105 101 combinedOp.OperatorGraph.AddOperator(offsetRandomizer); 106 102 combinedOp.OperatorGraph.InitialOperator = seq; 107 seq.AddSubOperator( indexRandomizer);103 seq.AddSubOperator(variableRandomizer); 108 104 seq.AddSubOperator(weightRandomizer); 109 105 seq.AddSubOperator(offsetRandomizer); … … 120 116 CombinedOperator combinedOp = new CombinedOperator(); 121 117 SequentialProcessor seq = new SequentialProcessor(); 122 UniformRandomizer indexRandomizer = new UniformRandomizer(); 123 indexRandomizer.Min = minIndex; 124 indexRandomizer.Max = maxIndex + 1; 125 indexRandomizer.GetVariableInfo("Value").ActualName = INDEX; 126 indexRandomizer.Name = "Index Randomizer"; 118 UniformItemChooser variableRandomizer = new UniformItemChooser(); 119 variableRandomizer.GetVariableInfo("Value").ActualName = INDEX; 120 variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables"; 121 variableRandomizer.Name = "Variable randomizer"; 127 122 NormalRandomAdder weightRandomAdder = new NormalRandomAdder(); 128 123 weightRandomAdder.Mu = 0.0; … … 137 132 138 133 combinedOp.OperatorGraph.AddOperator(seq); 139 combinedOp.OperatorGraph.AddOperator( indexRandomizer);134 combinedOp.OperatorGraph.AddOperator(variableRandomizer); 140 135 combinedOp.OperatorGraph.AddOperator(weightRandomAdder); 141 136 combinedOp.OperatorGraph.AddOperator(offsetRandomAdder); 142 137 combinedOp.OperatorGraph.InitialOperator = seq; 143 seq.AddSubOperator( indexRandomizer);138 seq.AddSubOperator(variableRandomizer); 144 139 seq.AddSubOperator(weightRandomAdder); 145 140 seq.AddSubOperator(offsetRandomAdder); … … 152 147 } 153 148 154 public void SetConstraints(int min InputIndex, int maxInputIndex, int minSampleOffset, int maxSampleOffset) {149 public void SetConstraints(int minSampleOffset, int maxSampleOffset) { 155 150 ConstrainedIntData offset = GetVariableValue<ConstrainedIntData>(OFFSET, null, false); 156 151 IntBoundedConstraint offsetConstraint = new IntBoundedConstraint(); … … 165 160 offset.AddConstraint(offsetConstraint); 166 161 167 ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false);168 IntBoundedConstraint indexConstraint = new IntBoundedConstraint();169 minIndex = minInputIndex;170 maxIndex = maxInputIndex;171 indexConstraint.LowerBound = minInputIndex;172 indexConstraint.LowerBoundEnabled = true;173 indexConstraint.LowerBoundIncluded = true;174 indexConstraint.UpperBound = maxInputIndex;175 indexConstraint.UpperBoundEnabled = true;176 indexConstraint.UpperBoundIncluded = true;177 index.AddConstraint(indexConstraint);162 //ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false); 163 //IntBoundedConstraint indexConstraint = new IntBoundedConstraint(); 164 //minIndex = minInputIndex; 165 //maxIndex = maxInputIndex; 166 //indexConstraint.LowerBound = minInputIndex; 167 //indexConstraint.LowerBoundEnabled = true; 168 //indexConstraint.LowerBoundIncluded = true; 169 //indexConstraint.UpperBound = maxInputIndex; 170 //indexConstraint.UpperBoundEnabled = true; 171 //indexConstraint.UpperBoundIncluded = true; 172 //index.AddConstraint(indexConstraint); 178 173 179 174 SetupInitialization(); -
trunk/sources/HeuristicLab.GP/3.3/BakedFunctionTree.cs
r1529 r2174 34 34 public byte arity = 0; 35 35 public IFunction functionType; 36 public List< double> data = new List<double>();36 public List<object> localData = new List<object>(); 37 37 38 38 public LightWeightFunction Clone() { … … 40 40 clone.arity = arity; 41 41 clone.functionType = functionType; 42 clone. data.AddRange(data);42 clone.localData.AddRange(localData); 43 43 return clone; 44 44 } … … 50 50 get { 51 51 FlattenVariables(); 52 FlattenTrees(); 52 FlattenTrees(); 53 53 return linearRepresentation; 54 54 } … … 72 72 variables = new List<IVariable>(); 73 73 variablesExpanded = true; 74 foreach (IVariableInfo variableInfo in function.VariableInfos) {75 if (variableInfo.Local) {74 foreach (IVariableInfo variableInfo in function.VariableInfos) { 75 if (variableInfo.Local) { 76 76 variables.Add((IVariable)function.GetVariable(variableInfo.FormalName).Clone()); 77 77 } … … 84 84 fun.functionType = tree.Function; 85 85 linearRepresentation.Add(fun); 86 foreach (IVariable variable in tree.LocalVariables) {87 I Item value =variable.Value;88 fun. data.Add(GetDoubleValue(value));89 } 90 foreach (IFunctionTree subTree in tree.SubTrees) {86 foreach (IVariable variable in tree.LocalVariables) { 87 IObjectData value = (IObjectData)variable.Value; 88 fun.localData.Add(value.Data); 89 } 90 foreach (IFunctionTree subTree in tree.SubTrees) { 91 91 AddSubTree(new BakedFunctionTree(subTree)); 92 92 } 93 }94 95 private double GetDoubleValue(IItem value) {96 if(value is DoubleData) {97 return ((DoubleData)value).Data;98 } else if(value is ConstrainedDoubleData) {99 return ((ConstrainedDoubleData)value).Data;100 } else if(value is IntData) {101 return ((IntData)value).Data;102 } else if(value is ConstrainedIntData) {103 return ((ConstrainedIntData)value).Data;104 } else throw new NotSupportedException("Invalid datatype of local variable for GP");105 93 } 106 94 … … 108 96 int arity = linearRepresentation[branchRoot].arity; 109 97 int length = 1; 110 for (int i = 0; i < arity; i++) {98 for (int i = 0; i < arity; i++) { 111 99 length += BranchLength(branchRoot + length); 112 100 } … … 115 103 116 104 private void FlattenTrees() { 117 if (treesExpanded) {105 if (treesExpanded) { 118 106 linearRepresentation[0].arity = (byte)subTrees.Count; 119 foreach (BakedFunctionTree subTree in subTrees) {107 foreach (BakedFunctionTree subTree in subTrees) { 120 108 subTree.FlattenVariables(); 121 109 subTree.FlattenTrees(); … … 128 116 129 117 private void FlattenVariables() { 130 if(variablesExpanded) { 131 linearRepresentation[0].data.Clear(); 132 foreach(IVariable variable in variables) { 133 linearRepresentation[0].data.Add(GetDoubleValue(variable.Value)); 118 if (variablesExpanded) { 119 linearRepresentation[0].localData.Clear(); 120 foreach (IVariable variable in variables) { 121 object objData = variable.Value; 122 while (objData is IObjectData) objData = ((IObjectData)objData).Data; 123 linearRepresentation[0].localData.Add(objData); 134 124 } 135 125 variablesExpanded = false; … … 140 130 public int Size { 141 131 get { 142 if (treesExpanded) {132 if (treesExpanded) { 143 133 int size = 1; 144 foreach (BakedFunctionTree tree in subTrees) {134 foreach (BakedFunctionTree tree in subTrees) { 145 135 size += tree.Size; 146 136 } 147 137 return size; 148 } else 149 return linearRepresentation.Count;138 } else 139 return linearRepresentation.Count; 150 140 } 151 141 } … … 153 143 public int Height { 154 144 get { 155 if (treesExpanded) {145 if (treesExpanded) { 156 146 int height = 0; 157 foreach (IFunctionTree subTree in subTrees) {147 foreach (IFunctionTree subTree in subTrees) { 158 148 int curHeight = subTree.Height; 159 if (curHeight > height) height = curHeight;160 } 161 return height +1;149 if (curHeight > height) height = curHeight; 150 } 151 return height + 1; 162 152 } else { 163 153 int nextBranchStart; … … 171 161 int height = 0; 172 162 branchStart++; 173 for (int i = 0; i < f.arity; i++) {163 for (int i = 0; i < f.arity; i++) { 174 164 int curHeight = BranchHeight(branchStart, out nextBranchStart); 175 if (curHeight > height) height = curHeight;165 if (curHeight > height) height = curHeight; 176 166 branchStart = nextBranchStart; 177 167 } … … 182 172 public IList<IFunctionTree> SubTrees { 183 173 get { 184 if (!treesExpanded) {174 if (!treesExpanded) { 185 175 subTrees = new List<IFunctionTree>(); 186 176 int arity = linearRepresentation[0].arity; 187 177 int branchIndex = 1; 188 for (int i = 0; i < arity; i++) {178 for (int i = 0; i < arity; i++) { 189 179 BakedFunctionTree subTree = new BakedFunctionTree(); 190 180 int length = BranchLength(branchIndex); 191 for (int j = branchIndex; j < branchIndex + length; j++) {181 for (int j = branchIndex; j < branchIndex + length; j++) { 192 182 subTree.linearRepresentation.Add(linearRepresentation[j]); 193 183 } … … 205 195 public ICollection<IVariable> LocalVariables { 206 196 get { 207 if (!variablesExpanded) {197 if (!variablesExpanded) { 208 198 variables = new List<IVariable>(); 209 199 IFunction function = Function; 210 200 int localVariableIndex = 0; 211 foreach (IVariableInfo variableInfo in function.VariableInfos) {212 if (variableInfo.Local) {201 foreach (IVariableInfo variableInfo in function.VariableInfos) { 202 if (variableInfo.Local) { 213 203 IVariable clone = (IVariable)function.GetVariable(variableInfo.FormalName).Clone(); 214 IItem value = clone.Value; 215 if(value is ConstrainedDoubleData) { 216 ((ConstrainedDoubleData)value).Data = linearRepresentation[0].data[localVariableIndex]; 217 } else if(value is ConstrainedIntData) { 218 ((ConstrainedIntData)value).Data = (int)linearRepresentation[0].data[localVariableIndex]; 219 } else if(value is DoubleData) { 220 ((DoubleData)value).Data = linearRepresentation[0].data[localVariableIndex]; 221 } else if(value is IntData) { 222 ((IntData)value).Data = (int)linearRepresentation[0].data[localVariableIndex]; 223 } else throw new NotSupportedException("Invalid local variable type for GP."); 204 IObjectData objData = (IObjectData)clone.Value; 205 if (objData is ConstrainedDoubleData) { 206 ((ConstrainedDoubleData)objData).Data = (double)linearRepresentation[0].localData[localVariableIndex]; 207 } else if (objData is ConstrainedIntData) { 208 ((ConstrainedIntData)objData).Data = (int)linearRepresentation[0].localData[localVariableIndex]; 209 } else { 210 objData.Data = linearRepresentation[0].localData[localVariableIndex]; 211 } 224 212 variables.Add(clone); 225 213 localVariableIndex++; … … 227 215 } 228 216 variablesExpanded = true; 229 linearRepresentation[0]. data.Clear();217 linearRepresentation[0].localData.Clear(); 230 218 } 231 219 return variables; … … 238 226 239 227 public IVariable GetLocalVariable(string name) { 240 foreach (IVariable var in LocalVariables) {241 if (var.Name == name) return var;228 foreach (IVariable var in LocalVariables) { 229 if (var.Name == name) return var; 242 230 } 243 231 return null; … … 253 241 254 242 public void AddSubTree(IFunctionTree tree) { 255 if (!treesExpanded) throw new InvalidOperationException();243 if (!treesExpanded) throw new InvalidOperationException(); 256 244 subTrees.Add(tree); 257 245 } 258 246 259 247 public void InsertSubTree(int index, IFunctionTree tree) { 260 if (!treesExpanded) throw new InvalidOperationException();248 if (!treesExpanded) throw new InvalidOperationException(); 261 249 subTrees.Insert(index, tree); 262 250 } … … 264 252 public void RemoveSubTree(int index) { 265 253 // sanity check 266 if (!treesExpanded) throw new InvalidOperationException();254 if (!treesExpanded) throw new InvalidOperationException(); 267 255 subTrees.RemoveAt(index); 268 256 } … … 273 261 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 274 262 XmlNode linearRepresentationNode = document.CreateElement("LinearRepresentation"); 275 foreach (LightWeightFunction f in linearRepresentation) {276 XmlNode entryNode = PersistenceManager.Persist("Function Type", f.functionType, document, persistedObjects);263 foreach (LightWeightFunction f in linearRepresentation) { 264 XmlNode entryNode = PersistenceManager.Persist("Function", f.functionType, document, persistedObjects); 277 265 XmlAttribute arityAttribute = document.CreateAttribute("Arity"); 278 arityAttribute.Value = f.arity+"";266 arityAttribute.Value = XmlConvert.ToString(f.arity); 279 267 entryNode.Attributes.Append(arityAttribute); 280 if(f.data.Count > 0) {281 XmlAttribute dataAttribute = document.CreateAttribute("Data");282 dataAttribute.Value = GetString(f.data);283 entryNode.Attributes.Append(dataAttribute);268 foreach (object o in f.localData) { 269 if (f.localData.Count > 0) { 270 entryNode.AppendChild(CreateDataNode(document, o)); 271 } 284 272 } 285 273 linearRepresentationNode.AppendChild(entryNode); … … 287 275 288 276 node.AppendChild(linearRepresentationNode); 277 return node; 278 } 279 280 private XmlNode CreateDataNode(XmlDocument doc, object o) { 281 XmlNode node = doc.CreateElement("Data"); 282 XmlAttribute typeAttr = doc.CreateAttribute("Type"); 283 node.Attributes.Append(typeAttr); 284 if (o is double) { 285 node.Value = XmlConvert.ToString((double)o); 286 typeAttr.Value = "d"; 287 } else if (o is int) { 288 node.Value = XmlConvert.ToString((int)o); 289 typeAttr.Value = "i"; 290 } else if (o is string) { 291 node.Value = (string)o; 292 typeAttr.Value = "s"; 293 } else throw new ArgumentException("Invalid type for local data element: " + o); 289 294 return node; 290 295 } … … 293 298 base.Populate(node, restoredObjects); 294 299 XmlNode linearRepresentationNode = node.SelectSingleNode("LinearRepresentation"); 295 foreach (XmlNode entryNode in linearRepresentationNode.ChildNodes) {300 foreach (XmlNode entryNode in linearRepresentationNode.ChildNodes) { 296 301 LightWeightFunction f = new LightWeightFunction(); 297 f.arity = byte.Parse(entryNode.Attributes["Arity"].Value, CultureInfo.InvariantCulture); 298 if(entryNode.Attributes["Data"]!=null) 299 f.data = GetList<double>(entryNode.Attributes["Data"].Value, s => double.Parse(s, CultureInfo.InvariantCulture)); 302 f.arity = XmlConvert.ToByte(entryNode.Attributes["Arity"].Value); 303 foreach (XmlNode dataNode in entryNode.ChildNodes) { 304 f.localData.Add(ParseDataNode(dataNode)); 305 } 300 306 f.functionType = (IFunction)PersistenceManager.Restore(entryNode, restoredObjects); 301 307 linearRepresentation.Add(f); … … 305 311 } 306 312 307 private string GetString(IEnumerable<double> xs) { 308 StringBuilder builder = new StringBuilder(); 309 foreach(double x in xs) { 310 builder.Append(x.ToString("r", CultureInfo.InvariantCulture) + "; "); 311 } 312 if(builder.Length > 0) builder.Remove(builder.Length - 2, 2); 313 return builder.ToString(); 314 } 315 316 private List<T> GetList<T>(string s, Converter<string, T> converter) { 317 List<T> result = new List<T>(); 318 string[] tokens = s.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); 319 foreach(string token in tokens) { 320 T x = converter(token.Trim()); 321 result.Add(x); 322 } 323 return result; 324 } 313 private object ParseDataNode(XmlNode dataNode) { 314 string type = dataNode.Attributes["Type"].Value; 315 if (type == "d") { 316 return XmlConvert.ToDouble(dataNode.Value); 317 } else if (type == "i") { 318 return XmlConvert.ToInt32(dataNode.Value); 319 } else if (type == "s") { 320 return dataNode.Value; 321 } else throw new FormatException("Can't parse type \"" + type + "\" \"" + dataNode.Value + "\" as local data for GP trees"); 322 } 323 324 //private string GetString(IEnumerable<double> xs) { 325 // StringBuilder builder = new StringBuilder(); 326 // foreach (double x in xs) { 327 // builder.Append(x.ToString("r", CultureInfo.InvariantCulture) + "; "); 328 // } 329 // if (builder.Length > 0) builder.Remove(builder.Length - 2, 2); 330 // return builder.ToString(); 331 //} 332 333 //private List<T> GetList<T>(string s, Converter<string, T> converter) { 334 // List<T> result = new List<T>(); 335 // string[] tokens = s.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); 336 // foreach (string token in tokens) { 337 // T x = converter(token.Trim()); 338 // result.Add(x); 339 // } 340 // return result; 341 //} 325 342 326 343 public override object Clone(IDictionary<Guid, object> clonedObjects) { 327 344 BakedFunctionTree clone = new BakedFunctionTree(); 328 345 // in case the user (de)serialized the tree between evaluation and selection we have to flatten the tree again. 329 if (treesExpanded) FlattenTrees();330 if (variablesExpanded) FlattenVariables();331 foreach (LightWeightFunction f in linearRepresentation) {346 if (treesExpanded) FlattenTrees(); 347 if (variablesExpanded) FlattenVariables(); 348 foreach (LightWeightFunction f in linearRepresentation) { 332 349 clone.linearRepresentation.Add(f.Clone()); 333 350 } -
trunk/sources/HeuristicLab.Modeling/3.2/ProblemInjector.cs
r2165 r2174 78 78 AddVariableInfo(new VariableInfo("MaxNumberOfTrainingSamples", "Maximal number of training samples to use (optional)", typeof(IntData), VariableKind.In)); 79 79 AddVariableInfo(new VariableInfo("NumberOfInputVariables", "The number of available input variables", typeof(IntData), VariableKind.New)); 80 AddVariableInfo(new VariableInfo("InputVariables", "List of input variable names", typeof(ItemList), VariableKind.New)); 80 81 } 81 82 … … 97 98 98 99 Dataset scopeDataset = CreateNewDataset(operatorDataset, targetVariable, operatorAllowedFeatures); 100 ItemList inputVariables = new ItemList(); 101 for (int i = 1; i < scopeDataset.Columns; i++) { 102 inputVariables.Add(new StringData(scopeDataset.GetVariableName(i))); 103 } 99 104 100 scope.AddVariable(new Variable("Dataset", scopeDataset)); 101 scope.AddVariable(new Variable("TargetVariable", new IntData(0))); 102 scope.AddVariable(new Variable("NumberOfInputVariables", new IntData(scopeDataset.Columns - 1))); 105 scope.AddVariable(new Variable(scope.TranslateName("Dataset"), scopeDataset)); 106 scope.AddVariable(new Variable(scope.TranslateName("TargetVariable"), new IntData(0))); 107 scope.AddVariable(new Variable(scope.TranslateName("NumberOfInputVariables"), new IntData(scopeDataset.Columns - 1))); 108 scope.AddVariable(new Variable(scope.TranslateName("InputVariables"), inputVariables)); 103 109 104 110 int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data; … … 116 122 scope.AddVariable(new Variable(scope.TranslateName("ActualTrainingSamplesStart"), new IntData(trainingStart))); 117 123 scope.AddVariable(new Variable(scope.TranslateName("ActualTrainingSamplesEnd"), new IntData(trainingStart + nTrainingSamples))); 124 125 118 126 return null; 119 127 } … … 154 162 155 163 private void AddVariableToScope(string variableName, IScope scope) { 156 scope.AddVariable(new Variable( variableName, (IItem)GetVariable(variableName).Value.Clone()));164 scope.AddVariable(new Variable(scope.TranslateName(variableName), (IItem)GetVariable(variableName).Value.Clone())); 157 165 } 158 166 } -
trunk/sources/HeuristicLab.Random/3.2/HeuristicLab.Random-3.2.csproj
r1534 r2174 81 81 </ItemGroup> 82 82 <ItemGroup> 83 <Compile Include="UniformItemChooser.cs" /> 83 84 <Compile Include="UniformRandomAdder.cs" /> 84 85 <Compile Include="NormalRandomAdder.cs" /> -
trunk/sources/HeuristicLab.Random/3.2/UniformRandomizer.cs
r1530 r2174 63 63 /// </summary> 64 64 public UniformRandomizer() { 65 AddVariableInfo(new VariableInfo("Value", "The value to manipulate (type is one of: IntData, ConstrainedIntData, DoubleData, ConstrainedDoubleData)", typeof(IObjectData), VariableKind. In));65 AddVariableInfo(new VariableInfo("Value", "The value to manipulate (type is one of: IntData, ConstrainedIntData, DoubleData, ConstrainedDoubleData)", typeof(IObjectData), VariableKind.Out)); 66 66 AddVariableInfo(new VariableInfo("Random", "The random generator to use", typeof(MersenneTwister), VariableKind.In)); 67 67 AddVariableInfo(new VariableInfo("Min", "Lower bound of the uniform distribution (inclusive)", typeof(DoubleData), VariableKind.None));
Note: See TracChangeset
for help on using the changeset viewer.