public double getFlowPerLane(double time) { if (flowFunction == null) { return CONSTANT_FLOW_PER_LANE; } return flowFunction.value(time); }
/** * calculates uniform distribution with mean=0 and variance=1. * * @return random variable realization */ private static double getUniformlyDistributedRealization() { final double randomVar = MyRandom.nextDouble(); final double randomMu0Sigma1 = SQRT12 * (randomVar - 0.5); return randomMu0Sigma1; }
public static double getUniformlyDistributedRandomizedFactor(double randomizationStrength) { return 1 + randomizationStrength * getUniformDistribution(); }
public static double calcEMA(double time, List<XYDataPoint> timeSeries, double tau) { if (timeSeries.isEmpty()) { return 0; } double norm = 0; double result = 0; for (final XYDataPoint dp : timeSeries) { final double phi = weight(time, dp.getX(), tau); norm += phi; result += phi * dp.getY(); } return result / norm; }
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 static double convertToSeconds(String time, String timeFormat) { return convertToSeconds(time, timeFormat, 0L); }
public static void deleteFileList(String path, String regex) { final String[] files = getFileList(path + File.separator, regex); for (int i = 0; i < files.length; i++) { if (LOG.isDebugEnabled()) { LOG.debug("filename to delete = " + files[i]); } deleteFile(files[i], "deleteFileList with regexExpression = " + regex); } }
@Override public int getVEqCount() { return vEqFunction.getNumberOfDataPoints(); }
public static InputSource getInputSourceFromFilename(String filename) { final File inputFile = new File(filename); return getInputSourceFromFilename(inputFile); }
public static int randomColor() { int r = (int) (Math.random() * 256); int g = (int) (Math.random() * 256); int b = (int) (Math.random() * 256); return color(r, g, b); }
private static boolean deleteDir(File dir) { if (dir.isDirectory()) { final String[] children = dir.list(); for (int i = 0; i < children.length; i++) { final boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; } } } return dir.delete(); }
FileFloatingCars() { super(ProjectMetaData.getInstance().getOutputPath(), ProjectMetaData.getInstance().getProjectName()); String regex = baseFilename + EXTENSION_REGEX; FileUtils.deleteFileList(path, regex); }
/** * calculates uniform distribution with mean=0 and variance=1. * * @return random variable realization */ private static double getUniformlyDistributedRealization() { final double randomVar = MyRandom.nextDouble(); final double randomMu0Sigma1 = SQRT12 * (randomVar - 0.5); return randomMu0Sigma1; }
public double getSpeed(double time) { if (flowFunction == null) { return CONSTANT_INIT_SPEED; } return speedFunction.value(time); }
/** * returns a realization of a uniformly distributed random variable in [-1, 1] * * @return a uniformly distributed realization in [-1, 1] */ public static double getUniformDistribution() { return 2 * MyRandom.nextDouble() - 1; }
@Override public double getVEq(double rho) { // return Tables.intp(vEqTab, Math.min(rho, rhoMax), 0, rhoMax); return vEqFunction.value(rho); }
public double rho(double x) { return rhoFct.value(x); } }
public double vInit(double x) { Preconditions .checkNotNull(speedFct, "expected usage of equilibrium speeds, check with hasUserDefinedSpeeds"); return speedFct.value(x); }
private double get_uPTa(double a) { double wm = param.getWeightMinus(); double bMax = param.getBMax(); double uPT = Math.min(bMax, Math.max(-bMax, uPTaFunction.value(a))); return (a <= -bMax) ? wm * (1 - 2 * delta) * Math.pow(a / param.getA0(), -2 * delta) : (a < bMax) ? uPT : (wm + dw) * (1 - 2 * delta) * Math.pow(a / param.getA0(), -2 * delta); }
private double get_uPTaa(double a) { double bmax = param.getBMax(); double aPT = Math.min(bmax, Math.max(-bmax, uPaaFunction.value(a))); return (a <= -bmax) ? -param.getWeightMinus() * 2 * delta * (1 - 2 * delta) * Math.pow(a / param.getA0(), -2 * delta - 1) : (a < bmax) ? aPT : -(param.getWeightMinus() + dw) * 2 * delta * (1 - 2 * delta) * Math.pow(a / param.getA0(), -2 * delta - 1); }