Commit 722b46a9 authored by Julian Zobel's avatar Julian Zobel
Browse files

GAUSS Distribution for waiting times instead of pure random

parent ef423c3a
......@@ -124,8 +124,8 @@ public abstract class AbstractMovementModel implements MovementModel {
double minLength, double maxLength) {
assert minLength <= maxLength;
PositionVector delta = null;
if (oldPosition.getDimensions() == 2) {
if (oldPosition.getDimensions() == 2 || (oldPosition.getDimensions() == 3 && oldPosition.getAltitude() == 0)) {
double angle = random.nextDouble() * 2 * Math.PI;
double length = random.nextDouble() * (maxLength - minLength)
+ minLength;
......
......@@ -51,9 +51,9 @@ public abstract class AbstractAttractionBasedTransitionStrategy implements ITran
private List<AttractionAssignmentListener> listeners = new LinkedList<>();
private long pauseTimeMin = 0;
protected long pauseTimeMin = 0;
private long pauseTimeMax = 0;
protected long pauseTimeMax = 0;
protected final static int EVENT_PAUSE_ENDED = 1;
......@@ -99,6 +99,8 @@ public abstract class AbstractAttractionBasedTransitionStrategy implements ITran
return (long) (rnd.nextDouble() * (pauseTimeMax-pauseTimeMin)) + pauseTimeMin;
}
public void setMinPauseTime(long minPauseTime) {
if (minPauseTime < 0) {
throw new ConfigurationException(
......
......@@ -67,16 +67,29 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
// start roaming if the AP was reached
if(roamingStates.get(comp) == roamingTransitionState.TRANSITION) {
// schedule the end of the roaming phase, which will make a new transition
Event.scheduleWithDelay(getPauseTime(), this, comp, EVENT_PAUSE_ENDED);
// schedule the end of the roaming phase, which will make a new transition
Event.scheduleWithDelay(gaussianDistributionPauseTime(pauseTimeMax-pauseTimeMin, 0.5*(pauseTimeMax-pauseTimeMin)), this, comp, EVENT_PAUSE_ENDED);
}
this.roamingStates.put(comp, roamingTransitionState.PAUSE);
// schedule roaming
Event.scheduleWithDelay(Time.SECOND * 30, this, comp, EVENT_ROAMING_PAUSE_ENDED);
Event.scheduleWithDelay(gaussianDistributionPauseTime(Time.MINUTE * 1, Time.MINUTE), this, comp, EVENT_ROAMING_PAUSE_ENDED);
}
/**
* Use a gaussian distribution for the pause time interval generation, using a mean value and a standard deviation
*
* @return
*/
private long gaussianDistributionPauseTime(double mean, double std) {
double x = rnd.nextGaussian() * std + mean;
if(x <= 0) return gaussianDistributionPauseTime(mean, std*0.9);
return (long) x;
}
private void roamAroundAttractionPoint(SimLocationActuator comp) {
if(roamingStates.get(comp) != roamingTransitionState.TRANSITION) {
AttractionPoint currentAttractionPoint = this.assignments.get(comp);
......
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