Changeset 11009 for branches/DataPreprocessing/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 06/12/14 13:26:18 (10 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/DataPreprocessing/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged: 10562,10859,10985
- Property svn:mergeinfo changed
-
branches/DataPreprocessing/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/LinearInstruction.cs
r9828 r11009 25 25 public class LinearInstruction : Instruction { 26 26 public double value; 27 public bytechildIndex;27 public int childIndex; 28 28 public bool skip; 29 29 } -
branches/DataPreprocessing/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeLinearCompiler.cs
r9828 r11009 34 34 code[c + j] = new LinearInstruction { dynamicNode = s, nArguments = (byte)s.SubtreeCount, opCode = opCodeMapper(s) }; 35 35 } 36 code[i].childIndex = (byte)c;36 code[i].childIndex = c; 37 37 c += node.SubtreeCount; 38 38 ++i; -
branches/DataPreprocessing/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj
r10538 r11009 140 140 <Compile Include="Interfaces\ISymbolicExpressionGrammarBase.cs" /> 141 141 <Compile Include="Interfaces\ISymbolicExpressionTreeGrammar.cs" /> 142 <Compile Include="Interfaces\ISymbolicExpressionTreeNodeComparer.cs" /> 143 <Compile Include="Interfaces\ISymbolicExpressionTreeNodeSimilarityComparer.cs" /> 142 144 <Compile Include="Interfaces\Operators\ISymbolicExpressionTreeArchitectureAlteringOperator.cs" /> 143 145 <Compile Include="Interfaces\Operators\ISymbolicExpressionTreeGrammarBasedOperator.cs" /> -
branches/DataPreprocessing/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r9456 r11009 323 323 if (cachedIsAllowedChildSymbol.TryGetValue(key, out result)) return result; 324 324 325 List<string> temp; 326 if (allowedChildSymbols.TryGetValue(parent.Name, out temp)) { 327 //if (temp.Contains(child.Name)) return true; 328 if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) { 329 cachedIsAllowedChildSymbol.Add(key, true); 330 return true; 325 // value has to be calculated and cached make sure this is done in only one thread 326 lock (cachedIsAllowedChildSymbol) { 327 // in case the value has been calculated on another thread in the meanwhile 328 if (cachedIsAllowedChildSymbol.TryGetValue(key, out result)) return result; 329 330 List<string> temp; 331 if (allowedChildSymbols.TryGetValue(parent.Name, out temp)) { 332 if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) { 333 cachedIsAllowedChildSymbol.Add(key, true); 334 return true; 335 } 331 336 } 332 }333 cachedIsAllowedChildSymbol.Add(key, false);334 return false;337 cachedIsAllowedChildSymbol.Add(key, false); 338 return false; 339 } 335 340 } 336 341 … … 345 350 if (cachedIsAllowedChildSymbolIndex.TryGetValue(key, out result)) return result; 346 351 347 List<string> temp; 348 if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, argumentIndex), out temp)) { 349 if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) { 350 cachedIsAllowedChildSymbolIndex.Add(key, true); 351 return true; 352 // value has to be calculated and cached make sure this is done in only one thread 353 lock (cachedIsAllowedChildSymbolIndex) { 354 // in case the value has been calculated on another thread in the meanwhile 355 if (cachedIsAllowedChildSymbolIndex.TryGetValue(key, out result)) return result; 356 357 List<string> temp; 358 if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, argumentIndex), out temp)) { 359 if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) { 360 cachedIsAllowedChildSymbolIndex.Add(key, true); 361 return true; 362 } 352 363 } 353 }354 cachedIsAllowedChildSymbolIndex.Add(key, false);355 return false;364 cachedIsAllowedChildSymbolIndex.Add(key, false); 365 return false; 366 } 356 367 } 357 368 … … 391 402 return res; 392 403 393 res = GetMinimumExpressionLengthRec(symbol); 394 foreach (var entry in cachedMinExpressionLength.Where(e => e.Value >= int.MaxValue).ToList()) { 395 if (entry.Key != symbol.Name) cachedMinExpressionLength.Remove(entry.Key); 396 } 397 return res; 404 // value has to be calculated and cached make sure this is done in only one thread 405 lock (cachedMinExpressionLength) { 406 // in case the value has been calculated on another thread in the meanwhile 407 if (cachedMinExpressionLength.TryGetValue(symbol.Name, out res)) return res; 408 409 res = GetMinimumExpressionLengthRec(symbol); 410 foreach (var entry in cachedMinExpressionLength.Where(e => e.Value >= int.MaxValue).ToList()) { 411 if (entry.Key != symbol.Name) cachedMinExpressionLength.Remove(entry.Key); 412 } 413 return res; 414 } 398 415 } 399 416 … … 418 435 int temp; 419 436 var key = Tuple.Create(symbol.Name, maxDepth); 420 if (!cachedMaxExpressionLength.TryGetValue(key, out temp)) { 437 if (cachedMaxExpressionLength.TryGetValue(key, out temp)) return temp; 438 // value has to be calculated and cached make sure this is done in only one thread 439 lock (cachedMaxExpressionLength) { 440 // in case the value has been calculated on another thread in the meanwhile 441 if (cachedMaxExpressionLength.TryGetValue(key, out temp)) return temp; 442 421 443 cachedMaxExpressionLength[key] = int.MaxValue; // prevent infinite recursion 422 444 long sumOfMaxTrees = 1 + (from argIndex in Enumerable.Range(0, GetMaximumSubtreeCount(symbol)) … … 429 451 return cachedMaxExpressionLength[key]; 430 452 } 431 return temp;432 453 } 433 454 … … 438 459 return res; 439 460 440 res = GetMinimumExpressionDepthRec(symbol); 441 foreach (var entry in cachedMinExpressionDepth.Where(e => e.Value >= int.MaxValue).ToList()) { 442 if (entry.Key != symbol.Name) cachedMinExpressionDepth.Remove(entry.Key); 443 } 444 return res; 461 // value has to be calculated and cached make sure this is done in only one thread 462 lock (cachedMinExpressionDepth) { 463 // in case the value has been calculated on another thread in the meanwhile 464 if (cachedMinExpressionDepth.TryGetValue(symbol.Name, out res)) return res; 465 466 res = GetMinimumExpressionDepthRec(symbol); 467 foreach (var entry in cachedMinExpressionDepth.Where(e => e.Value >= int.MaxValue).ToList()) { 468 if (entry.Key != symbol.Name) cachedMinExpressionDepth.Remove(entry.Key); 469 } 470 return res; 471 } 445 472 } 446 473 private int GetMinimumExpressionDepthRec(ISymbol symbol) { … … 462 489 public int GetMaximumExpressionDepth(ISymbol symbol) { 463 490 int temp; 464 if (!cachedMaxExpressionDepth.TryGetValue(symbol.Name, out temp)) { 491 if (cachedMaxExpressionDepth.TryGetValue(symbol.Name, out temp)) return temp; 492 // value has to be calculated and cached make sure this is done in only one thread 493 lock (cachedMaxExpressionDepth) { 494 // in case the value has been calculated on another thread in the meanwhile 495 if (cachedMaxExpressionDepth.TryGetValue(symbol.Name, out temp)) return temp; 496 465 497 cachedMaxExpressionDepth[symbol.Name] = int.MaxValue; 466 498 long maxDepth = 1 + (from argIndex in Enumerable.Range(0, GetMaximumSubtreeCount(symbol)) … … 472 504 return cachedMaxExpressionDepth[symbol.Name]; 473 505 } 474 return temp;475 506 } 476 507
Note: See TracChangeset
for help on using the changeset viewer.