DataPointRT point = Common.runtimeManager.getDataPoint(vo.getAttractionPointId());
if (point == null) {
if (log.isDebugEnabled())
log.debug("Attraction point is not enabled");
// Point is not currently active.
return new NumericValue(current);
}
DataValue attractorValue = PointValueTime.getValue(point.getPointValue());
if (attractorValue == null) {
if (log.isDebugEnabled())
log.debug("Attraction point has not vaue");
return new NumericValue(current);
}
double attraction = attractorValue.getDoubleValue();
// Move half the distance toward the attractor...
double change = (attraction - current) / 2;
// ... subject to the maximum change allowed...
if (change < 0 && -change > vo.getMaxChange())
change = -vo.getMaxChange();
else if (change > vo.getMaxChange())
change = vo.getMaxChange();
// ... and a random fluctuation.
change += RANDOM.nextDouble() * vo.getVolatility() * 2 - vo.getVolatility();
if (log.isDebugEnabled())
log.debug("attraction=" + attraction + ", change=" + change);
return new NumericValue(current + change);
}