Commit 6daa3597 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Update for diss

parent b473db0c
......@@ -59,6 +59,11 @@ public final class Oracle {
public List<Host> getAllHosts() {
return null;
}
@Override
public Host getHostByID(long pValue) {
return null;
}
};
}
}
......@@ -94,12 +99,7 @@ public final class Oracle {
* @return
*/
public static Host getHostByID(INodeID nodeId) {
for (Host host : getAllHosts()) {
if (host.getId().equals(nodeId)) {
return host;
}
}
return null;
return getOracle().getHostByID(nodeId.value());
}
}
......@@ -43,6 +43,8 @@ public interface OracleComponent extends GlobalComponent {
*/
public List<Host> getAllHosts();
public Host getHostByID(long pValue);
/**
* Allows Overlays and Components to distinguish between real-world
* implementations and simulations - could be nifty for performance reasons
......
......@@ -25,12 +25,15 @@ import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Attribute;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
public interface CostBasedPubSubComponent extends PubSubComponent {
public interface ImpactBasedPubSubComponent extends PubSubComponent {
public Subscription createSubscription(Topic topic, Filter filter, double costs);
public Subscription createSubscription(Topic topic, Filter filter, double impact);
public Subscription createSubscription(Topic topic, Filter filter, double[] costs);
public Subscription createSubscription(Topic topic, Filter filter, double[] impact);
public Subscription createSubscription(Topic topic, Filter filter, double[] impact, double bandwidth);
public Notification createNotification(Topic topic,
List<Attribute<?>> attributes, double costs, byte[] payload);
}
......@@ -9,6 +9,10 @@ public class RoadNetworkPathComperator implements Comparator<StatisticalRoadNetw
@Override
public int compare(StatisticalRoadNetworkRoute pPath0, StatisticalRoadNetworkRoute pPath1) {
return -Double.compare(pPath0.getProbability(), pPath1.getProbability());
int compare = Integer.compare(pPath0.getPath().getRoute().size(), pPath1.getPath().getRoute().size());
if (compare == 0) {
compare = -Double.compare(pPath0.getProbability(), pPath1.getProbability());
}
return compare;
}
}
\ No newline at end of file
......@@ -41,8 +41,8 @@ public interface VehicularRelevanceCalculationComponent extends HostComponent, R
PositionRepresentation getPositionRepresentation();
/**
* This method calculates the relevance of an event for a vehicle, combining
* the temporal and the geographical relevance.
* This method calculates the relevance of an event for a vehicle, combining the
* temporal and the geographical relevance.
*
* @param pVehiclePosition
* The vehicle's position
......
......@@ -29,6 +29,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.pr
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RainProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.TrafficSignProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.VehicleProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.EnvironmentInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation;
......@@ -46,6 +47,8 @@ public class DefaultVehicularPropertyImpactEstimator implements VehicularPropert
return Math.pow(10, 3);
} else if (pProperty.equals(TrafficSignProperty.class)) {
return 10;
} else if (pProperty.equals(VehicleProperty.class)) {
return 0;
}
return 10;
}
......
......@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator.lifetime.LifetimeDistribution;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
......@@ -33,6 +34,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.pr
*/
public class EventInformationContainer {
private static Map<Class<? extends RoadProperty>, Long> durations = new HashMap<>();
private static Map<Class<? extends RoadProperty>, LifetimeDistribution> lifetimeDistribution = new HashMap<>();
private static Map<Class<? extends RoadProperty>, Double> disseminationRange = new HashMap<>();
public static void registerEventDuration(Class<? extends RoadProperty> pClass, long pDuration) {
......@@ -51,6 +53,15 @@ public class EventInformationContainer {
}
}
public static void registerEventLifetimeDistribution(Class<? extends RoadProperty> pClass,
LifetimeDistribution pLifetimeDistribution) {
if (!lifetimeDistribution.containsKey(pClass)) {
lifetimeDistribution.put(pClass, pLifetimeDistribution);
} else {
throw new AssertionError(pClass + " has already been registered!");
}
}
public static long getEventDuration(Class<? extends RoadProperty> pClass) {
if (durations.containsKey(pClass)) {
return durations.get(pClass);
......@@ -64,4 +75,11 @@ public class EventInformationContainer {
}
return Double.POSITIVE_INFINITY;
}
public static LifetimeDistribution getEventLifetimeDistribution(Class<? extends RoadProperty> pClass) {
if (lifetimeDistribution.containsKey(pClass)) {
return lifetimeDistribution.get(pClass);
}
return null;
}
}
......@@ -54,7 +54,10 @@ public class BumpProperty extends AbstractRoadProperty {
@Override
public BumpProperty clone() {
return new BumpProperty(getLocation(), getEdge(), _bump);
BumpProperty property = new BumpProperty(getLocation(), getEdge(), _bump);
property.setDuration(getDuration());
property.setDetectionDate(getDetectionDate());
return property;
}
}
......@@ -54,6 +54,9 @@ public class FogProperty extends AbstractRoadProperty {
@Override
public FogProperty clone() {
return new FogProperty(getLocation(), getEdge(), _fog);
FogProperty property = new FogProperty(getLocation(), getEdge(), _fog);
property.setDuration(getDuration());
property.setDetectionDate(getDetectionDate());
return property;
}
}
......@@ -59,7 +59,10 @@ public class HazardProperty extends AbstractRoadProperty {
@Override
public HazardProperty clone() {
return new HazardProperty(getLocation(), getEdge(), _hazard);
HazardProperty property = new HazardProperty(getLocation(), getEdge(), _hazard);
property.setDuration(getDuration());
property.setDetectionDate(getDetectionDate());
return property;
}
}
......@@ -54,6 +54,9 @@ public class RainProperty extends AbstractRoadProperty {
@Override
public RainProperty clone() {
return new RainProperty(getLocation(), getEdge(), _rain);
RainProperty property = new RainProperty(getLocation(), getEdge(), _rain);
property.setDuration(getDuration());
property.setDetectionDate(getDetectionDate());
return property;
}
}
......@@ -54,6 +54,9 @@ public class TrafficSignProperty extends AbstractRoadProperty {
@Override
public TrafficSignProperty clone() {
return new TrafficSignProperty(getLocation(), getEdge(), _sign);
TrafficSignProperty property = new TrafficSignProperty(getLocation(), getEdge(), _sign);
property.setDuration(getDuration());
property.setDetectionDate(getDetectionDate());
return property;
}
}
......@@ -82,6 +82,7 @@ public class VectoralJamProperty extends NumericVectoralProperty {
VectoralJamProperty vectoralJamProperty = new VectoralJamProperty(getLocation(), getEdge());
vectoralJamProperty.setProbabilities(Arrays.copyOf(getValueProbabilities(), getValueProbabilities().length));
vectoralJamProperty.setDetectionDate(getDetectionDate());
vectoralJamProperty.setDuration(getDuration());
return vectoralJamProperty;
}
......
......@@ -64,7 +64,10 @@ public class RoadConditionProperty extends AbstractRoadProperty {
@Override
public RoadConditionProperty clone() {
return new RoadConditionProperty(getLocation(), getEdge(), _roadCondition);
RoadConditionProperty property = new RoadConditionProperty(getLocation(), getEdge(), _roadCondition);
property.setDuration(getDuration());
property.setDetectionDate(getDetectionDate());
return property;
}
}
......@@ -71,6 +71,7 @@ public class VectoralRoadConditionProperty extends VectoralProperty {
VectoralRoadConditionProperty vectoralJamProperty = new VectoralRoadConditionProperty(getLocation(), getEdge());
vectoralJamProperty.setProbabilities(Arrays.copyOf(getValueProbabilities(), getValueProbabilities().length));
vectoralJamProperty.setDetectionDate(getDetectionDate());
vectoralJamProperty.setDuration(getDuration());
return vectoralJamProperty;
}
......
......@@ -56,4 +56,9 @@ public class DeterministicExponentialLifetimeDistribution implements LifetimeDis
public long getAverageLifetime() {
return _averageEventDuration;
}
@Override
public double getProbabilityForLifetime(long pLifetime) {
return Math.pow(_existProbability, pLifetime / Time.SECOND);
}
}
......@@ -57,4 +57,9 @@ public class ExponentialLifetimeDistribution implements LifetimeDistribution {
public long getAverageLifetime() {
return _averageEventDuration;
}
@Override
public double getProbabilityForLifetime(long pLifetime) {
return Math.pow(_existProbability, pLifetime / _granularity);
}
}
......@@ -22,6 +22,8 @@ package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.genera
import java.util.Random;
import org.apache.commons.math3.special.Erf;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
......@@ -49,4 +51,14 @@ public class GaussianLifetimeDistribution implements LifetimeDistribution {
public long getAverageLifetime() {
return _averageEventDuration;
}
@Override
public double getProbabilityForLifetime(long pLifetime) {
double average = _averageEventDuration / (double) Time.SECOND;
double standardDeviation = _standardDeviationEventDuration / (double) Time.SECOND;
double age = pLifetime / (double) Time.SECOND;
double parameter = (average - age) / (Math.sqrt(2) * standardDeviation);
return 1 - 0.5 * Erf.erfc(parameter);
}
}
......@@ -24,4 +24,6 @@ public interface LifetimeDistribution {
long getLifetime();
long getAverageLifetime();
double getProbabilityForLifetime(long pLifetime);
}
......@@ -30,7 +30,8 @@ public enum AvailableInformationAttributes {
"edge", RoadNetworkEdge.class), TTL(
"ttl", Long.class), EXPECTED_DURATION(
"duration", Long.class), STANDARD_DEVIATION_DURATION(
"sd_duration"), TYPE("type", SiSType.class), COST("cost", Double.class);
"sd_duration"), TYPE("type", SiSType.class), COST("cost",
Double.class), FORWARDER("forwarder", INodeID.class);
private final String attributeID;
private final Class<? extends Object> clazz;
......
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