Commit 18180bef authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Renamed property benefit/cost to property impact

parent 11bd32e1
......@@ -20,12 +20,6 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.BumpProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.FogProperty;
......@@ -37,22 +31,11 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.pr
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.TrafficSignProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.EnvironmentInformation;
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.paths.VehiclePathTracker;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.paths.VehiclePathTrackerFactory;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing.DijkstraAlgorithm;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing.RoutingAlgorithm;
public class DefaultVehicularPropertyCostEstimator implements VehicularPropertyCostEstimator {
private static final int MAX_DETOUR = 3;
private RoutingAlgorithm routing = new DijkstraAlgorithm();
public class ConfigurableVehicularPropertyImpactEstimator implements VehicularPropertyImpactEstimator {
@Override
public double calculateCostsIfKnown(Class<? extends RoadProperty> pProperty) {
public double calculateImpactIfKnown(Class<? extends RoadProperty> pProperty) {
if (pProperty.equals(JamProperty.class)) {
return 3 * Math.pow(10, 2);
} else if (pProperty.equals(RainProperty.class)) {
......@@ -68,108 +51,31 @@ public class DefaultVehicularPropertyCostEstimator implements VehicularPropertyC
}
@Override
public double calculateCostsIfKnown(Notification pNotification) {
public double calculateImpactIfKnown(Notification pNotification) {
EnvironmentInformation<? extends LocationBasedEnvironmentProperty> environmentInformation = EnvironmentInformation
.createFromNotification(pNotification);
if (environmentInformation instanceof RoadInformation) {
return calculateCostsIfKnown(((RoadInformation) environmentInformation).getValue());
return calculateImpactIfKnown(((RoadInformation) environmentInformation).getValue());
}
throw new AssertionError("Cost calculation only valid for road information!");
}
@Override
public List<DecisionPoint> getDecisionPoints(Notification pNotification) {
public double calculateImpactIfUnknown(Notification pNotification) {
EnvironmentInformation<? extends LocationBasedEnvironmentProperty> environmentInformation = EnvironmentInformation
.createFromNotification(pNotification);
if (environmentInformation instanceof RoadInformation) {
RoadInformation roadInformation = (RoadInformation) environmentInformation;
List<DecisionPoint> decisionPoints = new ArrayList<>();
decisionPoints.add(new VehicularDecisionPoint(roadInformation.getEdge(), roadInformation.getLocation(),
calculateCostsIfKnown(roadInformation.getValue())));
if (roadInformation.getValue().isDetourable()) {
Set<RoadNetworkEdge> edges = new HashSet<>();
edges.add(roadInformation.getEdge());
for (int i = 0; i < MAX_DETOUR; i++) {
Set<RoadNetworkEdge> newEdges = new HashSet<>();
for (RoadNetworkEdge roadNetworkEdge : edges) {
newEdges.addAll(roadNetworkEdge.getIncomingEdges());
}
edges.addAll(newEdges);
}
for (RoadNetworkEdge roadNetworkEdge : edges) {
decisionPoints.add(new VehicularDetouringDecisionPoint(roadNetworkEdge, roadInformation.getEdge(),
roadInformation.getLocation(), calculateCostsIfKnown(roadInformation.getValue())));
}
}
return decisionPoints;
return calculateImpactIfUnknown(((RoadInformation) environmentInformation).getValue());
}
throw new AssertionError("Cost calculation only valid for road information!");
}
@Override
public double calculateCostsIfKnown(RoadProperty pProperty, RoadNetworkEdge pDecisionPoint,
VehicleCostPreference pVehicle, RoadNetworkRoute pPath) {
VehiclePathTracker tracker = VehiclePathTrackerFactory.getVehiclePathTracker();
if (pPath.containsEdge(pDecisionPoint) && pPath.containsEdge(pProperty.getEdge())) {
if (pPath.getStart().equals(pProperty.getEdge())) {
return calculateCostsIfKnown(pProperty);
}
if (pProperty.isDetourable()) {
// Find other route...
List<RoadNetworkEdge> edgesToAvoid = new ArrayList<>();
edgesToAvoid.add(pProperty.getEdge());
RoadNetworkRoute route = routing.findRoute(RoadNetwork.CURRENT_ROAD_NETWORK, pPath.getStart(),
pPath.getDestination(), Collections.emptyList(), edgesToAvoid);
if (route != null) {
double newRouteTravelTime = route.getTravelTime();
double routeTravelTime = pPath.getTravelTime();
boolean found = false;
for (int i = 0; i < pPath.getRoute().size() - 1; i++) {
if (pPath.getRoute().get(i).equals(pProperty.getEdge())) {
routeTravelTime -= tracker.getTravelTime(pPath.getRoute().get(i),
pPath.getRoute().get(i + 1));
found = true;
}
}
if (found) {
routeTravelTime += (pProperty.getEdge().getLength() / pProperty.getEdge().getMaxSpeed());
}
if (routeTravelTime > newRouteTravelTime) {
return calculateCostsIfKnown(pProperty) + (routeTravelTime - newRouteTravelTime) * 10;
}
}
}
}
return calculateCostsIfKnown(pProperty);
}
@Override
public double calculateCostsIfUnknown(Notification pNotification) {
EnvironmentInformation<? extends LocationBasedEnvironmentProperty> environmentInformation = EnvironmentInformation
.createFromNotification(pNotification);
if (environmentInformation instanceof RoadInformation) {
return calculateCostsIfUnknown(((RoadInformation) environmentInformation).getValue());
}
throw new AssertionError("Cost calculation only valid for road information!");
}
@Override
public double calculateCostsIfUnknown(Class<? extends RoadProperty> pProperty) {
public double calculateImpactIfUnknown(Class<? extends RoadProperty> pProperty) {
if (pProperty.equals(JamProperty.class)) {
return Math.pow(10, 4);
} else if (pProperty.equals(BumpProperty.class)) {
......@@ -180,10 +86,4 @@ public class DefaultVehicularPropertyCostEstimator implements VehicularPropertyC
return 1;
}
@Override
public double calculateCostsIfUnknown(RoadProperty pProperty, RoadNetworkEdge pDecisionPoint,
VehicleCostPreference pVehicle, RoadNetworkRoute pPath) {
return 0;
}
}
/*
* 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.sensor.environment.costs;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.BumpProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.FogProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.HazardProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.JamProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.LocationBasedEnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RainProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.TrafficSignProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.EnvironmentInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation;
public class DefaultVehicularPropertyImpactEstimator implements VehicularPropertyImpactEstimator {
@Override
public double calculateImpactIfKnown(Class<? extends RoadProperty> pProperty) {
if (pProperty.equals(JamProperty.class)) {
return 3 * Math.pow(10, 2);
} else if (pProperty.equals(RainProperty.class)) {
return 1;
} else if (pProperty.equals(FogProperty.class)) {
return 1;
} else if (pProperty.equals(HazardProperty.class)) {
return Math.pow(10, 3);
} else if (pProperty.equals(TrafficSignProperty.class)) {
return 10;
}
return 10;
}
@Override
public double calculateImpactIfKnown(Notification pNotification) {
EnvironmentInformation<? extends LocationBasedEnvironmentProperty> environmentInformation = EnvironmentInformation
.createFromNotification(pNotification);
if (environmentInformation instanceof RoadInformation) {
return calculateImpactIfKnown(((RoadInformation) environmentInformation).getValue());
}
throw new AssertionError("Cost calculation only valid for road information!");
}
@Override
public double calculateImpactIfUnknown(Notification pNotification) {
EnvironmentInformation<? extends LocationBasedEnvironmentProperty> environmentInformation = EnvironmentInformation
.createFromNotification(pNotification);
if (environmentInformation instanceof RoadInformation) {
return calculateImpactIfUnknown(((RoadInformation) environmentInformation).getValue());
}
throw new AssertionError("Cost calculation only valid for road information!");
}
@Override
public double calculateImpactIfUnknown(Class<? extends RoadProperty> pProperty) {
if (pProperty.equals(JamProperty.class)) {
return Math.pow(10, 4);
} else if (pProperty.equals(BumpProperty.class)) {
return Math.pow(10, -2);
} else if (pProperty.equals(HazardProperty.class)) {
return Math.pow(10, 6);
}
return 1;
}
}
......@@ -20,14 +20,10 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification;
public interface PropertyBenefitEstimator {
double calculateCostsIfKnown(Notification pNotification);
double calculateCostsIfUnknown(Notification pNotification);
public interface PropertyImpactEstimator {
double calculateImpactIfKnown(Notification pNotification);
List<DecisionPoint> getDecisionPoints(Notification pNotification);
double calculateImpactIfUnknown(Notification pNotification);
}
/*
* 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.sensor.environment.costs;
public class PropertyImpactEstimatorFactory {
private static PropertyImpactEstimator _costEstimator = null;
public void registerPropertyBenefitEstimator(PropertyImpactEstimator pBenefitEstimator) {
synchronized (PropertyImpactEstimatorFactory.class) {
_costEstimator = pBenefitEstimator;
}
}
public static PropertyImpactEstimator getPropertyBenefitEstimator() {
synchronized (PropertyImpactEstimatorFactory.class) {
if (_costEstimator == null) {
System.err.println("No property impact estimator set! Falling back to "
+ DefaultVehicularPropertyImpactEstimator.class.getSimpleName());
_costEstimator = new DefaultVehicularPropertyImpactEstimator();
}
}
return _costEstimator;
}
}
......@@ -20,10 +20,18 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs;
public class PropertyBenefitEstimatorFactory {
private static DefaultVehicularPropertyCostEstimator _costEstimator = new DefaultVehicularPropertyCostEstimator();
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
public static PropertyBenefitEstimator getPropertyBenefitEstimator() {
return _costEstimator;
public interface VehicularPropertyImpactEstimator extends PropertyImpactEstimator {
default double calculateImpactIfKnown(RoadProperty pProperty) {
return calculateImpactIfKnown(pProperty.getClass());
}
double calculateImpactIfKnown(Class<? extends RoadProperty> pProperty);
default double calculateImpactIfUnknown(RoadProperty pProperty) {
return calculateImpactIfUnknown(pProperty.getClass());
}
double calculateImpactIfUnknown(Class<? extends RoadProperty> pProperty);
}
......@@ -20,8 +20,8 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyBenefitEstimatorFactory;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularPropertyCostEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyImpactEstimatorFactory;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularPropertyImpactEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.JamProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
......@@ -32,8 +32,8 @@ public class JamPropertyGenerator implements RoadPropertyGenerator {
@Override
public RoadProperty generateProperty(Location pLocation, RoadNetworkEdge pEdge) {
double travelTime = (pEdge.getLength() / pEdge.getMaxSpeed());
double newTravelTime = ((VehicularPropertyCostEstimator) PropertyBenefitEstimatorFactory
.getPropertyBenefitEstimator()).calculateCostsIfKnown(JamProperty.class) + travelTime;
double newTravelTime = ((VehicularPropertyImpactEstimator) PropertyImpactEstimatorFactory
.getPropertyBenefitEstimator()).calculateImpactIfKnown(JamProperty.class) + travelTime;
double newSpeed = pEdge.getLength() / newTravelTime;
return new JamProperty(pLocation, pEdge, true, newSpeed);
}
......
......@@ -21,5 +21,5 @@
package de.tudarmstadt.maki.simonstrator.api.component.vehicular;
public enum VehicleDecisionStrategyType {
NONE, DUMMY, VISION_ONLY, STATIC_INFO, DYNAMIC_INFO, COMBINED_INFO, OPTIMAL
NONE, DUMMY, VISION_ONLY, STATIC_INFO, DYNAMIC_INFO, COMBINED_INFO, OPTIMAL, LATEST
}
......@@ -24,9 +24,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyBenefitEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyBenefitEstimatorFactory;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularPropertyCostEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyImpactEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyImpactEstimatorFactory;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularPropertyImpactEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.HazardProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.JamProperty;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
......@@ -36,6 +36,8 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.EdgeControll
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.paths.VehiclePathTrackerFactory;
public class RoadNetworkEdge {
private static final boolean ENABLE_SPEED_ADAPTATION = false;
private String _edgeID;
private double _angle;
......@@ -95,20 +97,22 @@ public class RoadNetworkEdge {
}
private void adjustMaxSpeed() {
double maxSpeed = getOriginalMaxSpeed();
for (RoadProperty roadProperty : _activeProperties) {
if (roadProperty instanceof JamProperty) {
if (((JamProperty) roadProperty).getAverageSpeed() < maxSpeed) {
maxSpeed = ((JamProperty) roadProperty).getAverageSpeed();
}
} else if (roadProperty instanceof HazardProperty) {
if (0.001 < maxSpeed) {
maxSpeed = 0.001;
if (ENABLE_SPEED_ADAPTATION) {
double maxSpeed = getOriginalMaxSpeed();
for (RoadProperty roadProperty : _activeProperties) {
if (roadProperty instanceof JamProperty) {
if (((JamProperty) roadProperty).getAverageSpeed() < maxSpeed) {
maxSpeed = ((JamProperty) roadProperty).getAverageSpeed();
}
} else if (roadProperty instanceof HazardProperty) {
if (0.001 < maxSpeed) {
maxSpeed = 0.001;
}
}
}
}
changeEdgeMaxSpeed(maxSpeed);
changeEdgeMaxSpeed(maxSpeed);
}
}
/**
......@@ -330,6 +334,10 @@ public class RoadNetworkEdge {
}
public double calculateStandardEdgeCosts() {
return calculateStandardDrivingDuration();
}
public double calculateStandardDrivingDuration() {
return VehiclePathTrackerFactory.getVehiclePathTracker().getTravelTime(this);
}
......@@ -345,11 +353,11 @@ public class RoadNetworkEdge {
if (pProperty != null && pProperty.getDefaultProperty() != null
&& !propertyEquals(pProperty, pProperty.getDefaultProperty())) {
if (pProperty.getEdge().equals(this)) {
PropertyBenefitEstimator benefitEstimator = PropertyBenefitEstimatorFactory
PropertyImpactEstimator benefitEstimator = PropertyImpactEstimatorFactory
.getPropertyBenefitEstimator();
if (benefitEstimator instanceof VehicularPropertyCostEstimator) {
additionalCost = ((VehicularPropertyCostEstimator) benefitEstimator)
.calculateCostsIfKnown(pProperty);
if (benefitEstimator instanceof VehicularPropertyImpactEstimator) {
additionalCost = ((VehicularPropertyImpactEstimator) benefitEstimator)
.calculateImpactIfKnown(pProperty);
} else {
throw new AssertionError("VehicularPropertyCostEstimator required!");
}
......@@ -368,11 +376,11 @@ public class RoadNetworkEdge {
double additionalCosts = 0;
if (pProperty != null && !propertyEquals(pProperty, pProperty.getDefaultProperty())) {
if (pProperty.getEdge().equals(this)) {
PropertyBenefitEstimator benefitEstimator = PropertyBenefitEstimatorFactory
PropertyImpactEstimator benefitEstimator = PropertyImpactEstimatorFactory
.getPropertyBenefitEstimator();
if (benefitEstimator instanceof VehicularPropertyCostEstimator) {
additionalCosts = ((VehicularPropertyCostEstimator) benefitEstimator)
.calculateCostsIfUnknown(pProperty);
if (benefitEstimator instanceof VehicularPropertyImpactEstimator) {
additionalCosts = ((VehicularPropertyImpactEstimator) benefitEstimator)
.calculateImpactIfUnknown(pProperty);
} else {
throw new AssertionError("VehicularPropertyCostEstimator required!");
}
......
......@@ -155,4 +155,16 @@ public class RoadNetworkRoute implements Iterable<RoadNetworkEdge> {
}
return sum;
}
public double calculateDrivingDurationTo(RoadNetworkEdge pDestination) {
double sum = 0;
for (int i = 1; i < _route.size(); i++) {
if (!_route.get(i).equals(pDestination)) {
sum += _route.get(i).calculateStandardEdgeCosts();
} else {
break;
}
}
return sum;
}
}
......@@ -18,29 +18,26 @@
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs;
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
public interface VehicularPropertyCostEstimator extends PropertyBenefitEstimator {
default double calculateCostsIfKnown(RoadProperty pProperty) {
return calculateCostsIfKnown(pProperty.getClass());
}
double calculateCostsIfKnown(Class<? extends RoadProperty> pProperty);
import java.util.List;
double calculateCostsIfKnown(RoadProperty pProperty, RoadNetworkEdge pDecisionPoint, VehicleCostPreference pVehicle,
RoadNetworkRoute pPath);
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
default double calculateCostsIfUnknown(RoadProperty pProperty) {
return calculateCostsIfUnknown(pProperty.getClass());
public class LatestPossibleDijkstraAlgorithm extends DijkstraAlgorithm {
protected double calculateAdditionalEdgeCosts(RoadNetworkEdge pEdge, List<RoadInformation> pInfo,
double pCurrentPathLength, List<RoadNetworkEdge> pCurrentRouteList) {
if (pInfo != null && pCurrentRouteList.size() > 0) {
for (RoadInformation roadInformation : pInfo) {
if (pCurrentRouteList.get(0).equals(roadInformation.getEdge())
|| pCurrentRouteList.get(0).getAccessibleEdges().contains(roadInformation.getEdge())) {
double additionalCostIfKnown = pEdge.calculateAdditionalCostIfKnown(roadInformation.getValue());
return additionalCostIfKnown;
}
}
}
return 0d;
}
double calculateCostsIfUnknown(Class<? extends RoadProperty> pProperty);
double calculateCostsIfUnknown(RoadProperty pProperty, RoadNetworkEdge pDecisionPoint,
VehicleCostPreference pVehicle, RoadNetworkRoute pPath);
}
......@@ -5,9 +5,9 @@ import java.util.regex.Pattern;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.PubSubComponent;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyBenefitEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyBenefitEstimatorFactory;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularPropertyCostEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyImpactEstimator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.PropertyImpactEstimatorFactory;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularPropertyImpactEstimator;
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.subscriptions.SubscriptionTopicType;
......@@ -45,9 +45,9 @@ public class CostBasedTopic implements ProcessedTopic, Comparable<CostBasedTopic
public boolean matchesInformationRequirements(PointInformation<?> pInformation) {
if (pInformation instanceof RoadInformation) {
RoadInformation roadInfo = (RoadInformation) pInformation;
PropertyBenefitEstimator costEstimator = PropertyBenefitEstimatorFactory.getPropertyBenefitEstimator();
double costsForMissingInformation = ((VehicularPropertyCostEstimator) costEstimator)
.calculateCostsIfUnknown(roadInfo.getValue());
PropertyImpactEstimator costEstimator = PropertyImpactEstimatorFactory.getPropertyBenefitEstimator();
double costsForMissingInformation = ((VehicularPropertyImpactEstimator) costEstimator)
.calculateImpactIfUnknown(roadInfo.getValue());
if (costsForMissingInformation >= _costs) {
return true;
......
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