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
API
Commits
18180bef
Commit
18180bef
authored
May 20, 2019
by
Tobias Meuser
Browse files
Renamed property benefit/cost to property impact
parent
11bd32e1
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/
Default
VehicularProperty
Cos
tEstimator.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/
Configurable
VehicularProperty
Impac
tEstimator.java
View file @
18180bef
...
...
@@ -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
calculate
Costs
IfKnown
(
Class
<?
extends
RoadProperty
>
pProperty
)
{
public
double
calculate
Impact
IfKnown
(
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
calculate
Costs
IfKnown
(
Notification
pNotification
)
{
public
double
calculate
Impact
IfKnown
(
Notification
pNotification
)
{
EnvironmentInformation
<?
extends
LocationBasedEnvironmentProperty
>
environmentInformation
=
EnvironmentInformation
.
createFromNotification
(
pNotification
);
if
(
environmentInformation
instanceof
RoadInformation
)
{
return
calculate
Costs
IfKnown
(((
RoadInformation
)
environmentInformation
).
getValue
());
return
calculate
Impact
IfKnown
(((
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
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/DefaultVehicularPropertyImpactEstimator.java
0 → 100755
View file @
18180bef
/*
* 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
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/Property
Benefi
tEstimator.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/Property
Impac
tEstimator.java
View file @
18180bef
...
...
@@ -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
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/PropertyImpactEstimatorFactory.java
0 → 100755
View file @
18180bef
/*
* 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
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/Property
Benefi
tEstimator
Factory
.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/
Vehicular
Property
Impac
tEstimator.java
View file @
18180bef
...
...
@@ -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
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/JamPropertyGenerator.java
View file @
18180bef
...
...
@@ -20,8 +20,8 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.generator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.Property
Benefi
tEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularProperty
Cos
tEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.Property
Impac
tEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularProperty
Impac
tEstimator
;
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
=
((
VehicularProperty
Cos
tEstimator
)
Property
Benefi
tEstimatorFactory
.
getPropertyBenefitEstimator
()).
calculate
Costs
IfKnown
(
JamProperty
.
class
)
+
travelTime
;
double
newTravelTime
=
((
VehicularProperty
Impac
tEstimator
)
Property
Impac
tEstimatorFactory
.
getPropertyBenefitEstimator
()).
calculate
Impact
IfKnown
(
JamProperty
.
class
)
+
travelTime
;
double
newSpeed
=
pEdge
.
getLength
()
/
newTravelTime
;
return
new
JamProperty
(
pLocation
,
pEdge
,
true
,
newSpeed
);
}
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/VehicleDecisionStrategyType.java
View file @
18180bef
...
...
@@ -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
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/RoadNetworkEdge.java
View file @
18180bef
...
...
@@ -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.Property
Benefi
tEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.Property
Benefi
tEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularProperty
Cos
tEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.Property
Impac
tEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.Property
Impac
tEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularProperty
Impac
tEstimator
;
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
))
{
Property
Benefi
tEstimator
benefitEstimator
=
Property
Benefi
tEstimatorFactory
Property
Impac
tEstimator
benefitEstimator
=
Property
Impac
tEstimatorFactory
.
getPropertyBenefitEstimator
();
if
(
benefitEstimator
instanceof
VehicularProperty
Cos
tEstimator
)
{
additionalCost
=
((
VehicularProperty
Cos
tEstimator
)
benefitEstimator
)
.
calculate
Costs
IfKnown
(
pProperty
);
if
(
benefitEstimator
instanceof
VehicularProperty
Impac
tEstimator
)
{
additionalCost
=
((
VehicularProperty
Impac
tEstimator
)
benefitEstimator
)
.
calculate
Impact
IfKnown
(
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
))
{
Property
Benefi
tEstimator
benefitEstimator
=
Property
Benefi
tEstimatorFactory
Property
Impac
tEstimator
benefitEstimator
=
Property
Impac
tEstimatorFactory
.
getPropertyBenefitEstimator
();
if
(
benefitEstimator
instanceof
VehicularProperty
Cos
tEstimator
)
{
additionalCosts
=
((
VehicularProperty
Cos
tEstimator
)
benefitEstimator
)
.
calculate
Costs
IfUnknown
(
pProperty
);
if
(
benefitEstimator
instanceof
VehicularProperty
Impac
tEstimator
)
{
additionalCosts
=
((
VehicularProperty
Impac
tEstimator
)
benefitEstimator
)
.
calculate
Impact
IfUnknown
(
pProperty
);
}
else
{
throw
new
AssertionError
(
"VehicularPropertyCostEstimator required!"
);
}
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/RoadNetworkRoute.java
View file @
18180bef
...
...
@@ -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
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/
sensor/environment/costs/VehicularPropertyCostEstimator
.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/
vehicular/roadnetwork/routing/LatestPossibleDijkstraAlgorithm
.java
View file @
18180bef
...
...
@@ -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
,
R
oad
N
etworkRo
ute
pPath
)
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.r
oad
n
etwork
.
Ro
adNetworkEdge
;
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
0
d
;
}
double
calculateCostsIfUnknown
(
Class
<?
extends
RoadProperty
>
pProperty
);
double
calculateCostsIfUnknown
(
RoadProperty
pProperty
,
RoadNetworkEdge
pDecisionPoint
,
VehicleCostPreference
pVehicle
,
RoadNetworkRoute
pPath
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/subscriptions/topic/CostBasedTopic.java
View file @
18180bef
...
...
@@ -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.Property
Benefi
tEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.Property
Benefi
tEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularProperty
Cos
tEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.Property
Impac
tEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.Property
Impac
tEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.costs.VehicularProperty
Impac
tEstimator
;
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
;
Property
Benefi
tEstimator
costEstimator
=
Property
Benefi
tEstimatorFactory
.
getPropertyBenefitEstimator
();
double
costsForMissingInformation
=
((
VehicularProperty
Cos
tEstimator
)
costEstimator
)
.
calculate
Costs
IfUnknown
(
roadInfo
.
getValue
());
Property
Impac
tEstimator
costEstimator
=
Property
Impac
tEstimatorFactory
.
getPropertyBenefitEstimator
();
double
costsForMissingInformation
=
((
VehicularProperty
Impac
tEstimator
)
costEstimator
)
.
calculate
Impact
IfUnknown
(
roadInfo
.
getValue
());
if
(
costsForMissingInformation
>=
_costs
)
{
return
true
;
...
...
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