- Timestamp:
- 04/05/10 18:53:37 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Creators/ProbabilisticTreeCreator.cs
r3239 r3270 61 61 private Symbol SelectRandomSymbol(IRandom random, IEnumerable<Symbol> symbols) { 62 62 var symbolList = symbols.ToList(); 63 return symbolList[random.Next(symbolList.Count)]; 63 var ticketsSum = symbolList.Select(x => x.Tickets.Value).Sum(); 64 var r = random.NextDouble() * ticketsSum; 65 double aggregatedTickets = 0; 66 for (int i = 0; i < symbolList.Count; i++) { 67 aggregatedTickets += symbolList[i].Tickets.Value; 68 if (aggregatedTickets >= r) { 69 return symbolList[i]; 70 } 71 } 72 // this should never happen 73 throw new ArgumentException(); 64 74 } 65 75
Note: See TracChangeset
for help on using the changeset viewer.