コード例 #1
0
ファイル: DBOutputWriter.java プロジェクト: relteq/sirius
  /**
   * Fills link_data_total table
   *
   * @param link
   * @param param output parameters
   * @return the stored row
   * @throws Exception
   */
  private LinkDataTotal fill_total(Link link, OutputParameters params) throws Exception {
    LinkDataTotal db_ldt = new LinkDataTotal();
    db_ldt.setLinkId(str2id(link.getId()));
    db_ldt.setNetworkId(str2id(link.myNetwork.getId()));
    db_ldt.setDataSources(db_simulation_run.getDataSources());
    db_ldt.setTs(ts.getTime());
    db_ldt.setAggregation("raw");
    db_ldt.setType("mean");
    db_ldt.setCellNumber(Integer.valueOf(0));
    // mean density, vehicles
    double density = SiriusMath.sum(link.cumulative_density[0]) / params.getNsteps();
    db_ldt.setDensity(BigDecimal.valueOf(density));

    FundamentalDiagram fd = link.currentFD(0);
    if (null != fd) {
      if (params.doExportFlows()) {
        // input flow, vehicles
        db_ldt.setInFlow(BigDecimal.valueOf(SiriusMath.sum(link.cumulative_inflow[0])));
        // output flow, vehicles
        double outflow = SiriusMath.sum(link.cumulative_outflow[0]);
        db_ldt.setOutFlow(BigDecimal.valueOf(outflow));

        // free flow speed, m/s
        BigDecimal ffspeed = fd.getFreeFlowSpeed();
        // speed, m/s
        if (density <= 0) db_ldt.setSpeed(ffspeed);
        else {
          double speed =
              outflow * link.getLength().doubleValue() / (params.getOutputPeriod() * density);
          if (null != ffspeed && speed > ffspeed.doubleValue()) db_ldt.setSpeed(ffspeed);
          else if (!Double.isNaN(speed)) db_ldt.setSpeed(BigDecimal.valueOf(speed));
        }
      }
      // free flow speed, m/s
      db_ldt.setFreeFlowSpeed(fd.getFreeFlowSpeed());
      // critical speed, m/s
      db_ldt.setCriticalSpeed(fd.getCriticalSpeed());
      // congestion wave speed, m/s
      db_ldt.setCongestionWaveSpeed(fd.getCongestionSpeed());
      // maximum flow, vehicles per second per lane
      db_ldt.setCapacity(fd.getCapacity());
      // jam density, vehicles per meter per lane
      db_ldt.setJamDensity(fd.getJamDensity());
      // capacity drop, vehicle per second per lane
      db_ldt.setCapacityDrop(fd.getCapacityDrop());
    }
    db_ldt.save();
    return db_ldt;
  }
コード例 #2
0
ファイル: DBOutputWriter.java プロジェクト: relteq/sirius
 /**
  * Fills link_data_detailed table
  *
  * @param link
  * @param params output parameters
  * @param total_speed speed for the cell as a whole, m/s
  * @throws Exception
  */
 private void fill_detailed(Link link, OutputParameters params, BigDecimal total_speed)
     throws Exception {
   for (int vt_ind = 0; vt_ind < db_vehicle_type.length; ++vt_ind) {
     LinkDataDetailed db_ldd = new LinkDataDetailed();
     db_ldd.setLinkId(str2id(link.getId()));
     db_ldd.setNetworkId(str2id(link.myNetwork.getId()));
     db_ldd.setDataSources(db_simulation_run.getDataSources());
     db_ldd.setVehicleTypes(db_vehicle_type[vt_ind]);
     db_ldd.setTs(ts.getTime());
     db_ldd.setAggregation("raw");
     db_ldd.setType("mean");
     db_ldd.setCellNumber(Integer.valueOf(0));
     // mean density, vehicles
     double density = link.cumulative_density[0][vt_ind] / params.getNsteps();
     db_ldd.setDensity(new BigDecimal(density));
     if (params.doExportFlows()) {
       // input flow, vehicles
       db_ldd.setInFlow(new BigDecimal(link.cumulative_inflow[0][vt_ind]));
       // output flow, vehicles
       double outflow = link.cumulative_outflow[0][vt_ind];
       db_ldd.setOutFlow(new BigDecimal(outflow));
       if (density <= 0) db_ldd.setSpeed(total_speed);
       else {
         // speed, m/s
         double speed =
             outflow * link.getLength().doubleValue() / (params.getOutputPeriod() * density);
         FundamentalDiagram fd = link.currentFD(0);
         // free flow speed, m/s
         BigDecimal ffspeed = null == fd ? null : fd.getFreeFlowSpeed();
         if (null != ffspeed && speed > ffspeed.doubleValue()) db_ldd.setSpeed(ffspeed);
         else if (!Double.isNaN(speed)) db_ldd.setSpeed(new BigDecimal(speed));
       }
     }
     db_ldd.save();
   }
 }