Exemple #1
0
  @Override
  public void recordstate(double time, boolean exportflows, int outsteps) throws SiriusException {
    success = false;
    double min = Math.floor(time / 60);
    double hrs = Math.floor(min / 60);
    ts.set(Calendar.HOUR_OF_DAY, (int) hrs);
    ts.set(Calendar.MINUTE, (int) (min - hrs * 60));
    ts.set(Calendar.SECOND, (int) (time - min * 60));
    OutputParameters params =
        new OutputParameters(
            exportflows,
            0 == scenario.clock.getCurrentstep() ? 1 : outsteps,
            scenario.getSimDtInSeconds() * outsteps);

    for (com.relteq.sirius.jaxb.Network network : scenario.getNetworkList().getNetwork()) {
      for (com.relteq.sirius.jaxb.Link link : network.getLinkList().getLink()) {
        Link _link = (Link) link;
        try {
          LinkDataTotal db_ldt = fill_total(_link, params);
          fill_detailed(_link, params, db_ldt.getSpeed());
        } catch (Exception exc) {
          throw new SiriusException(exc);
        } finally {
          _link.reset_cumulative();
        }
      }
    }
    success = true;
  }
Exemple #2
0
  /**
   * 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;
  }
Exemple #3
0
 /**
  * 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();
   }
 }