Commit 6de41a46 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Updated road properties

parent dedd4810
...@@ -54,7 +54,7 @@ public class DefaultVehicularPropertyCostEstimator implements VehicularPropertyC ...@@ -54,7 +54,7 @@ public class DefaultVehicularPropertyCostEstimator implements VehicularPropertyC
@Override @Override
public double calculateCostsIfKnown(Class<? extends RoadProperty> pProperty) { public double calculateCostsIfKnown(Class<? extends RoadProperty> pProperty) {
if (pProperty.equals(JamProperty.class)) { if (pProperty.equals(JamProperty.class)) {
return 5 * Math.pow(10, 2); return 3 * Math.pow(10, 2);
} else if (pProperty.equals(RainProperty.class)) { } else if (pProperty.equals(RainProperty.class)) {
return 1; return 1;
} else if (pProperty.equals(FogProperty.class)) { } else if (pProperty.equals(FogProperty.class)) {
......
...@@ -32,26 +32,25 @@ public class ExponentialLifetimeDistribution implements LifetimeDistribution { ...@@ -32,26 +32,25 @@ public class ExponentialLifetimeDistribution implements LifetimeDistribution {
private long _averageEventDuration; private long _averageEventDuration;
private double _existProbability; private double _existProbability;
private long _granularity = 10 * Time.SECOND;
@XMLConfigurableConstructor({ "duration" }) @XMLConfigurableConstructor({ "duration" })
public ExponentialLifetimeDistribution(long pEventDuration) { public ExponentialLifetimeDistribution(long pEventDuration) {
_averageEventDuration = pEventDuration; _averageEventDuration = pEventDuration;
_existProbability = 1 - 1 / (double) (pEventDuration / Time.SECOND); _existProbability = 1 - 1 / (double) (pEventDuration / _granularity);
} }
@Override @Override
public long getLifetime() { public long getLifetime() {
long delay = 0; double random = eventDurationRandom.nextDouble();
while (true) {
double random = eventDurationRandom.nextDouble(); long theoreticLifetime = (long) Math.ceil(Math.log(random) / Math.log(_existProbability));
if (random > _existProbability) { long lifetime = Math.max(theoreticLifetime * _granularity, _granularity * 2);
break; System.out.println("Random lifetime: " + random + " with duration: "
} else { + theoreticLifetime * _granularity + " (final: " + lifetime + ")");
delay += Time.SECOND;
} return lifetime;
}
return delay;
} }
@Override @Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment