Example #1
0
 /** Reads fundamental diagram parameters from AIMSUN generated xml */
 public void readFundamentalDiagramsFromXML_AIMSUN() {
   for (int key : detectors.keySet()) {
     Detector d = detectors.get(key);
     // find the corresponding FD profile
     int i;
     for (i = 0;
         i
             < this.mainScenario
                 .getFundamentalDiagramProfileSet()
                 .getFundamentalDiagramProfile()
                 .size();
         i++) {
       if (Integer.parseInt(
               this.mainScenario
                   .getFundamentalDiagramProfileSet()
                   .getFundamentalDiagramProfile()
                   .get(i)
                   .getLinkId())
           == d.getLinkAssoc()) {
         break;
       }
     }
     BigDecimal vf =
         this.mainScenario
             .getFundamentalDiagramProfileSet()
             .getFundamentalDiagramProfile()
             .get(i)
             .getFundamentalDiagram()
             .get(0)
             .getFreeFlowSpeed();
     BigDecimal q_max =
         this.mainScenario
             .getFundamentalDiagramProfileSet()
             .getFundamentalDiagramProfile()
             .get(i)
             .getFundamentalDiagram()
             .get(0)
             .getCapacity();
     BigDecimal rhojam =
         this.mainScenario
             .getFundamentalDiagramProfileSet()
             .getFundamentalDiagramProfile()
             .get(i)
             .getFundamentalDiagram()
             .get(0)
             .getJamDensity();
     double w =
         q_max.doubleValue() / (rhojam.doubleValue() - q_max.doubleValue() / vf.doubleValue());
     d.getFdParams().setFD(vf.doubleValue(), w, q_max.doubleValue() / d.getNumberOfLanes());
     detectors.put(key, d);
   }
 }
Example #2
0
 /** Reads the SensorList from mainScenario and populates the detectors hashmap */
 public void createDetectorListFromMainScenario() {
   String sensorIDString;
   for (int i = 0; i < this.mainScenario.getSensorList().getSensor().size(); i++) {
     Detector d = new Detector();
     sensorIDString =
         this.mainScenario
             .getSensorList()
             .getSensor()
             .get(i)
             .getParameters()
             .getParameter()
             .get(7)
             .getValue();
     d.setSensorID(Integer.parseInt(sensorIDString));
     d.setSensorType(this.mainScenario.getSensorList().getSensor().get(i).getType());
     d.setSourceAddress("n/a");
     d.setLinkAssoc(
         Integer.parseInt(
             this.mainScenario.getSensorList().getSensor().get(i).getLinkReference().getId()));
     detectors.put(d.getSensorID(), d);
   }
 }
