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
120c157a
Commit
120c157a
authored
Nov 06, 2017
by
Tobias Meuser
Browse files
Improved optimal decision strategy
parent
adee2028
Changes
1
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/vehicular/caching/decision/OptimalCacheDecisionStrategy.java
View file @
120c157a
...
@@ -23,7 +23,6 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
...
@@ -23,7 +23,6 @@ package de.tud.kom.p2psim.impl.vehicular.caching.decision;
import
java.util.List
;
import
java.util.List
;
import
de.tud.kom.p2psim.impl.topology.movement.VehicleMovementModel
;
import
de.tud.kom.p2psim.impl.topology.movement.VehicleMovementModel
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
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.roadnetwork.RoadNetwork
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork
;
...
@@ -32,9 +31,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
...
@@ -32,9 +31,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
public
class
OptimalCacheDecisionStrategy
implements
CacheDecisionStrategy
{
public
class
OptimalCacheDecisionStrategy
implements
CacheDecisionStrategy
{
private
RoadNetwork
_roadNetwork
;
private
RoadNetwork
_roadNetwork
;
private
boolean
_lastJamState
=
false
;
private
long
_lastChange
=
0
;
public
OptimalCacheDecisionStrategy
()
{
public
OptimalCacheDecisionStrategy
()
{
}
}
...
@@ -59,23 +55,14 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -59,23 +55,14 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
jam
=
true
;
jam
=
true
;
}
}
if
(
jam
!=
_lastJamState
)
{
_lastChange
=
Time
.
getCurrentTime
();
}
long
maxTimestamp
=
-
1
;
long
maxTimestamp
=
-
1
;
T
maxFitting
=
null
;
T
maxFitting
=
null
;
T
maxFittingIncludingTimestamp
=
null
;
for
(
T
t
:
pSimilarPointInformation
)
{
for
(
T
t
:
pSimilarPointInformation
)
{
long
timestamp
=
t
.
getDetectionDate
();
long
timestamp
=
t
.
getDetectionDate
();
if
(
t
.
getValue
().
equals
(
jam
)
&&
timestamp
>
maxTimestamp
)
{
if
(
t
.
getValue
().
equals
(
jam
)
&&
timestamp
>
maxTimestamp
)
{
maxTimestamp
=
timestamp
;
maxTimestamp
=
timestamp
;
maxFitting
=
t
;
maxFitting
=
t
;
if
(
timestamp
>
_lastChange
)
{
maxFittingIncludingTimestamp
=
t
;
}
}
}
}
}
...
@@ -92,23 +79,6 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
...
@@ -92,23 +79,6 @@ public class OptimalCacheDecisionStrategy implements CacheDecisionStrategy {
}
}
}
}
if
(
maxFittingIncludingTimestamp
==
null
)
{
maxTimestamp
=
-
1
;
for
(
T
t
:
pSimilarPointInformation
)
{
long
timestamp
=
t
.
getDetectionDate
();
if
(
timestamp
>
maxTimestamp
&&
timestamp
>
_lastChange
)
{
maxTimestamp
=
timestamp
;
maxFittingIncludingTimestamp
=
t
;
}
}
}
if
(
maxFittingIncludingTimestamp
!=
null
)
{
return
maxFittingIncludingTimestamp
;
}
return
maxFitting
;
return
maxFitting
;
}
}
}
}
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