Example #1
0
 /** Runs the experiment to steady state, but no further. */
 public void runToSteadyState() {
   Iterator<Statistic> stats = this.getStats().getAllStats();
   while (stats.hasNext()) {
     Statistic stat = stats.next();
     stat.setJustBins(true);
   }
   this.stopAtSteadyState = true;
   this.run();
 }
Example #2
0
  /** Runs the experiment. The builk of simulation happens in this. */
  public void run() {
    this.initialize();
    long startTime = System.currentTimeMillis();

    this.nEventsProccessed = 0;
    Sim.printBanner();
    System.out.println("Starting simulation");
    // TODO fix magic numbers
    int orderOfMag = 5;
    long printSamples = (long) Math.pow(10, orderOfMag);
    while (!stop) {
      Event currentEvent = this.eventQueue.nextEvent();
      this.currentTime = currentEvent.getTime();
      currentEvent.process();
      this.nEventsProccessed++;
      if (this.nEventsProccessed > printSamples) {
        System.out.println("Processed " + this.nEventsProccessed + " events");
        Iterator<Statistic> statIter = this.exprimentOutput.getStats().getAllStats();
        while (statIter.hasNext()) {
          Statistic currentStat = statIter.next();
          if (!currentStat.isConverged()) {
            System.out.println(
                "Still waiting for "
                    + currentStat.getStatName()
                    + " at mean converge of "
                    + currentStat.getMeanAccuracy()
                    + " and quantile converge of "
                    + currentStat.getQuantileAccuracy());
            currentStat.printStatInfo();
          }
        }
        orderOfMag++;
        printSamples = (long) Math.pow(10, orderOfMag);
      }

      if (this.getStats().allStatsConverged()) {
        System.out.println("Ending from convergence");
        break;
      }

      if (this.getStats().allStatsSteadyState() && this.stopAtSteadyState) {
        System.out.println("Halting at steady state");
        break;
      }

      if (eventLimit > 0 && nEventsProccessed > eventLimit) {
        break;
      }
    }

    long endTime = System.currentTimeMillis();
    double execTime = (endTime - startTime) / 1000.0;
    System.out.println("The experiment took " + execTime + " seconds to run");
  }