Commit 2c04ab95 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Updated majority-based voting

parent 173e49b1
......@@ -12,7 +12,7 @@
<distributionManagement>
<repository>
<id>kom-deploy</id>
<url>scp://dev.kom.e-technik.tu-darmstadt.de/srv/www/dev/htdocs/mvn</url>
<url>scp://dev.kom.e-technik.tu-darmstadt.de/mvn</url>
</repository>
</distributionManagement>
......@@ -372,8 +372,8 @@
<dependency>
<groupId>maki</groupId>
<artifactId>simonstrator-traci</artifactId>
<version>0.1-SNAPSHOT</version>
<version>0.2-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
......@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.vectoral.VectoralProperty;
import de.tudarmstadt.maki.simonstrator.api.component.transition.TransferState;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.AbstractCacheDecisionStrategy;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheDecisionStrategy;
......@@ -46,11 +47,15 @@ public class MajorityVotingCacheDecisionStrategy extends AbstractCacheDecisionSt
List<T> pSimilarPointInformation) {
Map<Object, Integer> voting = new HashMap<>();
for (T t : pSimilarPointInformation) {
if (!voting.containsKey(t.getValue())) {
voting.put(t.getValue(), 0);
Object value = t.getValue();
if (value instanceof VectoralProperty) {
value = ((VectoralProperty) value).getMostProbableValue();
}
if (!voting.containsKey(value)) {
voting.put(value, 0);
}
voting.put(t.getValue(), voting.get(t.getValue()) + 1);
voting.put(value, voting.get(value) + 1);
}
Entry<Object, Integer> maxEntry = null;
......@@ -69,7 +74,7 @@ public class MajorityVotingCacheDecisionStrategy extends AbstractCacheDecisionSt
for (T t : pSimilarPointInformation) {
long timestamp = t.getDetectionDate();
if (t.getValue().equals(maxEntry.getKey()) && timestamp > maxTimestamp) {
if ((t.getValue().equals(maxEntry.getKey()) || t.getValue() instanceof VectoralProperty && ((VectoralProperty)t.getValue()).getMostProbableValue().equals(maxEntry.getKey())) && timestamp > maxTimestamp) {
maxTimestamp = timestamp;
maxFitting = t;
}
......
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