Commit f96cb6a8 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Updated decision making for vehits, used processing server

parent 042766bf
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision;
public enum CacheDecisionStrategyParameters {
ACCURACY, COST_RATIO
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.decision;
public interface CacheSizeAwareCacheDecisionStrategy extends CacheDecisionStrategy {
void setCacheSize(int pCacheSize);
}
......@@ -35,5 +35,5 @@ public interface CacheReplacementStrategy {
* @return true, if the existing cache entry should be replaced, false
* otherwise.
*/
boolean replaceInformation(PointInformation pCachedInformation, PointInformation pSensedInformation);
boolean replaceInformation(PointInformation<?> pCachedInformation, PointInformation<?> pSensedInformation);
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.replacement;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.aggregation.AggregationInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AggregatedInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
public class SimilarInformationReplacementStrategy implements CacheReplacementStrategy {
@Override
public boolean replaceInformation(PointInformation<?> pCachedInformation, PointInformation<?> pSensedInformation) {
// if (Time.getCurrentTime() >= 195500000) {
// System.out.println();
// }
if (pCachedInformation instanceof AggregatedInformation
&& pSensedInformation instanceof AggregatedInformation) {
AggregatedInformation cachedAggregate = ((AggregatedInformation) pCachedInformation);
AggregatedInformation sensedAggregate = ((AggregatedInformation) pSensedInformation);
boolean same = true;
if (pCachedInformation.getValue() instanceof RoadProperty
&& pSensedInformation.getValue() instanceof RoadProperty) {
RoadProperty cachedValue = (RoadProperty) pCachedInformation.getValue();
RoadProperty sensedValue = (RoadProperty) pSensedInformation.getValue();
same = cachedValue.getEdge().equals(sensedValue.getEdge());
}
if (same && cachedAggregate.isAggregated() && sensedAggregate.isAggregated()) {
AggregationInformation cachedMetaInfo = cachedAggregate.getAggregationInformation();
AggregationInformation sensedMetaInfo = sensedAggregate.getAggregationInformation();
return sensedMetaInfo.getMinTimestamp() <= pCachedInformation.getDetectionDate();
}
}
return false;
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.information;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.aggregation.AggregationInformation;
public interface AggregatedInformation {
AggregationInformation getAggregationInformation();
boolean isAggregated();
}
......@@ -60,8 +60,16 @@ public class EnvironmentInformation<T extends LocationBasedEnvironmentProperty>
}
@Override
public <T> void setAttribute(AvailableInformationAttributes pKey, T pValue) {
_attributes.put(pKey, pValue);
public <S> void setAttribute(AvailableInformationAttributes pKey, S pValue) {
if (AvailableInformationAttributes.DATE.equals(pKey)) {
_environment.setDetectionDate((long) pValue);
} else if (AvailableInformationAttributes.VALUE.equals(pKey)) {
_environment = (T) pValue;
} else if (AvailableInformationAttributes.POSITION.equals(pKey)) {
_environment.setLocation((Location) pValue);
} else {
_attributes.put(pKey, pValue);
}
}
@SuppressWarnings("unchecked")
......@@ -82,12 +90,17 @@ public class EnvironmentInformation<T extends LocationBasedEnvironmentProperty>
@Override
public List<AvailableInformationAttributes> getAvailableAttributes() {
return new ArrayList<>(_attributes.keySet());
List<AvailableInformationAttributes> result = new ArrayList<>(_attributes.keySet());
result.add(AvailableInformationAttributes.DATE);
result.add(AvailableInformationAttributes.POSITION);
return result;
}
@Override
public <T> boolean hasAttribute(AvailableInformationAttributes pKey) {
return _attributes.containsKey(pKey);
return getAvailableAttributes().contains(pKey);
}
@Override
......
......@@ -21,7 +21,11 @@
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.information;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.AggregatedProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.aggregation.AggregationInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
/**
......@@ -30,7 +34,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
*
*/
public class RoadInformation extends EnvironmentInformation<RoadProperty>
implements VehicularPointInformation<RoadProperty> {
implements VehicularPointInformation<RoadProperty>, AggregatedInformation {
public RoadInformation(RoadProperty pEnvironment) {
super(pEnvironment);
......@@ -41,6 +45,24 @@ public class RoadInformation extends EnvironmentInformation<RoadProperty>
return getValue().getEdge();
}
@Override
public <T> void setAttribute(AvailableInformationAttributes pKey, T pValue) {
if (AvailableInformationAttributes.EDGE.equals(pKey)) {
getValue().setEdge((RoadNetworkEdge) pValue);
} else {
super.setAttribute(pKey, pValue);
}
}
@Override
public List<AvailableInformationAttributes> getAvailableAttributes() {
List<AvailableInformationAttributes> result = super.getAvailableAttributes();
result.add(AvailableInformationAttributes.EDGE);
return result;
}
@Override
public <T> T getAttribute(AvailableInformationAttributes pKey) {
if (AvailableInformationAttributes.EDGE.equals(pKey)) {
......@@ -57,10 +79,22 @@ public class RoadInformation extends EnvironmentInformation<RoadProperty>
@Override
public <T> boolean hasAttribute(AvailableInformationAttributes pKey) {
if (pKey.equals(AvailableInformationAttributes.EDGE)) {
return true;
}
return super.hasAttribute(pKey);
}
@Override
public AggregationInformation getAggregationInformation() {
if (getValue() instanceof AggregatedProperty) {
return ((AggregatedProperty) getValue()).getAggregationInformation();
}
return null;
}
@Override
public boolean isAggregated() {
if (getValue() instanceof AggregatedProperty) {
return ((AggregatedProperty) getValue()).isAggregated();
}
return false;
}
}
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
......@@ -43,16 +43,19 @@ public abstract class AbstractQoIBasedImpactFunction<T extends PointInformation>
protected long ttl;
protected long maxTimestamp;
protected long minTimestamp;
protected int maxCacheSize;
protected Object _lastDecision;
public AbstractQoIBasedImpactFunction(List<T> pInformation, double pAccuracy) {
this(pInformation, pAccuracy, null);
public AbstractQoIBasedImpactFunction(List<T> pInformation, double pAccuracy, int pMaxCacheSize) {
this(pInformation, pAccuracy, pMaxCacheSize, null);
}
public AbstractQoIBasedImpactFunction(List<T> pInformation, double pAccuracy, Object pLastDecision) {
public AbstractQoIBasedImpactFunction(List<T> pInformation, double pAccuracy, int pMaxCacheSize,
Object pLastDecision) {
accuracy = pAccuracy;
maxCacheSize = pMaxCacheSize;
_lastDecision = pLastDecision;
minTimestamp = Long.MAX_VALUE;
maxTimestamp = 0;
......
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
......@@ -26,8 +26,8 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Poin
public class SimpleQoIBasedImpactFunction<T extends PointInformation> extends AbstractQoIBasedImpactFunction<T> {
public SimpleQoIBasedImpactFunction(List<T> pInformation, double pAccuracy) {
super(pInformation, pAccuracy);
public SimpleQoIBasedImpactFunction(List<T> pInformation, double pAccuracy, int pCacheSize) {
super(pInformation, pAccuracy, pCacheSize);
}
@Override
......
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
......@@ -29,10 +29,11 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Poin
public class VectoralQoIBasedImpactFunction<T extends PointInformation> extends AbstractQoIBasedImpactFunction<T> {
private static final double MIN_STEP = 0.00001;
private static final double MIN_STEP = 0.0001;
public VectoralQoIBasedImpactFunction(List<T> pInformation, double pAccuracy, Object pLastDecision) {
super(pInformation, pAccuracy, pLastDecision);
public VectoralQoIBasedImpactFunction(List<T> pInformation, double pAccuracy, int pMaxCacheSize,
Object pLastDecision) {
super(pInformation, pAccuracy, pMaxCacheSize, pLastDecision);
}
@Override
......@@ -139,7 +140,7 @@ public class VectoralQoIBasedImpactFunction<T extends PointInformation> extends
double rate, double errorProbability, double pNumberOfMessages, double b) {
VectoralProperty currentProperty = null;
for (int a = optimalMessageAmount + 1; a <= pNumberOfMessages; a++) {
for (int a = optimalMessageAmount + 1; a <= Math.min(pNumberOfMessages, maxCacheSize); a++) {
VectoralProperty jamProperty = pTemplate.clone();
if (_lastDecision != null) {
......@@ -167,7 +168,7 @@ public class VectoralQoIBasedImpactFunction<T extends PointInformation> extends
}
}
for (int a = 0; a <= optimalMessageAmount; a++) {
for (int a = 0; a <= Math.min(optimalMessageAmount, maxCacheSize); a++) {
VectoralProperty jamProperty = pTemplate.clone();
jamProperty.setGaussianWithAccuracy(pNewValue, accuracy);
......
......@@ -261,6 +261,11 @@ public class RoadNetworkEdge {
return laneShapes;
}
@Override
public int hashCode() {
return _edgeID.hashCode();
}
public boolean isJammed() {
for (RoadProperty roadProperty : _activeProperties) {
if (roadProperty instanceof JamProperty) {
......
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