Changeset 2730 for trunk/sources/HeuristicLab.GP/3.3/TreeGardener.cs
- Timestamp:
- 02/01/10 16:43:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP/3.3/TreeGardener.cs
r2675 r2730 483 483 484 484 public static IFunction RandomSelect(IRandom random, IList<IFunction> functionSet) { 485 if (random == null || functionSet == null) throw new ArgumentNullException(); 486 if (functionSet.Count == 0) throw new ArgumentException("Empty function set"); 487 if (functionSet.Select(x => x.Tickets).Sum() <= 0) throw new ArgumentException("All functions in set have 0 tickets"); 485 488 double[] accumulatedTickets = new double[functionSet.Count]; 486 489 double ticketAccumulator = 0; … … 498 501 if (r < accumulatedTickets[i]) return functionSet[i]; 499 502 } 500 // sanity check 501 throw new InvalidProgramException(); // should never happen 503 throw new ArgumentException(); 502 504 } 503 505
Note: See TracChangeset
for help on using the changeset viewer.