void saveDynamicVariables() {
   // NB: Should not be called upon a modeData without a vehicleType, as this.vehicleType will be
   // null and will throw an exception.
   this.permanentDensity =
       this.numberOfAgents
           / (InputsForFDTestSetUp.LINK_LENGTH * 3)
           * 1000
           * this.vehicleType.getPcuEquivalents();
   this.permanentAverageVelocity = this.getActualAverageVelocity();
   GenerateFundamentalDiagramData.LOG.info(
       "Calculated permanent Speed from "
           + modeId
           + "'s lastXSpeeds : "
           + speedTable
           + "\nResult is : "
           + this.permanentAverageVelocity);
   this.permanentFlow = this.getSlidingAverageOfLastXHourlyFlows();
   GenerateFundamentalDiagramData.LOG.info(
       "Calculated permanent Flow from "
           + modeId
           + "'s lastXFlows900 : "
           + lastXHourlyFlows
           + "\nResult is :"
           + this.permanentFlow);
 }
  void checkFlowStability900() {
    //		double relativeDeviances = 0.;
    //		double avgFlow = ListUtils.doubleMean(this.lastXHourlyFlows);
    //		for(int i=0;i<this.NUMBER_OF_MEMORIZED_FLOWS;i++){
    //			relativeDeviances  += Math.pow( (this.lastXHourlyFlows.get(i).doubleValue() -
    // avgFlow)/avgFlow , 2);
    //		}
    //		relativeDeviances /= this.NUMBER_OF_MEMORIZED_FLOWS;

    double absoluteDeviances =
        this.lastXHourlyFlows.get(this.lastXHourlyFlows.size() - 1) - this.lastXHourlyFlows.get(0);
    if (Math.abs(absoluteDeviances) < 1) {
      //		if(relativeDeviances < 0.05){
      this.flowStability = true;
      if (modeId == null)
        GenerateFundamentalDiagramData.LOG.info(
            "========== Reaching a certain flow stability for global flow.");
      else
        GenerateFundamentalDiagramData.LOG.info(
            "========== Reaching a certain flow stability in mode: " + modeId.toString());
    } else {
      this.flowStability = false;
    }
  }
 void checkSpeedStability() {
   double relativeDeviances = 0.;
   double averageSpeed = ListUtils.doubleMean(this.speedTable);
   for (int i = 0; i < this.speedTableSize; i++) {
     relativeDeviances +=
         Math.pow((this.speedTable.get(i).doubleValue() - averageSpeed) / averageSpeed, 2);
   }
   relativeDeviances /= this.noOfModes; // taking dependence on number of modes away
   if (relativeDeviances < 0.0005) {
     this.speedStability = true;
     GenerateFundamentalDiagramData.LOG.info(
         "========== Reaching a certain speed stability in mode: " + modeId);
   } else {
     this.speedStability = false;
   }
 }