private void generateTimeSeriesData(List<Inflow> inflow) { final int size = inflow.size(); double[] timeValues = new double[size]; double[] flowValues = new double[size]; double[] speedValues = new double[size]; for (int i = 0; i < size; i++) { final Inflow dataPoint = inflow.get(i); timeValues[i] = dataPoint.getT(); // convert flow per lane per hour in 1/s flowValues[i] = dataPoint.getQPerHour() * Units.INVH_TO_INVS; speedValues[i] = dataPoint.getV(); // in m/s LOG.debug("add data: flow={}, speed={}", flowValues[i], speedValues[i]); } flowFunction = new LinearInterpolatedFunction(timeValues, flowValues); speedFunction = new LinearInterpolatedFunction(timeValues, speedValues); }
private void interpolateGridData(TreeSet<SpatialTemporal> dataPoints) { final int size = dataPoints.size(); final double[] xMicro = new double[size]; final double[] vMicro = new double[size]; final double[] aMicro = new double[size]; int j = 0; for (SpatialTemporal dp : dataPoints) { LOG.debug("data point for interpolation={}", dp); vMicro[j] = dp.speed; xMicro[j] = dp.position; aMicro[j] = dp.acceleration; ++j; } LinearInterpolatedFunction speeds = new LinearInterpolatedFunction(xMicro, vMicro); LinearInterpolatedFunction accelerations = new LinearInterpolatedFunction(xMicro, aMicro); for (int i = 0; i < macroSpeed.length; ++i) { final double x = i * dxOutput; macroSpeed[i] = speeds.value(x); macroAcceleration[i] = accelerations.value(x); } }
private LinearInterpolatedFunction createSpeedProfile(List<SpeedDataType> speedData) { int size = speedData.size(); double[] times = new double[size]; double[] speeds = new double[size]; for (int i = 0; i < size; i++) { SpeedDataType dataPoint = speedData.get(i); times[i] = TimeUtilities.convertToSeconds(dataPoint.getTime(), timeFormat); speeds[i] = dataPoint.getSpeed(); } return new LinearInterpolatedFunction(times, speeds); }
public EquilibriumPropertiesImpl(double vehicleLength, LongitudinalModelBase model) { this.rhoMax = 1.0 / Math.max(vehicleLength, TINY_VALUE); if (vehicleLength < TINY_VALUE) { LOG.warn("vehicle length is artificially small={}, assume finite length {}", vehicleLength, TINY_VALUE); } if (model.hasDesiredSpeed()) { vEqFunction = calcEquilibriumSpeedFunction(model); calcRhoQMax(); } else { double[] xDummy = new double[]{0}; vEqFunction = new LinearInterpolatedFunction(xDummy, xDummy); } }
private void createFunctions(List<MacroConditionType> macroConditions) { final int size = macroConditions.size(); double[] positions = new double[size]; double[] densities = new double[size]; double[] speeds = new double[size]; for (int i = 0; i < size; i++) { MacroConditionType localMacroIC = macroConditions.get(i); final double rhoLocal = localMacroIC.getDensityPerKm() * Units.INVKM_TO_INVM; if (rhoLocal > MovsimConstants.SMALL_VALUE) { positions[i] = localMacroIC.getPosition(); densities[i] = rhoLocal; if (useUserDefinedSpeeds(macroConditions)) { speeds[i] = Math.min(localMacroIC.getSpeed(), MovsimConstants.MAX_VEHICLE_SPEED); LOG.debug("speed={}", speeds[i]); } } } rhoFct = new LinearInterpolatedFunction(positions, densities); if (useUserDefinedSpeeds(macroConditions)) { speedFct = new LinearInterpolatedFunction(positions, speeds); } }
private void initTables() { double[] uPTatab = new double[NTABMAX]; // tabulated d(U_PT)/da double[] uPTaatab = new double[NTABMAX]; // tabulated d^2(U_PT)/da^2 double[] acc = new double[NTABMAX]; // in File Constructor: Initialize Tables of d(U_PT)/da and d^2(U_PT)/da^2 for (int i = 0; i < NTABMAX; i++) { final double a = param.getBMax() * (-1 + 2 * i / ((double) (NTABMAX - 1))); double x = a / param.getA0(); double lorenz = 1 / (1 + x * x); double g = x * Math.pow(lorenz, delta); double gx = Math.pow(lorenz, delta) - 2 * delta * x * x * Math.pow(lorenz, delta + 1); double gxx = -6 * delta * x * Math.pow(lorenz, delta + 1) + 4 * delta * (delta + 1) * Math.pow(x, 3) * Math.pow(lorenz, delta + 2); double prefactor = param.getWeightMinus() + 0.5 * dw * (1 + Math.tanh(x)); double cosh2 = Math.pow(Math.cosh(x), 2); acc[i] = a; uPTatab[i] = 1 / param.getA0() * (prefactor * gx + 0.5 * dw * g / cosh2); uPTaatab[i] = 1 / (param.getA0() * param.getA0()) * (prefactor * gxx + dw / cosh2 * (gx - Math.tanh(x) * g)); } this.uPTaFunction = new LinearInterpolatedFunction(acc, uPTatab); this.uPaaFunction = new LinearInterpolatedFunction(acc, uPTaatab); }
return new LinearInterpolatedFunction(rhoTab, vEqTab);