Commit 8e78f5af authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Finshed offlaoding

parent 863a0954
...@@ -49,7 +49,7 @@ public enum PhyType { ...@@ -49,7 +49,7 @@ public enum PhyType {
* (LinkLayer might add retransmission behavior as in 802.11), 5MBit/s netto * (LinkLayer might add retransmission behavior as in 802.11), 5MBit/s netto
* (802.11b) BW, 500us latency, 2,2kB MTU, Broadcast * (802.11b) BW, 500us latency, 2,2kB MTU, Broadcast
*/ */
WIFI(NetInterfaceName.WIFI, 0.01, 5 * Rate.Mbit_s, 500 * Time.MICROSECOND, WIFI(NetInterfaceName.WIFI, 0.01, 12 * Rate.Mbit_s, 500 * Time.MICROSECOND,
2334, true), 2334, true),
/** /**
* A wired connection based on a TopologyView * A wired connection based on a TopologyView
......
...@@ -145,6 +145,8 @@ public class DefaultConfigurator implements Configurator { ...@@ -145,6 +145,8 @@ public class DefaultConfigurator implements Configurator {
private Map<String, String> variables = new LinkedHashMap<String, String>(); private Map<String, String> variables = new LinkedHashMap<String, String>();
private boolean _parseOnly = false;
/** /**
* Create new configurator instance with the configuration data in the given * Create new configurator instance with the configuration data in the given
* XML file. * XML file.
...@@ -199,6 +201,13 @@ public class DefaultConfigurator implements Configurator { ...@@ -199,6 +201,13 @@ public class DefaultConfigurator implements Configurator {
} }
} }
public Map<String, String> parseAllDefaults() throws ConfigurationException {
_parseOnly = true;
configureAll();
_parseOnly = false;
return getVariables();
}
/** /**
* Configure all components of the simulator. The single components are * Configure all components of the simulator. The single components are
* either registered via the <code>register(name, component)</code> method * either registered via the <code>register(name, component)</code> method
...@@ -273,10 +282,12 @@ public class DefaultConfigurator implements Configurator { ...@@ -273,10 +282,12 @@ public class DefaultConfigurator implements Configurator {
} else if (elem.getName().equals(Configurator.DEFAULT_TAG)) { } else if (elem.getName().equals(Configurator.DEFAULT_TAG)) {
configureDefaults(elem); configureDefaults(elem);
} else { } else {
if (!_parseOnly) {
configureComponent(elem); configureComponent(elem);
} }
} }
} }
}
/** /**
* Processes a <code><Default></code> Tag by setting the respective * Processes a <code><Default></code> Tag by setting the respective
......
...@@ -416,8 +416,11 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi ...@@ -416,8 +416,11 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
@Override @Override
public String getNodeDescription() { public String getNodeDescription() {
if (getHost().getId().value() > 47) {
return " " + getHost().getId(); return " " + getHost().getId();
} }
return "";
}
@Override @Override
public int getNodeColorDimensions() { public int getNodeColorDimensions() {
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
package de.tud.kom.p2psim.impl.vehicular.decision; package de.tud.kom.p2psim.impl.vehicular.decision;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Event; import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler; import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
...@@ -27,6 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Monitor; ...@@ -27,6 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Time; 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.core.MonitorComponent.AnalyzerNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.AnalyzerNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.EnvironmentSensor;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.Environment;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleDecisionComponent; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleDecisionComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.CachingComponent; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.CachingComponent;
...@@ -45,6 +49,8 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio ...@@ -45,6 +49,8 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
private boolean _routeAnalyzerInit = false; private boolean _routeAnalyzerInit = false;
private VehicleRouteAnalyzer _routeAnalyzer = null; private VehicleRouteAnalyzer _routeAnalyzer = null;
private EnvironmentSensor _sensors;
public AbstractVehicleDecisionComponent(Host pHost) { public AbstractVehicleDecisionComponent(Host pHost) {
_host = pHost; _host = pHost;
} }
...@@ -53,6 +59,7 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio ...@@ -53,6 +59,7 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
public void initialize() { public void initialize() {
try { try {
_cache = getHost().getComponent(CachingComponent.class); _cache = getHost().getComponent(CachingComponent.class);
_sensors = getHost().getComponent(EnvironmentSensor.class);
} catch (ComponentNotAvailableException e) { } catch (ComponentNotAvailableException e) {
throw new AssertionError(e); throw new AssertionError(e);
} }
...@@ -90,11 +97,11 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio ...@@ -90,11 +97,11 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
case EVENT_DECISION_MAKING_CYCLE: case EVENT_DECISION_MAKING_CYCLE:
RoadNetworkRoute currentRoute = getVehicleInformation().getCurrentRoute(); RoadNetworkRoute currentRoute = getVehicleInformation().getCurrentRoute();
if (currentRoute != null && currentRoute.getRoute().size() > 2) { if (currentRoute != null) {
boolean changed = false; boolean changed = false;
if (currentRoute.getRoute().size() > 2) {
BenefitBasedRoute optimalRouteWithBenefit = getOptimalRoute(currentRoute, BenefitBasedRoute optimalRouteWithBenefit = getOptimalRoute(currentRoute,
_cache.getDecidedCacheEntries(RoadInformation.class)); _cache.getDecidedCacheEntries(RoadInformation.class), _sensors.getEnvironment());
if (optimalRouteWithBenefit != null) { if (optimalRouteWithBenefit != null) {
RoadNetworkRoute optimalRoute = optimalRouteWithBenefit.getRoute(); RoadNetworkRoute optimalRoute = optimalRouteWithBenefit.getRoute();
if (optimalRouteWithBenefit.getRoute().getRoute().size() > 1) { if (optimalRouteWithBenefit.getRoute().getRoute().size() > 1) {
...@@ -107,11 +114,9 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio ...@@ -107,11 +114,9 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
} }
} }
} }
if (!changed) {
if (hasRouteAnalyzer()) {
getRouteAnalyzer().routeUnchanged(getHost().getId(), currentRoute);
} }
if (!changed && hasRouteAnalyzer()) {
getRouteAnalyzer().routeUnchanged(getHost().getId(), currentRoute);
} }
} }
......
...@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.impl.vehicular.decision; ...@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.impl.vehicular.decision;
import java.util.List; import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
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.RoadNetworkRoute; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
......
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.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.tud.kom.p2psim.impl.vehicular.decision;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
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.RoadNetworkRoute;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing.DijkstraAlgorithm;
public class LatestPossibleVehicleDecisionComponent extends AbstractVehicleDecisionComponent {
public LatestPossibleVehicleDecisionComponent(Host pHost) {
super(pHost);
}
@Override
public BenefitBasedRoute getOptimalRoute(RoadNetworkRoute pInvestigatedRoute, List<RoadInformation> knownInformation) {
List<RoadInformation> actualKnownInformation = new ArrayList<>();
if (getVehicleInformation().isValid() && knownInformation != null) {
for (RoadInformation roadInformation : knownInformation) {
RoadProperty property = roadInformation.getValue();
if (!property.getValue().equals(property.getDefaultProperty().getValue())) {
if (pInvestigatedRoute.getStart().getAccessibleEdges().contains(roadInformation.getEdge())) {
actualKnownInformation.add(roadInformation);
}
}
}
DijkstraAlgorithm dijkstraAlgorithm = new DijkstraAlgorithm();
List<RoadNetworkEdge> blocked = new ArrayList<>();
for (RoadInformation roadInformation : actualKnownInformation) {
if (!blocked.contains(roadInformation.getEdge())) {
blocked.add(roadInformation.getEdge());
}
}
RoadNetworkRoute route = dijkstraAlgorithm.findRoute(RoadNetwork.CURRENT_ROAD_NETWORK, getVehicleInformation().getCurrentRoute().getStart(), getVehicleInformation().getCurrentRoute().getDestination(), Collections.emptyList(), blocked);
if (route != null) {
double oldCosts = 0;
for (RoadNetworkEdge edge : pInvestigatedRoute.getRoute()) {
oldCosts += edge.calculateStandardEdgeCosts();
if (knownInformation != null) {
for (RoadInformation roadInformation : actualKnownInformation) {
oldCosts += edge.calculateAdditionalCostIfKnown(roadInformation.getValue());
}
}
}
double newCosts = 0;
for (RoadNetworkEdge edge : route.getRoute()) {
newCosts += edge.calculateStandardEdgeCosts();
if (knownInformation != null) {
for (RoadInformation roadInformation : actualKnownInformation) {
newCosts += edge.calculateAdditionalCostIfKnown(roadInformation.getValue());
}
}
}
if (oldCosts > newCosts) {
return new BenefitBasedRoute(oldCosts - newCosts, route);
}
}
return new BenefitBasedRoute(0, pInvestigatedRoute);
}
return null;
}
}
...@@ -25,6 +25,7 @@ import java.util.Collections; ...@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.Environment;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
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.RoadNetwork;
...@@ -39,24 +40,34 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision ...@@ -39,24 +40,34 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision
} }
@Override @Override
public BenefitBasedRoute getOptimalRoute(RoadNetworkRoute pInvestigatedRoute, List<RoadInformation> knownInformation) { public BenefitBasedRoute getOptimalRoute(RoadNetworkRoute pInvestigatedRoute,
List<RoadInformation> actualKnownInformation = new ArrayList<>(); List<RoadInformation> pKnownInformation) {
return new BenefitBasedRoute(0, pInvestigatedRoute);
}
@Override
public BenefitBasedRoute getOptimalRoute(RoadNetworkRoute pInvestigatedRoute, List<RoadInformation> knownInformation, Environment pEnvironment) {
List<RoadProperty> actualKnownInformation = new ArrayList<>();
if (getVehicleInformation().isValid() && knownInformation != null) { if (getVehicleInformation().isValid()) {
if (knownInformation != null) {
for (RoadInformation roadInformation : knownInformation) { for (RoadInformation roadInformation : knownInformation) {
RoadProperty property = roadInformation.getValue(); RoadProperty property = roadInformation.getValue();
if (!property.getValue().equals(property.getDefaultProperty().getValue())) { if (!property.getValue().equals(property.getDefaultProperty().getValue())) {
if (pInvestigatedRoute.getStart().getAccessibleEdges().contains(roadInformation.getEdge())) { if (pInvestigatedRoute.getStart().getAccessibleEdges().contains(roadInformation.getEdge())) {
actualKnownInformation.add(roadInformation); actualKnownInformation.add(roadInformation.getValue());
}
} }
} }
} }
actualKnownInformation.addAll(pEnvironment.getProperties(RoadProperty.class));
DijkstraAlgorithm dijkstraAlgorithm = new DijkstraAlgorithm(); DijkstraAlgorithm dijkstraAlgorithm = new DijkstraAlgorithm();
List<RoadNetworkEdge> blocked = new ArrayList<>(); List<RoadNetworkEdge> blocked = new ArrayList<>();
for (RoadInformation roadInformation : actualKnownInformation) { for (RoadProperty roadInformation : actualKnownInformation) {
if (!blocked.contains(roadInformation.getEdge())) { if (!blocked.contains(roadInformation.getEdge()) && roadInformation.getEdge().isActive()) {
blocked.add(roadInformation.getEdge()); blocked.add(roadInformation.getEdge());
} }
} }
...@@ -66,20 +77,16 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision ...@@ -66,20 +77,16 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision
double oldCosts = 0; double oldCosts = 0;
for (RoadNetworkEdge edge : pInvestigatedRoute.getRoute()) { for (RoadNetworkEdge edge : pInvestigatedRoute.getRoute()) {
oldCosts += edge.calculateStandardEdgeCosts(); oldCosts += edge.calculateStandardEdgeCosts();
if (knownInformation != null) { for (RoadProperty roadInformation : actualKnownInformation) {
for (RoadInformation roadInformation : actualKnownInformation) { oldCosts += edge.calculateAdditionalCostIfKnown(roadInformation);
oldCosts += edge.calculateAdditionalCostIfKnown(roadInformation.getValue());
}
} }
} }
double newCosts = 0; double newCosts = 0;
for (RoadNetworkEdge edge : route.getRoute()) { for (RoadNetworkEdge edge : route.getRoute()) {
newCosts += edge.calculateStandardEdgeCosts(); newCosts += edge.calculateStandardEdgeCosts();
if (knownInformation != null) { for (RoadProperty roadInformation : actualKnownInformation) {
for (RoadInformation roadInformation : actualKnownInformation) { newCosts += edge.calculateAdditionalCostIfKnown(roadInformation);
newCosts += edge.calculateAdditionalCostIfKnown(roadInformation.getValue());
}
} }
} }
......
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