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
@Override
public double calculateCostsIfKnown(Class<? extends RoadProperty> pProperty) {
if (pProperty.equals(JamProperty.class)) {
return 5 * Math.pow(10, 2);
return 3 * Math.pow(10, 2);
} else if (pProperty.equals(RainProperty.class)) {
return 1;
} else if (pProperty.equals(FogProperty.class)) {
......
......@@ -32,26 +32,25 @@ public class ExponentialLifetimeDistribution implements LifetimeDistribution {
private long _averageEventDuration;
private double _existProbability;
private long _granularity = 10 * Time.SECOND;
@XMLConfigurableConstructor({ "duration" })
public ExponentialLifetimeDistribution(long pEventDuration) {
_averageEventDuration = pEventDuration;
_existProbability = 1 - 1 / (double) (pEventDuration / Time.SECOND);
_existProbability = 1 - 1 / (double) (pEventDuration / _granularity);
}
@Override
public long getLifetime() {
long delay = 0;
while (true) {
double random = eventDurationRandom.nextDouble();
if (random > _existProbability) {
break;
} else {
delay += Time.SECOND;
}
}
return delay;
double random = eventDurationRandom.nextDouble();
long theoreticLifetime = (long) Math.ceil(Math.log(random) / Math.log(_existProbability));
long lifetime = Math.max(theoreticLifetime * _granularity, _granularity * 2);
System.out.println("Random lifetime: " + random + " with duration: "
+ theoreticLifetime * _granularity + " (final: " + lifetime + ")");
return lifetime;
}
@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