⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventgatherstat.java

📁 JAVA版的蚂蚁算法(Ant Colony Optimization Algorithms)
💻 JAVA
字号:
package dk.itu.nulx30.eventSimulation;

/**
 * This event calls either <code>addStatHeaders</code> or
 * <code>addStat</code> on its <code>EventSimulation</code>-object at the
 * specified time.
 *
 * @author Jacob Wahl Winther
 * @author Mikkel Bundgaard
 * @author Troels C. Damgaard
 * @author Federico Decara
 */
public class EventGatherStat extends Event {
  /** the simulation in which this event has occured*/
  private EventSimulation sim;

  /**
   * Class-variable that is initialized to <code>true</code>.
   * It is set to <code>false</code> when first
   * event of this type has been run with <code>doEvent()</code>.
   */
  private static boolean firstTime = true;

  /**
   * Class constructor for <code>EventEvaporation</code> which takes a time
   * and an <code>EventSimulation</code> as argument
   *
   * @param time the time when this event is about to occur
   * @param sim the simulation in which this event has occured
   */
  public EventGatherStat( double time, EventSimulation sim ) {
    super( time );
    this.sim = sim;
  }

  /**
   * This method is called from <code>EventSimulation</code> if a new simulation is
   * initialized. This is necessary as the <code>firstTime</code> variable has to
   * be reset to <code>true</code>.
   */
  public static void resetGatherStat(){
    firstTime = true;
  }

  /**
   * Execute this events method
   */
  public void doEvent() {
    // add header-strings if first doEvent-time
    if ( firstTime ) {
      sim.addStatHeaders( new String[] { "Lost packages" } );
      firstTime = false;
    }
    sim.addStat( new double[] { sim.getLostPackages() } );
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -