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
70f0b7c3
Commit
70f0b7c3
authored
May 18, 2018
by
Tobias Meuser
Browse files
Merge changes of Björn Büschke
parents
c911a273
58f23c9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/vehicular/caching/DefaultCachingComponent.java
View file @
70f0b7c3
...
@@ -40,7 +40,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Avai
...
@@ -40,7 +40,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Avai
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.JamInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.JamInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
...
@@ -58,6 +57,8 @@ implements CachingComponent, ConnectivityListener {
...
@@ -58,6 +57,8 @@ implements CachingComponent, ConnectivityListener {
private
CacheDecisionStrategy
_decisionStrategy
;
private
CacheDecisionStrategy
_decisionStrategy
;
private
int
_minObservations
=
0
;
private
double
[]
informationRatios
=
new
double
[]
{
1
,
0.75
,
0.5
,
0.25
,
0
};
private
double
[]
informationRatios
=
new
double
[]
{
1
,
0.75
,
0.5
,
0.25
,
0
};
public
DefaultCachingComponent
(
Host
pHost
,
public
DefaultCachingComponent
(
Host
pHost
,
...
@@ -67,8 +68,13 @@ implements CachingComponent, ConnectivityListener {
...
@@ -67,8 +68,13 @@ implements CachingComponent, ConnectivityListener {
_host
=
pHost
;
_host
=
pHost
;
if
(
_host
!=
null
)
{
if
(
_host
!=
null
)
{
_host
.
getNetworkComponent
().
getByName
(
NetInterfaceName
.
WIFI
)
NetInterface
wifi
=
_host
.
getNetworkComponent
().
getByName
(
NetInterfaceName
.
WIFI
);
.
addConnectivityListener
(
this
);
if
(
wifi
!=
null
)
{
wifi
.
addConnectivityListener
(
this
);
}
else
{
NetInterface
cellular
=
_host
.
getNetworkComponent
().
getByName
(
NetInterfaceName
.
MOBILE
);
cellular
.
addConnectivityListener
(
this
);
}
}
}
_invalidationStrategy
=
pInvalidationStrategy
;
_invalidationStrategy
=
pInvalidationStrategy
;
...
@@ -85,28 +91,40 @@ implements CachingComponent, ConnectivityListener {
...
@@ -85,28 +91,40 @@ implements CachingComponent, ConnectivityListener {
return
null
;
return
null
;
}
}
Map
<
Object
,
List
<
PointInformation
>>
similarCacheEntries
=
new
HashMap
<>();
Map
<
Object
,
Map
<
Class
<?
extends
Object
>,
List
<
PointInformation
>>
>
similarCacheEntries
=
new
HashMap
<>();
for
(
T
t
:
cacheEntries
)
{
for
(
T
t
:
cacheEntries
)
{
Object
position
=
getEdgeOrPosition
(
t
);
Object
position
=
getEdgeOrPosition
(
t
);
if
(!
similarCacheEntries
.
containsKey
(
position
))
{
if
(!
similarCacheEntries
.
containsKey
(
position
))
{
similarCacheEntries
.
put
(
position
,
new
ArrayList
<>());
similarCacheEntries
.
put
(
position
,
new
HashMap
<>());
}
}
similarCacheEntries
.
get
(
position
).
add
(
t
);
if
(!
similarCacheEntries
.
get
(
position
).
containsKey
(
t
.
getValue
().
getClass
()))
{
similarCacheEntries
.
get
(
position
).
put
(
t
.
getValue
().
getClass
(),
new
ArrayList
<
PointInformation
>());
}
similarCacheEntries
.
get
(
position
).
get
(
t
.
getValue
().
getClass
()).
add
(
t
);
}
}
List
<
T
>
decidedInformation
=
new
ArrayList
<>();
List
<
T
>
decidedInformation
=
new
ArrayList
<>();
for
(
List
<
PointInformation
>
similarE
ntri
es
:
similarCacheEntries
for
(
Map
<
Class
<?
extends
Object
>,
List
<
PointInformation
>
>
similarE
dg
es
:
similarCacheEntries
.
values
())
{
.
values
())
{
PointInformation
correctInformation
=
_decisionStrategy
for
(
List
<
PointInformation
>
similarInformation
:
similarEdges
.
values
())
{
.
decideOnCorrectInformation
(
similarEntries
);
if
(
similarInformation
.
size
()
>=
_minObservations
)
{
decidedInformation
.
add
((
T
)
correctInformation
);
PointInformation
correctInformation
=
_decisionStrategy
.
decideOnCorrectInformation
(
similarInformation
);
decidedInformation
.
add
((
T
)
correctInformation
);
}
}
}
}
return
decidedInformation
;
return
decidedInformation
;
}
}
public
void
setMinObservations
(
int
pMinObservations
)
{
this
.
_minObservations
=
pMinObservations
;
}
@Override
@Override
public
<
T
extends
PointInformation
>
List
<
T
>
getCacheEntries
(
public
<
T
extends
PointInformation
>
List
<
T
>
getCacheEntries
(
Class
<
T
>
pCacheEntryClass
)
{
Class
<
T
>
pCacheEntryClass
)
{
...
...
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