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
f476dae3
Commit
f476dae3
authored
Apr 30, 2018
by
Tobias Meuser
Browse files
First really working version for adhoc
parent
ed38bb7e
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/vehicular/caching/DefaultCachingComponent.java
View file @
f476dae3
...
@@ -40,6 +40,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Avai
...
@@ -40,6 +40,7 @@ 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
;
...
@@ -88,6 +89,7 @@ implements CachingComponent, ConnectivityListener {
...
@@ -88,6 +89,7 @@ implements CachingComponent, ConnectivityListener {
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
ArrayList
<>());
}
}
...
...
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/AveragingCacheDecisionStrategy.java
View file @
f476dae3
...
@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
...
@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
import
java.util.List
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.NumericVectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.NumericVectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VectoralJamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.
jam.
VectoralJamProperty
;
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.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
;
...
...
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/MajorityVotingVectoralCacheDecisionStrategy.java
View file @
f476dae3
...
@@ -23,8 +23,8 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
...
@@ -23,8 +23,8 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
import
java.util.List
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
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.vector.TemporalDependencyMatrix
;
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.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
;
...
...
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/OptimalCacheDecisionStrategy.java
View file @
f476dae3
...
@@ -22,12 +22,12 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
...
@@ -22,12 +22,12 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
import
java.util.List
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.
component.sensor.environment.data.JamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.
Time
;
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.jam.JamProperty
;
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.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.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
public
class
OptimalCacheDecisionStrategy
implements
CacheDecisionStrategy
{
public
class
OptimalCacheDecisionStrategy
implements
CacheDecisionStrategy
{
...
@@ -43,14 +43,10 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -43,14 +43,10 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
}
else
if
(
pSimilarPointInformation
.
size
()
==
0
)
{
}
else
if
(
pSimilarPointInformation
.
size
()
==
0
)
{
return
null
;
return
null
;
}
}
RoadNetworkEdge
edge
=
(
RoadNetworkEdge
)
pSimilarPointInformation
.
get
(
0
).
getAttribute
(
AvailableInformationAttributes
.
EDGE
);
double
actualSpeed
=
edge
.
getCurrentSpeedState
(
);
RoadNetworkEdge
edge
=
(
RoadNetworkEdge
)
pSimilarPointInformation
.
get
(
0
).
getAttribute
(
AvailableInformationAttributes
.
EDGE
);
if
(
actualSpeed
==
24
d
)
{
double
actualSpeed
=
edge
.
getCurrentSpeed
();
System
.
out
.
println
();
}
JamProperty
jamProperty
=
edge
.
getJamProperty
();
JamProperty
jamProperty
=
edge
.
getJamProperty
();
...
@@ -61,6 +57,7 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -61,6 +57,7 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
maxTimestamp
=
-
1
;
maxTimestamp
=
-
1
;
}
}
double
difference
=
Double
.
MAX_VALUE
;
T
maxFitting
=
null
;
T
maxFitting
=
null
;
for
(
T
t
:
pSimilarPointInformation
)
{
for
(
T
t
:
pSimilarPointInformation
)
{
long
timestamp
=
t
.
getDetectionDate
();
long
timestamp
=
t
.
getDetectionDate
();
...
@@ -69,9 +66,15 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -69,9 +66,15 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
if
(
currentValue
instanceof
VectoralProperty
)
{
if
(
currentValue
instanceof
VectoralProperty
)
{
currentValue
=
((
VectoralProperty
)
currentValue
).
getMostProbableValue
();
currentValue
=
((
VectoralProperty
)
currentValue
).
getMostProbableValue
();
}
}
if
(
currentValue
.
equals
(
actualSpeed
)
&&
timestamp
>
maxTimestamp
)
{
maxTimestamp
=
timestamp
;
if
(
timestamp
>=
maxTimestamp
)
{
maxFitting
=
t
;
if
(
currentValue
.
equals
(
actualSpeed
))
{
maxFitting
=
t
;
difference
=
0
;
}
else
if
(
currentValue
instanceof
Number
&&
Math
.
abs
(((
Number
)
currentValue
).
doubleValue
()
-
actualSpeed
)
<
difference
)
{
maxFitting
=
t
;
difference
=
Math
.
abs
(((
Number
)
currentValue
).
doubleValue
()
-
actualSpeed
);
}
}
}
}
}
...
@@ -81,7 +84,7 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -81,7 +84,7 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
for
(
T
t
:
pSimilarPointInformation
)
{
for
(
T
t
:
pSimilarPointInformation
)
{
long
timestamp
=
t
.
getDetectionDate
();
long
timestamp
=
t
.
getDetectionDate
();
if
(
timestamp
>
maxTimestamp
)
{
if
(
timestamp
>
=
maxTimestamp
)
{
maxTimestamp
=
timestamp
;
maxTimestamp
=
timestamp
;
maxFitting
=
t
;
maxFitting
=
t
;
}
}
...
...
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/TTLbasedCacheDecisionStrategy.java
View file @
f476dae3
...
@@ -27,14 +27,15 @@ import java.util.List;
...
@@ -27,14 +27,15 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
cern.colt.Arrays
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
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.VectoralJamProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.VectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam.VectoralJamProperty
;
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.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
;
import
edu.emory.mathcs.backport.java.util.Arrays
;
public
class
TTLbasedCacheDecisionStrategy
implements
CacheDecisionStrategy
{
public
class
TTLbasedCacheDecisionStrategy
implements
CacheDecisionStrategy
{
private
static
final
long
SCALING
=
Time
.
SECOND
;
private
static
final
long
SCALING
=
Time
.
SECOND
;
...
@@ -117,10 +118,6 @@ public class TTLbasedCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -117,10 +118,6 @@ public class TTLbasedCacheDecisionStrategy implements CacheDecisionStrategy {
}
}
if
(
differentValue
)
{
if
(
differentValue
)
{
if
(
Time
.
getCurrentTime
()
==
463500000
)
{
System
.
out
.
println
();
}
long
difference
=
maxTimestamp
-
minTimestamp
;
long
difference
=
maxTimestamp
-
minTimestamp
;
if
(
difference
==
0
)
{
if
(
difference
==
0
)
{
...
@@ -176,8 +173,8 @@ public class TTLbasedCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -176,8 +173,8 @@ public class TTLbasedCacheDecisionStrategy implements CacheDecisionStrategy {
long
timestamp
=
t
.
getDetectionDate
();
long
timestamp
=
t
.
getDetectionDate
();
Object
currentValue
=
t
.
getValue
();
Object
currentValue
=
t
.
getValue
();
if
(
currentValue
instanceof
Vectoral
Jam
Property
)
{
if
(
currentValue
instanceof
VectoralProperty
)
{
currentValue
=
((
Vectoral
Jam
Property
)
currentValue
).
getMostProbableValue
();
currentValue
=
((
VectoralProperty
)
currentValue
).
getMostProbableValue
();
}
}
if
(
currentValue
.
equals
(
maxValue
)
&&
timestamp
>
maxTimestamp
)
{
if
(
currentValue
.
equals
(
maxValue
)
&&
timestamp
>
maxTimestamp
)
{
...
@@ -185,6 +182,26 @@ public class TTLbasedCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -185,6 +182,26 @@ public class TTLbasedCacheDecisionStrategy implements CacheDecisionStrategy {
maxFitting
=
t
;
maxFitting
=
t
;
}
}
}
}
if
(
maxFitting
.
getValue
()
instanceof
VectoralProperty
)
{
VectoralProperty
vectoralProperty
=
((
VectoralProperty
)
maxFitting
.
getValue
()).
clone
();
double
[]
valueProbabilities
=
vectoralProperty
.
getValueProbabilities
();
Arrays
.
fill
(
valueProbabilities
,
0
);
double
sum
=
0
;
for
(
Object
key
:
weight
.
keySet
())
{
valueProbabilities
[
vectoralProperty
.
getIndexForValue
(
key
)]
=
weight
.
get
(
key
);
sum
+=
weight
.
get
(
key
);
}
for
(
int
i
=
0
;
i
<
valueProbabilities
.
length
;
i
++)
{
valueProbabilities
[
i
]
/=
sum
;
}
RoadInformation
roadInformation
=
new
RoadInformation
(
vectoralProperty
);
roadInformation
.
copyAttributes
((
RoadInformation
)
maxFitting
);
maxFitting
=
(
T
)
roadInformation
;
}
_lastDecision
=
maxFitting
.
getValue
();
_lastDecision
=
maxFitting
.
getValue
();
...
@@ -206,7 +223,7 @@ public class TTLbasedCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -206,7 +223,7 @@ public class TTLbasedCacheDecisionStrategy implements CacheDecisionStrategy {
return
maxFitting
;
return
maxFitting
;
}
}
}
}
public
double
calculateImpact
(
double
errorProbability
,
long
ttl
,
long
time
,
double
b
,
long
maxTimestamp
)
{
public
double
calculateImpact
(
double
errorProbability
,
long
ttl
,
long
time
,
double
b
,
long
maxTimestamp
)
{
long
age
=
maxTimestamp
-
time
;
long
age
=
maxTimestamp
-
time
;
if
(
errorProbability
==
0
)
{
if
(
errorProbability
==
0
)
{
...
...
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/TTLbasedVectoralCacheDecisionStrategy.java
View file @
f476dae3
...
@@ -21,15 +21,16 @@
...
@@ -21,15 +21,16 @@
package
de.tud.kom.p2psim.impl.vehicular.caching.decision
;
package
de.tud.kom.p2psim.impl.vehicular.caching.decision
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
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.Time
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.
VectoralJamProperty
;
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.
vector.TemporalDependencyMatrix
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.
measurement.MeasurementDistributionTypeContainer
;
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.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
;
...
@@ -100,11 +101,11 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -100,11 +101,11 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
long
maxTimestamp
=
0
;
long
maxTimestamp
=
0
;
Object
value
=
pSimilarPointInformation
.
get
(
0
).
getValue
();
Object
value
=
pSimilarPointInformation
.
get
(
0
).
getValue
();
if
(
value
instanceof
VectoralProperty
)
{
if
(
value
instanceof
VectoralProperty
)
{
value
=
((
VectoralProperty
)
value
).
getMostProbable
Value
();
value
=
((
VectoralProperty
)
value
).
getMostProbable
Index
();
}
}
boolean
differentValue
=
false
;
boolean
differentValue
=
false
;
List
<
Double
>
possibleValues
=
new
ArrayList
<>();
List
<
Integer
>
possibleValues
=
new
ArrayList
<>();
for
(
T
t
:
pSimilarPointInformation
)
{
for
(
T
t
:
pSimilarPointInformation
)
{
if
(!
t
.
hasAttribute
(
AvailableInformationAttributes
.
TTL
))
{
if
(!
t
.
hasAttribute
(
AvailableInformationAttributes
.
TTL
))
{
...
@@ -122,13 +123,16 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -122,13 +123,16 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
Object
currentValue
=
t
.
getValue
();
Object
currentValue
=
t
.
getValue
();
if
(
currentValue
instanceof
VectoralProperty
)
{
if
(
currentValue
instanceof
VectoralProperty
)
{
VectoralProperty
currentProperty
=
(
VectoralProperty
)
currentValue
;
VectoralProperty
currentProperty
=
(
VectoralProperty
)
currentValue
;
currentValue
=
currentProperty
.
getMostProbableValue
();
currentValue
=
currentProperty
.
getMostProbableIndex
();
if
(!
value
.
equals
(
currentValue
))
{
if
(!
value
.
equals
(
currentValue
))
{
differentValue
=
true
;
differentValue
=
true
;
}
}
if
(!
possibleValues
.
contains
(
currentValue
))
{
for
(
int
i
=
0
;
i
<
currentProperty
.
getValueProbabilities
().
length
;
i
++)
{
possibleValues
.
add
((
Double
)
currentValue
);
if
(!
possibleValues
.
contains
(
i
))
{
possibleValues
.
add
(
i
);
}
}
}
}
}
}
}
...
@@ -143,26 +147,33 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -143,26 +147,33 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
double
rate
=
difference
/
((
double
)
(
pSimilarPointInformation
.
size
()
-
1
)
*
SCALING
);
double
rate
=
difference
/
((
double
)
(
pSimilarPointInformation
.
size
()
-
1
)
*
SCALING
);
long
ttl
=
getTTL
(
pSimilarPointInformation
.
get
(
0
));
long
ttl
=
getTTL
(
pSimilarPointInformation
.
get
(
0
));
double
numberOfMessages
=
ttl
/
rate
;
double
numberOfMessages
=
ttl
/
rate
+
1
;
VectoralProperty
currentProperty
=
null
;
VectoralProperty
currentProperty
=
null
;
double
b
=
0
;
List
<
Double
>
bValues
=
new
ArrayList
<>();
int
count
=
0
;
double
b
;
for
(
Double
possibleValue
:
possibleValues
)
{
for
(
Integer
possibleValue
:
possibleValues
)
{
double
temp
=
determineB
(((
RoadInformation
)
pSimilarPointInformation
.
get
(
0
)).
getEdge
(),
possibleValue
,
getChangeRate
(
pSimilarPointInformation
.
get
(
0
),
rate
),
rate
,
1
-
accuracy
,
numberOfMessages
,
costWrongKeep
,
costWrongChange
);
double
temp
=
determineB
((
VectoralProperty
)
pSimilarPointInformation
.
get
(
0
).
getValue
(),
((
RoadInformation
)
pSimilarPointInformation
.
get
(
0
)).
getEdge
(),
possibleValue
,
getChangeRate
(
pSimilarPointInformation
.
get
(
0
),
rate
),
rate
,
1
-
accuracy
,
numberOfMessages
,
costWrongKeep
,
costWrongChange
);
if
(!
Double
.
isNaN
(
temp
))
{
if
(!
Double
.
isNaN
(
temp
))
{
b
+=
temp
;
bValues
.
add
(
temp
);
count
++;
}
}
}
}
if
(
count
>
0
)
{
Collections
.
sort
(
bValues
);
b
/=
count
;
if
(
bValues
.
size
()
>
0
)
{
if
(
bValues
.
size
()
%
2
==
0
)
{
b
=
(
bValues
.
get
(
bValues
.
size
()
/
2
)
+
bValues
.
get
(
bValues
.
size
()
/
2
-
1
))
/
2.0
;
}
else
{
b
=
bValues
.
get
(
bValues
.
size
()
/
2
);
}
}
else
{
}
else
{
b
=
Double
.
NEGATIVE_INFINITY
;
b
=
Double
.
NEGATIVE_INFINITY
;
}
}
int
count
=
0
;
for
(
T
t
:
pSimilarPointInformation
)
{
for
(
T
t
:
pSimilarPointInformation
)
{
RoadInformation
roadInformation
=
((
RoadInformation
)
t
);
RoadInformation
roadInformation
=
((
RoadInformation
)
t
);
VectoralProperty
property
=
(
VectoralProperty
)
roadInformation
.
getValue
();
VectoralProperty
property
=
(
VectoralProperty
)
roadInformation
.
getValue
();
...
@@ -214,12 +225,12 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -214,12 +225,12 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
* @return
* @return
*/
*/
private
<
T
extends
PointInformation
>
double
getAccuracy
(
T
pT
)
{
private
<
T
extends
PointInformation
>
double
getAccuracy
(
T
pT
)
{
if
(
pT
instanceof
RoadInformation
)
{
//
if (pT instanceof RoadInformation) {
RoadInformation
roadInformation
=
((
RoadInformation
)
pT
);
//
RoadInformation roadInformation = ((RoadInformation) pT);
VectoralProperty
property
=
(
VectoralProperty
)
roadInformation
.
getValue
();
//
VectoralProperty property = (VectoralProperty) roadInformation.getValue();
double
accuracy
=
property
.
getProbabilityFor
Value
(
property
.
getMostProbable
Value
());
//
double accuracy = property.getProbabilityFor
Index
(property.getMostProbable
Index
());
return
accuracy
;
//
return accuracy;
}
//
}
return
this
.
accuracy
;
return
this
.
accuracy
;
}
}
...
@@ -296,17 +307,17 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -296,17 +307,17 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
return
(
int
)
Math
.
round
(
Math
.
log
(-
changeProbability
/
Math
.
log
(
errorProbability
)
*
costSlow
/
costFast
)
/
Math
.
log
(
errorProbability
));
return
(
int
)
Math
.
round
(
Math
.
log
(-
changeProbability
/
Math
.
log
(
errorProbability
)
*
costSlow
/
costFast
)
/
Math
.
log
(
errorProbability
));
}
}
public
double
determineB
(
RoadNetworkEdge
pRoadNetworkEdge
,
double
pPossibleValue
,
double
change
,
double
rate
,
double
errorProbability
,
double
pNumberOfMessages
,
double
costSlow
,
double
costFast
)
{
public
double
determineB
(
VectoralProperty
pTemplate
,
RoadNetworkEdge
pRoadNetworkEdge
,
int
pPossibleValue
,
double
change
,
double
rate
,
double
errorProbability
,
double
pNumberOfMessages
,
double
costSlow
,
double
costFast
)
{
if
(
errorProbability
==
0
||
errorProbability
==
1
||
errorProbability
==
0.5
)
{
if
(
errorProbability
==
0
||
errorProbability
==
1
||
errorProbability
==
0.5
)
{
return
Double
.
NaN
;
return
Double
.
NaN
;
}
}
if
(
_lastDecision
!=
null
)
{
if
(
_lastDecision
!=
null
)
{
if
(
pPossibleValue
==
((
Vectoral
Jam
Property
)
_lastDecision
).
getMostProbable
Value
())
{
if
(
pPossibleValue
==
((
VectoralProperty
)
_lastDecision
).
getMostProbable
Index
())
{
return
Double
.
NaN
;
return
Double
.
NaN
;
}
}
}
else
{
}
else
{
if
(
pPossibleValue
==
p
RoadNetworkEdge
.
getCurrentSpeedState
())
{
if
(
pPossibleValue
==
p
Template
.
getDefaultIndex
())
{
return
Double
.
NaN
;
return
Double
.
NaN
;
}
}
}
}
...
@@ -316,6 +327,10 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -316,6 +327,10 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
int
optimalAmount
=
getOptimalMessageAmountForSwitch
(
p_c
,
errorProbability
,
costSlow
,
costFast
);
int
optimalAmount
=
getOptimalMessageAmountForSwitch
(
p_c
,
errorProbability
,
costSlow
,
costFast
);
if
((
int
)
pNumberOfMessages
<=
optimalAmount
)
{
return
Double
.
POSITIVE_INFINITY
;
}
if
(
optimalAmount
==
1
)
{
if
(
optimalAmount
==
1
)
{
return
Double
.
NEGATIVE_INFINITY
;
return
Double
.
NEGATIVE_INFINITY
;
}
}
...
@@ -331,15 +346,15 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -331,15 +346,15 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
}
}
do
{
do
{
Vectoral
Jam
Property
valueAfterN
=
calculateMostProbable
Value
(
pRoadNetworkEdge
,
pPossibleValue
,
optimalAmount
,
rate
,
errorProbability
,
pNumberOfMessages
,
b
);
VectoralProperty
valueAfterN
=
calculateMostProbable
(
pTemplate
,
pRoadNetworkEdge
,
pPossibleValue
,
optimalAmount
,
rate
,
errorProbability
,
pNumberOfMessages
,
b
);
double
probableValueAfterN
=
Double
.
NaN
;
double
probableValueAfterN
=
Double
.
NaN
;
if
(
valueAfterN
!=
null
)
{
if
(
valueAfterN
!=
null
)
{
probableValueAfterN
=
valueAfterN
.
getMostProbable
Value
();
probableValueAfterN
=
valueAfterN
.
getMostProbable
Index
();
}
}
Vectoral
Jam
Property
valueBeforeN
=
calculateMostProbable
Value
(
pRoadNetworkEdge
,
pPossibleValue
,
optimalAmount
-
1
,
rate
,
errorProbability
,
pNumberOfMessages
,
b
);
VectoralProperty
valueBeforeN
=
calculateMostProbable
(
pTemplate
,
pRoadNetworkEdge
,
pPossibleValue
,
optimalAmount
-
1
,
rate
,
errorProbability
,
pNumberOfMessages
,
b
);
double
probableValueBeforeN
=
Double
.
NaN
;
double
probableValueBeforeN
=
Double
.
NaN
;
if
(
valueBeforeN
!=
null
)
{
if
(
valueBeforeN
!=
null
)
{
probableValueBeforeN
=
valueBeforeN
.
getMostProbable
Value
();
probableValueBeforeN
=
valueBeforeN
.
getMostProbable
Index
();
}
}
if
(
probableValueAfterN
==
pPossibleValue
&&
probableValueAfterN
!=
probableValueBeforeN
)
{
if
(
probableValueAfterN
==
pPossibleValue
&&
probableValueAfterN
!=
probableValueBeforeN
)
{
...
@@ -378,16 +393,16 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -378,16 +393,16 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
}
while
(
true
);
}
while
(
true
);
}
}
public
Vectoral
Jam
Property
calculateMostProbable
Value
(
RoadNetworkEdge
pRoadNetworkEdge
,
double
pNewValue
,
int
optimalMessageAmount
,
double
rate
,
double
errorProbability
,
double
pNumberOfMessages
,
double
b
)
{
public
VectoralProperty
calculateMostProbable
(
VectoralProperty
pTemplate
,
RoadNetworkEdge
pRoadNetworkEdge
,
int
pNewValue
,
int
optimalMessageAmount
,
double
rate
,
double
errorProbability
,
double
pNumberOfMessages
,
double
b
)
{
Vectoral
Jam
Property
currentProperty
=
null
;
VectoralProperty
currentProperty
=
null
;
for
(
int
a
=
optimalMessageAmount
+
1
;
a
<=
pNumberOfMessages
;
a
++)
{
for
(
int
a
=
optimalMessageAmount
+
1
;
a
<=
pNumberOfMessages
;
a
++)
{
Vectoral
Jam
Property
jamProperty
=
new
VectoralJamProperty
();
VectoralProperty
jamProperty
=
pTemplate
.
clone
();
if
(
_lastDecision
!=
null
)
{
if
(
_lastDecision
!=
null
)
{
jamProperty
.
set
GaussianSpeedWithAccuracy
(((
Vectoral
Jam
Property
)
_lastDecision
).
getMostProbable
Value
(),
accuracy
);
jamProperty
.
set
(((
VectoralProperty
)
_lastDecision
).
getMostProbable
Index
(),
accuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
pTemplate
.
getClass
())
);
}
else
{
}
else
{
jamProperty
.
set
GaussianSpeedWithAccuracy
(
pRoadNetworkEdge
.
getCurrentSpeedState
(),
accuracy
);
jamProperty
.
set
(
pTemplate
.
getDefaultIndex
(),
accuracy
,
MeasurementDistributionTypeContainer
.
getDistribution
(
pTemplate
.
getClass
())
);
}
}
TemporalDependencyMatrix
temporalDependencyMatrix
=
jamProperty
.
getDependencyMatrix
();
TemporalDependencyMatrix
temporalDependencyMatrix
=
jamProperty
.
getDependencyMatrix
();
temporalDependencyMatrix
=
temporalDependencyMatrix
.
age
((
long
)
(
a
*
rate
));
temporalDependencyMatrix
=
temporalDependencyMatrix
.
age
((
long
)
(
a
*
rate
));
...
@@ -398,18 +413,18 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -398,18 +413,18 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
}
}
temporalDependencyMatrix
=
modifyDependencyMatrix
(
temporalDependencyMatrix
,
impact
);
temporalDependencyMatrix
=
modifyDependencyMatrix
(
temporalDependencyMatrix
,
impact
);
jamProperty
=
(
Vectoral
Jam
Property
)
jamProperty
.
age
(
1
,
temporalDependencyMatrix
);
jamProperty
=
(
VectoralProperty
)
jamProperty
.
age
(
1
,
temporalDependencyMatrix
);
if
(
currentProperty
!=
null
)
{
if
(
currentProperty
!=
null
)
{
currentProperty
=
(
Vectoral
Jam
Property
)
currentProperty
.
combine
(
jamProperty
);
currentProperty
=
(
VectoralProperty
)
currentProperty
.
combine
(
jamProperty
);
}
else
{
}
else
{
currentProperty
=
jamProperty
;
currentProperty
=
jamProperty
;
}
}
}
}
for
(
int
a
=
0
;
a
<=
optimalMessageAmount
;
a
++)
{
for
(
int
a
=
0
;
a
<=
optimalMessageAmount
;
a
++)
{
Vectoral
Jam
Property
jamProperty
=
new
VectoralJamProperty
();
VectoralProperty
jamProperty
=
pTemplate
.
clone
();
jamProperty
.
setGaussian
Speed
WithAccuracy
(
pNewValue
,
accuracy
);
jamProperty
.
setGaussianWithAccuracy
(
pNewValue
,
accuracy
);
TemporalDependencyMatrix
temporalDependencyMatrix
=
jamProperty
.
getDependencyMatrix
();
TemporalDependencyMatrix
temporalDependencyMatrix
=
jamProperty
.
getDependencyMatrix
();
temporalDependencyMatrix
=
temporalDependencyMatrix
.
age
((
long
)
(
a
*
rate
));
temporalDependencyMatrix
=
temporalDependencyMatrix
.
age
((
long
)
(
a
*
rate
));
...
@@ -420,10 +435,10 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
...
@@ -420,10 +435,10 @@ public class TTLbasedVectoralCacheDecisionStrategy implements CacheDecisionStrat
}
}
temporalDependencyMatrix
=
modifyDependencyMatrix
(
temporalDependencyMatrix
,
impact
);
temporalDependencyMatrix
=
modifyDependencyMatrix
(
temporalDependencyMatrix
,
impact
);
jamProperty
=
(
Vectoral
Jam
Property
)
jamProperty
.
age
(
1
,
temporalDependencyMatrix
);
jamProperty
=
(
VectoralProperty
)
jamProperty
.
age
(
1
,
temporalDependencyMatrix
);
if
(
currentProperty
!=
null
)
{
if
(
currentProperty
!=
null
)
{
currentProperty
=
(
Vectoral
Jam
Property
)
currentProperty
.
combine
(
jamProperty
);
currentProperty
=
(
VectoralProperty
)
currentProperty
.
combine
(
jamProperty
);
}
else
{
}
else
{
currentProperty
=
jamProperty
;
currentProperty
=
jamProperty
;
}
}
...
...
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