Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/17/10 16:08:53 (14 years ago)
Author:
gkronber
Message:

Fixed a minor bug in the probabilistic tree creator. #1014

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Creators/ProbabilisticTreeCreator.cs

    r3742 r3825  
    9090        // try a different size MAX_TRIES times
    9191      }
    92       throw new ArgumentException("Couldn't create a valid tree with the specified constraints.");
     92      throw new ArgumentException("Couldn't create a random valid tree.");
    9393    }
    9494
     
    234234      var symbolList = symbols.ToList();
    235235      var ticketsSum = symbolList.Select(x => x.InitialFrequency).Sum();
     236      if (ticketsSum == 0.0) throw new ArgumentException("The initial frequency of all allowed symbols is zero.");
    236237      var r = random.NextDouble() * ticketsSum;
    237238      double aggregatedTickets = 0;
    238239      for (int i = 0; i < symbolList.Count; i++) {
    239240        aggregatedTickets += symbolList[i].InitialFrequency;
    240         if (aggregatedTickets >= r) {
     241        if (aggregatedTickets > r) {
    241242          return symbolList[i];
    242243        }
    243244      }
    244245      // this should never happen
    245       throw new ArgumentException();
     246      throw new ArgumentException("There is a problem with the initial frequency setting of allowed symbols.");
    246247    }
    247248
Note: See TracChangeset for help on using the changeset viewer.