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

Updated majority-based voting

parent 173e49b1
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<distributionManagement> <distributionManagement>
<repository> <repository>
<id>kom-deploy</id> <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> </repository>
</distributionManagement> </distributionManagement>
...@@ -372,8 +372,8 @@ ...@@ -372,8 +372,8 @@
<dependency> <dependency>
<groupId>maki</groupId> <groupId>maki</groupId>
<artifactId>simonstrator-traci</artifactId> <artifactId>simonstrator-traci</artifactId>
<version>0.1-SNAPSHOT</version> <version>0.2-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -25,6 +25,7 @@ import java.util.List; ...@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; 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.transition.TransferState;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.AbstractCacheDecisionStrategy; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.AbstractCacheDecisionStrategy;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheDecisionStrategy; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheDecisionStrategy;
...@@ -46,11 +47,15 @@ public class MajorityVotingCacheDecisionStrategy extends AbstractCacheDecisionSt ...@@ -46,11 +47,15 @@ public class MajorityVotingCacheDecisionStrategy extends AbstractCacheDecisionSt
List<T> pSimilarPointInformation) { List<T> pSimilarPointInformation) {
Map<Object, Integer> voting = new HashMap<>(); Map<Object, Integer> voting = new HashMap<>();
for (T t : pSimilarPointInformation) { for (T t : pSimilarPointInformation) {
if (!voting.containsKey(t.getValue())) { Object value = t.getValue();
voting.put(t.getValue(), 0); 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; Entry<Object, Integer> maxEntry = null;
...@@ -69,7 +74,7 @@ public class MajorityVotingCacheDecisionStrategy extends AbstractCacheDecisionSt ...@@ -69,7 +74,7 @@ public class MajorityVotingCacheDecisionStrategy extends AbstractCacheDecisionSt
for (T t : pSimilarPointInformation) { for (T t : pSimilarPointInformation) {
long timestamp = t.getDetectionDate(); 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; maxTimestamp = timestamp;
maxFitting = t; 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