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
681cc6df
Commit
681cc6df
authored
Jun 26, 2018
by
Tobias Meuser
Browse files
Final version for Springer book
parent
d202296e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/vehicular/caching/DefaultCachingComponent.java
View file @
681cc6df
...
@@ -32,6 +32,7 @@ import de.tudarmstadt.maki.simonstrator.api.Time;
...
@@ -32,6 +32,7 @@ import de.tudarmstadt.maki.simonstrator.api.Time;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.transition.TransitionEngine
;
import
de.tudarmstadt.maki.simonstrator.api.component.transition.TransitionEngine
;
import
de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener
;
import
de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent
;
...
@@ -49,6 +50,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Road
...
@@ -49,6 +50,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Road
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork
;
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
;
import
de.tudresden.sumo.cmd.Simulation
;
public
class
DefaultCachingComponent
implements
CachingComponent
,
ConnectivityListener
{
public
class
DefaultCachingComponent
implements
CachingComponent
,
ConnectivityListener
{
...
@@ -62,8 +64,8 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
...
@@ -62,8 +64,8 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
private
CacheReplacementStrategy
_replacementStrategy
;
private
CacheReplacementStrategy
_replacementStrategy
;
CacheDecisionStrategy
_defaultDecisionStrategy
;
private
CacheDecisionStrategy
_defaultDecisionStrategy
;
Map
<
Class
<?
extends
Object
>,
CacheDecisionStrategy
>
_decisionStrategies
=
new
HashMap
<>();
private
Map
<
Class
<?
extends
Object
>,
CacheDecisionStrategy
>
_decisionStrategies
=
new
HashMap
<>();
private
int
_minObservations
=
0
;
private
int
_minObservations
=
0
;
...
@@ -267,7 +269,7 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
...
@@ -267,7 +269,7 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
}
}
}
}
shrinkCache
(
_maxCacheSize
-
1
);
shrinkCache
(
_maxCacheSize
);
entries
.
add
(
pCacheEntry
);
entries
.
add
(
pCacheEntry
);
...
@@ -277,7 +279,7 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
...
@@ -277,7 +279,7 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
}
}
private
void
shrinkCache
(
int
maxSize
)
{
private
void
shrinkCache
(
int
maxSize
)
{
while
(
maxSize
<
getTotalCacheSize
())
{
while
(
getTotalCacheSize
()
>
maxSize
)
{
int
maxSizeValue
=
0
;
int
maxSizeValue
=
0
;
List
<
PointInformation
>
removedValues
=
null
;
List
<
PointInformation
>
removedValues
=
null
;
List
<
PointInformation
>
removedList
=
null
;
List
<
PointInformation
>
removedList
=
null
;
...
@@ -295,6 +297,13 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
...
@@ -295,6 +297,13 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
}
}
for
(
Entry
<
Object
,
List
<
PointInformation
>>
entry
:
perPosition
.
entrySet
())
{
for
(
Entry
<
Object
,
List
<
PointInformation
>>
entry
:
perPosition
.
entrySet
())
{
if
(!((
RoadNetworkEdge
)
entry
.
getKey
()).
isActive
())
{
removedValues
=
entry
.
getValue
();
removedList
=
informationList
;
break
;
}
if
(
maxSizeValue
<
entry
.
getValue
().
size
())
{
if
(
maxSizeValue
<
entry
.
getValue
().
size
())
{
maxSizeValue
=
entry
.
getValue
().
size
();
maxSizeValue
=
entry
.
getValue
().
size
();
removedValues
=
entry
.
getValue
();
removedValues
=
entry
.
getValue
();
...
...
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/TTLbasedVectoralCacheDecisionStrategy.java
View file @
681cc6df
...
@@ -31,12 +31,14 @@ import de.tudarmstadt.maki.simonstrator.api.Time;
...
@@ -31,12 +31,14 @@ import de.tudarmstadt.maki.simonstrator.api.Time;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.TemporalDependencyMatrix
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.TemporalDependencyMatrix
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.aggregation.AggregationInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.transition.MechanismState
;
import
de.tudarmstadt.maki.simonstrator.api.component.transition.MechanismState
;
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
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheDecisionStrategyParameters
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheDecisionStrategyParameters
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheSizeAwareCacheDecisionStrategy
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision.CacheSizeAwareCacheDecisionStrategy
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AggregatedInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AvailableInformationAttributes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AvailableInformationAttributes
;
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
;
...
@@ -112,7 +114,7 @@ public class TTLbasedVectoralCacheDecisionStrategy extends AbstractCacheDecision
...
@@ -112,7 +114,7 @@ public class TTLbasedVectoralCacheDecisionStrategy extends AbstractCacheDecision
if
(
value
instanceof
VectoralProperty
)
{
if
(
value
instanceof
VectoralProperty
)
{
value
=
((
VectoralProperty
)
value
).
getMostProbableIndex
();
value
=
((
VectoralProperty
)
value
).
getMostProbableIndex
();
}
}
boolean
differentValue
=
fals
e
;
boolean
differentValue
=
tru
e
;
if
(
differentValue
)
{
if
(
differentValue
)
{
List
<
Integer
>
possibleValues
=
new
ArrayList
<>();
List
<
Integer
>
possibleValues
=
new
ArrayList
<>();
...
@@ -145,6 +147,13 @@ public class TTLbasedVectoralCacheDecisionStrategy extends AbstractCacheDecision
...
@@ -145,6 +147,13 @@ public class TTLbasedVectoralCacheDecisionStrategy extends AbstractCacheDecision
}
}
}
}
}
}
if
(
t
instanceof
AggregatedInformation
)
{
AggregationInformation
aggregationInformation
=
((
AggregatedInformation
)
t
).
getAggregationInformation
();
if
(
aggregationInformation
!=
null
&&
aggregationInformation
.
getMinTimestamp
()
<
minTimestamp
)
{
minTimestamp
=
aggregationInformation
.
getMinTimestamp
();
}
}
}
}
VectoralProperty
currentProperty
=
null
;
VectoralProperty
currentProperty
=
null
;
...
@@ -156,7 +165,6 @@ public class TTLbasedVectoralCacheDecisionStrategy extends AbstractCacheDecision
...
@@ -156,7 +165,6 @@ public class TTLbasedVectoralCacheDecisionStrategy extends AbstractCacheDecision
double
impact
=
impactFunction
.
calculateImpact
(
t
);
double
impact
=
impactFunction
.
calculateImpact
(
t
);
TemporalDependencyMatrix
dependencyMatrix
=
property
.
getDependencyMatrix
();
TemporalDependencyMatrix
dependencyMatrix
=
property
.
getDependencyMatrix
();
dependencyMatrix
=
modifyDependencyMatrix
(
dependencyMatrix
.
age
((
maxTimestamp
-
property
.
getDetectionDate
())
/
SCALING
),
impact
);
dependencyMatrix
=
modifyDependencyMatrix
(
dependencyMatrix
.
age
((
maxTimestamp
-
property
.
getDetectionDate
())
/
SCALING
),
impact
);
...
...
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