Commit 120c157a authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Improved optimal decision strategy

parent adee2028
...@@ -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;
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment