private int getNextEvent()

in samoa-api/src/main/java/org/apache/samoa/streams/clustering/RandomRBFGeneratorEvents.java [635:674]


  private int getNextEvent() {
    int choice = -1;
    boolean lowerLimit = numActiveKernels <= numClusterOption.getValue() - numClusterRangeOption.getValue();
    boolean upperLimit = numActiveKernels >= numClusterOption.getValue() + numClusterRangeOption.getValue();

    if (!lowerLimit || !upperLimit) {
      int mode = -1;
      if (eventDeleteCreateOption.isSet() && eventMergeSplitOption.isSet()) {
        mode = instanceRandom.nextInt(2);
      }

      if (mode == 0 || (mode == -1 && eventMergeSplitOption.isSet())) {
        // have we reached a limit? if not free choice
        if (!lowerLimit && !upperLimit)
          choice = instanceRandom.nextInt(2);
        else
        // we have a limit. if lower limit, choose split
        if (lowerLimit)
          choice = 1;
        // otherwise we reached upper level, choose merge
        else
          choice = 0;
      }

      if (mode == 1 || (mode == -1 && eventDeleteCreateOption.isSet())) {
        // have we reached a limit? if not free choice
        if (!lowerLimit && !upperLimit)
          choice = instanceRandom.nextInt(2) + 2;
        else
        // we have a limit. if lower limit, choose create
        if (lowerLimit)
          choice = 3;
        // otherwise we reached upper level, choose delete
        else
          choice = 2;
      }
    }

    return choice;
  }