Example #3
0
  /**
   * Reads the detector data from spreadsheet and writes into detectors hashmap The files should be
   * in the following format and placed in the root directory of the imputer project folder (for
   * example, see detOutMainlines_431.csv) 1) 5 minute data granularity is assumed 2) The data
   * should be sorted by alphabetical order of detector IDs and the data column should be
   * chronologically sorted for each detector
   *
   * @throws IOException
   * @throws BiffException
   */
  public void readDataIntoDetectorListFromSpreadSheet(String filename)
      throws BiffException, IOException {

    Workbook workbook = Workbook.getWorkbook(new File(filename));

    int rowIndex =
        1; // start the index at 1 and increase by number of data points after each iteration
    // Read absolute detector info and 5 minute data into the hashmap (some fields not important for
    // fake detectors, left blank or 0 for the time being)
    for (int key : detectors.keySet()) {
      Detector d = detectors.get(key);
      // find row index
      while (true) {
        NumberCell nc2 = (NumberCell) workbook.getSheet(0).getCell(0, rowIndex);
        if (nc2.getValue() == key) {
          break;
        }
        rowIndex++;
      }
      NumberCell nc = (NumberCell) workbook.getSheet(0).getCell(4, rowIndex); // Postmile
      d.setAbsolutePM(nc.getValue());
      d.setDetectorLength(0.0);
      d.setDetectorName(workbook.getSheet(0).getCell(1, rowIndex).getContents()); // Name
      d.setFreewayDirection("");
      d.setFreewayNumber(0);
      d.setLatitude(0.0);
      d.setLongitude(0.0);
      NumberCell nc1 = (NumberCell) workbook.getSheet(0).getCell(13, rowIndex); // Number of Lanes
      Double temp = nc1.getValue();
      d.setNumberOfLanes(temp.intValue());
      for (int k = rowIndex; k < rowIndex + totalTimeInHours * 60 / 5; k++) {
        NumberCell ncSpeed = (NumberCell) workbook.getSheet(0).getCell(6, k); // Speed
        NumberCell ncFlow = (NumberCell) workbook.getSheet(0).getCell(5, k); // Flow
        d.addDatumToSpeed(ncSpeed.getValue());
        d.addDatumToFlow(ncFlow.getValue() / d.getNumberOfLanes());
        d.addDatumToDensity(ncFlow.getValue() / ncSpeed.getValue() / d.getNumberOfLanes());
      }
      nc = (NumberCell) workbook.getSheet(0).getCell(14, rowIndex); // Health
      if (nc.getValue() == 0) {
        d.setHealthStatus(100.0);
      } else {
        d.setHealthStatus(0.0);
      }
      rowIndex = 1;
      // rowIndex += totalTimeInHours*60/5;
    }
  }
Example #4
0
  /**
   * Reads the data from database and writes into detectors hashmap
   *
   * @throws SQLException
   */
  public void readDataIntoDetectorListFromDatabase() throws SQLException {

    // TestConfiguration.dbSetup();

    PeMSStationAggregateReader stationAggregateReader =
        new PeMSStationAggregateReader(oraDatabase.doConnect());
    ArrayList<Long> vdsIDs = new ArrayList<Long>();

    for (int key : detectors.keySet()) {
      vdsIDs.add((long) key);
    }
    List<PeMSStationAggregate> stationsAggregate =
        stationAggregateReader.read(
            this.timeInterval, vdsIDs, PeMSAggregate.AggregationLevel.PEMS_5MIN);

    // Read absolute detector info into the hashmap
    VDSReader stationReader = new VDSReader(oraDatabase.doConnect());
    for (int key : detectors.keySet()) {
      VDS station = stationReader.read((long) key);
      Detector d = detectors.get(key);
      d.setAbsolutePM(station.getAbsolutePostmile());
      d.setDetectorLength(station.getDetectorLength());
      d.setDetectorName(station.getDetectorName());
      d.setFreewayDirection(station.getDirection());
      d.setFreewayNumber(station.getFreewayNum());
      d.setLatitude(station.getPosition().getPoint().get(0).getLat());
      d.setLongitude(station.getPosition().getPoint().get(0).getLng());
      d.setNumberOfLanes(station.getLaneCount());
    }

    // Read 5 minute data into the hashmap
    for (int i = 0; i < stationsAggregate.size(); i++) {
      // find the detector corresponding to the current ID in the data vector and fill the fields
      // accordingly
      Detector d = detectors.get((int) stationsAggregate.get(i).getVdsId());
      d.addDatumToSpeed(stationsAggregate.get(i).getTotal().getAvgSpeed());
      d.addDatumToFlow(
          stationsAggregate.get(i).getTotal().getFlow()
              * 12
              / d
                  .getNumberOfLanes()); // to get the hourly rate at 5 minute granularity, multiply
                                        // by 12
      d.addDatumToDensity(
          stationsAggregate.get(i).getTotal().getFlow()
              * 12
              / stationsAggregate.get(i).getTotal().getAvgSpeed()
              / d.getNumberOfLanes());
      if (i < detectors.size()) {
        d.setHealthStatus(stationsAggregate.get(i).getTotal().getObserved());
      }
    }
  }