Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
2c04ab95
Commit
2c04ab95
authored
Sep 22, 2020
by
Tobias Meuser
Browse files
Updated majority-based voting
parent
173e49b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
2c04ab95
...
...
@@ -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>
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/MajorityVotingCacheDecisionStrategy.java
View file @
2c04ab95
...
...
@@ -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
.
getV
alue
()
,
voting
.
get
(
t
.
getV
alue
()
)
+
1
);
voting
.
put
(
v
alue
,
voting
.
get
(
v
alue
)
+
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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment