Commit 6fa4ac8b authored by Clemens Krug's avatar Clemens Krug
Browse files

BUGFIXES

~ HotspotDistribution would lead to massive (more as intended) clustering over simulation time.
~ SearchDistanceThreshold did not increase.
parent 1c228f2f
......@@ -137,12 +137,21 @@ public class ModularMultiTypeMovementModel extends ModularMovementModel
}
/**
* Sets the {@link ITransitionStrategy} for the specified {@link SimLocationActuator}. Used strategies
* need to be registered in the config.
* @param ms The SimLocationActuator
* @param strategy the strategy to use
* Return the currently used transitions strategy of the specified component
* @param ms the component
* @return the current transition strategy
*/
public void setTransitionForComponent(SimLocationActuator ms, Class strategy)
public ITransitionStrategy getTransitionForComponent(SimLocationActuator ms)
{
return transitions.get(ms);
}
/**
* Gets one of the supported transition strategies.
* @param strategy The class of the strategy which should be returned.
* @return The specified strategy
*/
public ITransitionStrategy getTransitionStrategy(Class strategy)
{
ITransitionStrategy selectedStrategy = supportedTransitions.get(strategy);
if(selectedStrategy == null)
......@@ -150,8 +159,19 @@ public class ModularMultiTypeMovementModel extends ModularMovementModel
throw new UnsupportedOperationException(
String.format("ModularMultiTypeMovementModel: TransitionStrategy %s ist not supported!", strategy.toString()));
}
changeTransitionStrategy(ms, selectedStrategy);
return selectedStrategy;
}
/**
* Sets the {@link ITransitionStrategy} for the specified {@link SimLocationActuator}. Used strategies
* need to be registered in the config.
* @param ms The SimLocationActuator
* @param strategy the strategy to use
*/
public void setTransitionForComponent(SimLocationActuator ms, Class strategy)
{
changeTransitionStrategy(ms, getTransitionStrategy(strategy));
}
/**
......
......@@ -36,6 +36,7 @@ public class RandomInAreaTransitionStrategy implements ITransitionStrategy
* These are the current spots inside the target area where the client is currently heading.
*/
private Map<SimLocationActuator, AttractionPoint> currentTarget = new HashMap<>();
private Map<SimLocationActuator, Integer> currentSearchRadius = new HashMap<>();
private List<AttractionAssignmentListener> listeners = new LinkedList<>();
......@@ -85,23 +86,29 @@ public class RandomInAreaTransitionStrategy implements ITransitionStrategy
AttractionPoint aPoint = aPoints.iterator().next();
assignments.put(ms, aPoint);
currentTarget.put(ms, nextRandomPosition(aPoint, defaultRadius));
currentSearchRadius.put(ms, defaultRadius);
}
listeners.forEach(listener -> listener.updatedAttractionAssignment(ms, currentTarget.get(ms)));
}
@Override
public void reachedAttractionPoint(SimLocationActuator ms) {
currentTarget.put(ms, nextRandomPosition(assignments.get(ms), defaultRadius));
currentTarget.put(ms, nextRandomPosition(assignments.get(ms), currentSearchRadius.get(ms)));
listeners.forEach(listener -> listener.updatedAttractionAssignment(ms, currentTarget.get(ms)));
}
@Override
public void updateTargetAttractionPoint(SimLocationActuator comp, AttractionPoint attractionPoint) {
assignments.put(comp, attractionPoint);
currentTarget.put(comp, nextRandomPosition(attractionPoint, defaultRadius));
currentTarget.put(comp, nextRandomPosition(attractionPoint, currentSearchRadius.get(comp)));
listeners.forEach(listener -> listener.updatedAttractionAssignment(comp, attractionPoint));
}
public void setSearchRadiusForComponent(SimLocationActuator ms, int radius)
{
currentSearchRadius.put(ms, radius);
}
public void setDefaultRadius(int radius)
{
this.defaultRadius = radius;
......@@ -115,7 +122,7 @@ public class RandomInAreaTransitionStrategy implements ITransitionStrategy
*/
private BasicAttractionPoint nextRandomPosition(Location center, int radius)
{
assert defaultRadius > 0 : "An area radius must be specified for the RandomInAreaTransitionStrategy! Did you set the 'DefaultRadius' property for this transition?";
assert radius > 0 : "An area radius must be specified for the RandomInAreaTransitionStrategy! Did you set the 'DefaultRadius' property for this transition?";
double x = center.getLongitude();
double y = center.getLatitude();
......
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