Commit 05a2918a authored by Julian Zobel's avatar Julian Zobel 🦄
Browse files

Bugfix for mobility model speed distribution.

Assert the (minimum) speed value is always equal or larger than zero.
Correct boundary setting for gaussian distribution.
parent 466058c1
......@@ -47,8 +47,9 @@ public class GaussianSpeedDistribution implements ISpeedDistributionProvider {
@Override
public double calculateSpeed() {
double speed = random.nextGaussian() * std + mean;
Math.min(speed, max);
Math.max(speed, min);
speed = Math.min(speed, max);
speed = Math.max(speed, min);
return speed;
}
......@@ -61,6 +62,7 @@ public class GaussianSpeedDistribution implements ISpeedDistributionProvider {
}
public void setMin(double min) {
assert min >= 0;
this.min = min;
}
......
......@@ -46,6 +46,7 @@ public class StaticSpeedDistribution implements ISpeedDistributionProvider {
}
public void setValue(double value) {
assert value >= 0;
this.value = value;
}
......
......@@ -28,7 +28,7 @@ public class UniformSpeedDistribution implements ISpeedDistributionProvider {
private Random random = Randoms.getRandom(UniformSpeedDistribution.class);
private double min;
private double min = 0;
private double max;
private boolean includeUpperBound = false;
......@@ -45,10 +45,11 @@ public class UniformSpeedDistribution implements ISpeedDistributionProvider {
@Override
public double calculateSpeed() {
return min + random.nextDouble() * (max - min + (includeUpperBound ? Double.MIN_VALUE : 0));
return Math.max(min, min + random.nextDouble() * (max - min + (includeUpperBound ? Double.MIN_VALUE : 0)));
}
public void setMin(double min) {
assert min >= 0;
this.min = min;
}
......
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