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
1f25a59c
Commit
1f25a59c
authored
Nov 30, 2018
by
Tobias Meuser
Browse files
Added stuff for Dennis
parent
3c79589c
Changes
28
Show whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/path/PathPredictionComponent.java
0 → 100755
View file @
1f25a59c
package
de.tudarmstadt.maki.simonstrator.api.component.relevance.path
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
public
interface
PathPredictionComponent
extends
HostComponent
{
public
PathPredictionContainer
findPossiblePathsToDestination
(
RoadNetworkEdge
pStart
,
RoadNetworkEdge
pEnd
);
public
PathPredictionContainer
findPossiblePathsOverRoad
(
RoadNetworkEdge
pStart
,
RoadNetworkEdge
pEnd
,
int
pAdditionalDepth
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/path/PathPredictionContainer.java
0 → 100755
View file @
1f25a59c
package
de.tudarmstadt.maki.simonstrator.api.component.relevance.path
;
import
java.util.Collections
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
public
class
PathPredictionContainer
{
private
List
<
StatisticalRoadNetworkRoute
>
_paths
;
public
PathPredictionContainer
(
List
<
StatisticalRoadNetworkRoute
>
pPaths
)
{
_paths
=
pPaths
;
}
public
PathPredictionContainer
()
{
_paths
=
Collections
.
emptyList
();
}
public
List
<
StatisticalRoadNetworkRoute
>
getRoutes
()
{
return
_paths
;
}
public
void
addPath
(
RoadNetworkRoute
pPath
,
double
pProbability
,
long
pDuration
)
{
_paths
.
add
(
new
StatisticalRoadNetworkRoute
(
pPath
,
pProbability
,
pDuration
));
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/path/RoadNetworkPathComperator.java
0 → 100755
View file @
1f25a59c
package
de.tudarmstadt.maki.simonstrator.api.component.relevance.path
;
import
java.util.Comparator
;
public
class
RoadNetworkPathComperator
implements
Comparator
<
StatisticalRoadNetworkRoute
>
{
public
RoadNetworkPathComperator
()
{
}
@Override
public
int
compare
(
StatisticalRoadNetworkRoute
pPath0
,
StatisticalRoadNetworkRoute
pPath1
)
{
return
-
Double
.
compare
(
pPath0
.
getProbability
(),
pPath1
.
getProbability
());
}
}
\ No newline at end of file
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/path/StatisticalRoadNetworkRoute.java
0 → 100755
View file @
1f25a59c
package
de.tudarmstadt.maki.simonstrator.api.component.relevance.path
;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
public
class
StatisticalRoadNetworkRoute
{
private
double
probability
;
private
long
duration
;
private
RoadNetworkRoute
path
;
public
StatisticalRoadNetworkRoute
(
RoadNetworkRoute
pPath
,
double
pProbability
,
long
pDuration
)
{
path
=
pPath
;
probability
=
pProbability
;
duration
=
pDuration
;
}
public
StatisticalRoadNetworkRoute
(
RoadNetworkEdge
pEdge
,
double
pProbability
,
long
pDuration
)
{
List
<
RoadNetworkEdge
>
edges
=
new
ArrayList
<>();
edges
.
add
(
pEdge
);
path
=
new
RoadNetworkRoute
(
edges
);
probability
=
pProbability
;
duration
=
pDuration
;
}
public
long
getDuration
()
{
return
duration
;
}
public
double
getProbability
()
{
return
probability
;
}
public
RoadNetworkEdge
getCurrentEdge
()
{
return
path
.
getStart
();
}
public
RoadNetworkRoute
getPath
()
{
return
path
;
}
public
StatisticalRoadNetworkRoute
createPath
(
RoadNetworkEdge
pCurrentEdge
,
double
pProbability
,
long
pTravelTime
)
{
ArrayList
<
RoadNetworkEdge
>
newEdges
=
new
ArrayList
<>(
path
.
getRoute
());
newEdges
.
add
(
0
,
pCurrentEdge
);
return
new
StatisticalRoadNetworkRoute
(
new
RoadNetworkRoute
(
newEdges
),
getProbability
()
*
pProbability
,
getDuration
()
+
pTravelTime
);
}
public
static
StatisticalRoadNetworkRoute
append
(
StatisticalRoadNetworkRoute
pRoute
,
StatisticalRoadNetworkRoute
pToBeAppended
)
{
if
(
pRoute
.
getPath
().
getDestination
().
equals
(
pToBeAppended
.
getPath
().
getStart
()))
{
List
<
RoadNetworkEdge
>
path
=
new
ArrayList
<>(
pRoute
.
getPath
().
getRoute
());
for
(
int
i
=
1
;
i
<
pToBeAppended
.
getPath
().
getRoute
().
size
();
i
++)
{
path
.
add
(
pToBeAppended
.
getPath
().
getRoute
().
get
(
i
));
}
return
new
StatisticalRoadNetworkRoute
(
new
RoadNetworkRoute
(
path
),
pRoute
.
getProbability
()
*
pToBeAppended
.
getProbability
(),
pRoute
.
getDuration
()
+
pToBeAppended
.
getDuration
());
}
throw
new
AssertionError
(
"The two routes are not connected!"
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/AbstractRoadProperty.java
View file @
1f25a59c
...
...
@@ -113,4 +113,9 @@ public abstract class AbstractRoadProperty implements RoadProperty, AggregatedPr
}
return
false
;
}
@Override
public
boolean
isDetourable
()
{
return
false
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/RoadProperty.java
View file @
1f25a59c
...
...
@@ -40,4 +40,6 @@ public interface RoadProperty extends LocationBasedEnvironmentProperty, Aggregat
Object
getValue
();
boolean
equalLocation
(
RoadProperty
pRoadProperty
);
boolean
isDetourable
();
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/benefit/BenefitEstimator.java
0 → 100755
View file @
1f25a59c
/*
* 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.data.benefit
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
public
interface
BenefitEstimator
extends
HostComponent
{
double
calculateBenefit
(
NodeProperties
pProperties
,
Notification
pNotification
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/benefit/DecisionBasedVehicularBenefitEstimator.java
0 → 100755
View file @
1f25a59c
/*
* 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.data.benefit
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
import
de.tudarmstadt.maki.simonstrator.api.component.relevance.path.PathPredictionComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.relevance.path.PathPredictionContainer
;
import
de.tudarmstadt.maki.simonstrator.api.component.relevance.path.StatisticalRoadNetworkRoute
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.LocationBasedEnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.PropertyBenefitEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.PropertyBenefitEstimatorFactory
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.VehicularPropertyCostEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AvailableInformationAttributes
;
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.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
public
class
DecisionBasedVehicularBenefitEstimator
implements
BenefitEstimator
{
private
Map
<
RoadInformation
,
CostGraph
>
_costGraphs
=
new
HashMap
<>();
private
Host
_host
;
public
DecisionBasedVehicularBenefitEstimator
(
Host
pHost
)
{
_host
=
pHost
;
}
@Override
public
void
initialize
()
{
try
{
getHost
().
getComponent
(
SiSComponent
.
class
).
get
().
rawObservations
(
SiSTypes
.
ROAD_EDGE
,
SiSRequest
.
NONE
,
null
);
}
catch
(
ComponentNotAvailableException
e
)
{
}
}
@Override
public
void
shutdown
()
{
}
@Override
public
Host
getHost
()
{
return
_host
;
}
@Override
public
double
calculateBenefit
(
NodeProperties
pProperties
,
Notification
pNotification
)
{
try
{
SiSComponent
sis
=
getHost
().
getComponent
(
SiSComponent
.
class
);
EnvironmentInformation
<?
extends
LocationBasedEnvironmentProperty
>
environmentInformation
=
EnvironmentInformation
.
createFromNotification
(
pNotification
);
if
(
environmentInformation
instanceof
RoadInformation
)
{
RoadInformation
roadInformation
=
(
RoadInformation
)
environmentInformation
;
PathPredictionComponent
pathPredictionComponent
=
getHost
().
getComponent
(
PathPredictionComponent
.
class
);
RoadNetworkEdge
currentLocation
=
sis
.
get
().
localObservationOf
(
pProperties
.
getId
(),
SiSTypes
.
ROAD_EDGE
,
SiSRequest
.
NONE
);
PathPredictionContainer
predictionContainer
=
pathPredictionComponent
.
findPossiblePathsOverRoad
(
currentLocation
,
roadInformation
.
getEdge
(),
3
);
double
expectedBenefit
=
0
;
for
(
StatisticalRoadNetworkRoute
statisticalRoute
:
predictionContainer
.
getRoutes
())
{
RoadNetworkRoute
networkRoute
=
statisticalRoute
.
getPath
();
if
(
statisticalRoute
.
getProbability
()
>
0
&&
networkRoute
.
containsEdge
(
roadInformation
.
getEdge
())
&&
networkRoute
.
getRoute
().
indexOf
(
roadInformation
.
getEdge
())
<
7
)
{
if
(!
_costGraphs
.
containsKey
(
roadInformation
))
{
int
depth
=
Math
.
min
(
networkRoute
.
getRoute
().
size
()
*
2
,
10
);
CostGraph
costGraphWithoutEvent
=
new
CostGraph
(
networkRoute
.
getDestination
());
costGraphWithoutEvent
.
createCostGraph
(
depth
);
CostGraph
costGraph
=
new
CostGraph
(
networkRoute
.
getDestination
(),
roadInformation
,
costGraphWithoutEvent
);
costGraph
.
createCostGraph
(
depth
);
_costGraphs
.
put
(
roadInformation
,
costGraph
);
}
CostGraph
costGraph
=
_costGraphs
.
get
(
roadInformation
);
RoadNetworkEdge
start
=
networkRoute
.
getStart
();
RoadNetworkRoute
optimalRoute
=
costGraph
.
getOptimalRoute
(
start
);
if
(
optimalRoute
!=
null
)
{
double
optimalCost
=
0
;
for
(
RoadNetworkEdge
edge
:
optimalRoute
.
getRoute
())
{
optimalCost
+=
costGraph
.
calculateEdgeCost
(
edge
);
}
double
currentCost
=
0
;
for
(
RoadNetworkEdge
edge
:
networkRoute
.
getRoute
())
{
currentCost
+=
costGraph
.
calculateEdgeCost
(
edge
);
}
int
equalAmount
=
2
;
for
(
int
i
=
0
;
i
<
equalAmount
+
1
;
i
++)
{
boolean
setCosts
=
i
<
optimalRoute
.
getRoute
().
size
()
^
i
<
networkRoute
.
getRoute
().
size
();
setCosts
|=
i
<
optimalRoute
.
getRoute
().
size
()
&&
!
optimalRoute
.
getRoute
().
get
(
i
).
equals
(
networkRoute
.
getRoute
().
get
(
i
));
if
(
setCosts
)
{
expectedBenefit
+=
Math
.
max
(
currentCost
-
optimalCost
,
0
)
*
statisticalRoute
.
getProbability
();
break
;
}
}
}
}
}
// PathPredictionContainer predictionContainer = pathPredictionComponent.findPossiblePathsOverRoad(
// sis.get().localObservationOf(pProperties.getId(), SiSTypes.ROAD_EDGE, SiSRequest.NONE),
// roadInformation.getEdge(), 3);
//
// PropertyBenefitEstimator benefitEstimator = PropertyBenefitEstimatorFactory
// .getPropertyBenefitEstimator();
// List<DecisionPoint> decisionPoints = benefitEstimator.getDecisionPoints(pNotification);
// Map<RoadNetworkEdge, VehicularDecisionPoint> decisionPointsByEdge = new HashMap<>();
// for (DecisionPoint decisionPoint : decisionPoints) {
// if (decisionPoint instanceof VehicularDecisionPoint) {
// decisionPointsByEdge.put(((VehicularDecisionPoint) decisionPoint).getDecisionPoint(),
// (VehicularDecisionPoint) decisionPoint);
// } else {
// throw new AssertionError("Only VehicularDecisionPoints allowed!");
// }
// }
//
// double expectedBenefit = 0;
// List<StatisticalRoadNetworkRoute> routes = predictionContainer.getRoutes();
// for (StatisticalRoadNetworkRoute statisticalRoute : routes) {
// double probability = statisticalRoute.getProbability();
// RoadNetworkRoute route = statisticalRoute.getPath();
//
// double maxBenefit = 0;
// for (RoadNetworkEdge edge : route.getRoute()) {
// if (decisionPointsByEdge.containsKey(edge)) {
// VehicularDecisionPoint decisionPoint = decisionPointsByEdge.get(edge);
// if (decisionPoint instanceof VehicularDetouringDecisionPoint) {
// VehicularDetouringDecisionPoint detouring = (VehicularDetouringDecisionPoint) decisionPoint;
// double benefit = detouring.calculateBenefit(route);
// double overhead = detouring.calculateOverhead(route);
// if (benefit > maxBenefit) {
// maxBenefit = benefit;
// }
// } else {
// double benefit = decisionPoint.getBenefit();
// if (benefit > maxBenefit) {
// maxBenefit = benefit;
// }
// }
// }
// }
// expectedBenefit += probability * maxBenefit;
// }
return
expectedBenefit
;
}
else
{
throw
new
AssertionError
(
"RoadInformation required for this benefit estimator!"
);
}
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
e
);
}
catch
(
InformationNotAvailableException
e
)
{
return
0
;
}
}
private
class
CostGraph
{
private
Map
<
RoadNetworkEdge
,
Double
>
_costGraph
=
new
HashMap
<>();
private
Map
<
RoadNetworkEdge
,
RoadNetworkEdge
>
_nextEdgeGraph
=
new
HashMap
<>();
// For event active
private
RoadInformation
_information
;
private
CostGraph
_costGraphWithoutEvent
;
private
RoadNetworkEdge
_destination
;
// If event inactive
public
CostGraph
(
RoadNetworkEdge
pDestination
)
{
_costGraph
.
put
(
pDestination
,
0
d
);
_destination
=
pDestination
;
}
// If event active
public
CostGraph
(
RoadNetworkEdge
pDestination
,
RoadInformation
pInformation
,
CostGraph
pCostGraphWithoutEvent
)
{
this
(
pDestination
);
_information
=
pInformation
;
_costGraphWithoutEvent
=
pCostGraphWithoutEvent
;
}
public
RoadNetworkRoute
getOptimalRoute
(
RoadNetworkEdge
pEdge
)
{
List
<
RoadNetworkEdge
>
edges
=
new
ArrayList
<>();
RoadNetworkEdge
current
=
pEdge
;
edges
.
add
(
current
);
while
(
_nextEdgeGraph
.
containsKey
(
current
))
{
RoadNetworkEdge
next
=
_nextEdgeGraph
.
get
(
current
);
edges
.
add
(
next
);
current
=
next
;
if
(
next
.
equals
(
_destination
)
||
!
_costGraph
.
containsKey
(
current
)
||
!
_costGraph
.
containsKey
(
next
)
||
_costGraph
.
get
(
current
)
<
_costGraph
.
get
(
next
))
{
break
;
}
}
if
(
edges
.
get
(
edges
.
size
()
-
1
).
equals
(
_destination
))
{
return
new
RoadNetworkRoute
(
edges
);
}
return
null
;
}
public
double
calculateEdgeCost
(
RoadNetworkEdge
pEdge
)
{
if
(
pEdge
.
equals
(
_destination
))
{
return
0
;
}
double
edgeCost
=
pEdge
.
getLength
()
/
pEdge
.
getOriginalMaxSpeed
();
if
(
_information
!=
null
)
{
if
(
_information
.
getEdge
().
equals
(
pEdge
))
{
PropertyBenefitEstimator
benefitEstimator
=
PropertyBenefitEstimatorFactory
.
getPropertyBenefitEstimator
();
if
(
benefitEstimator
instanceof
VehicularPropertyCostEstimator
)
{
edgeCost
+=
((
VehicularPropertyCostEstimator
)
benefitEstimator
)
.
calculateCostsIfKnown
(
_information
.
getValue
());
}
else
{
throw
new
AssertionError
(
"VehicularPropertyCostEstimator required!"
);
}
}
}
return
edgeCost
;
}
public
void
createCostGraph
(
int
pMaxDepth
)
{
if
(
_information
!=
null
)
{
long
duration
=
_information
.
getAttribute
(
AvailableInformationAttributes
.
EXPECTED_DURATION
);
double
existProbability
=
1
-
1
/
(
double
)
(
duration
/
Time
.
SECOND
);
for
(
int
i
=
0
;
i
<
pMaxDepth
;
i
++)
{
List
<
RoadNetworkEdge
>
labeledEdges
=
new
ArrayList
<>(
_costGraph
.
keySet
());
for
(
RoadNetworkEdge
roadNetworkEdge
:
labeledEdges
)
{
List
<
RoadNetworkEdge
>
incomingEdges
=
roadNetworkEdge
.
getIncomingEdges
();
for
(
RoadNetworkEdge
incomingEdge
:
incomingEdges
)
{
if
(
isCyclic
(
incomingEdge
,
roadNetworkEdge
))
{
continue
;
}
double
edgeCost
=
calculateEdgeCost
(
incomingEdge
);
double
eventActiveCost
=
_costGraph
.
get
(
roadNetworkEdge
);
double
eventInactiveCost
=
_costGraphWithoutEvent
.
get
(
roadNetworkEdge
);
double
stillExistProbability
=
Math
.
pow
(
existProbability
,
incomingEdge
.
getLength
()
/
incomingEdge
.
getOriginalMaxSpeed
());
double
totalCosts
=
edgeCost
+
eventInactiveCost
*
(
1
-
stillExistProbability
)
+
eventActiveCost
*
stillExistProbability
;
if
(!
_costGraph
.
containsKey
(
incomingEdge
)
||
totalCosts
<
_costGraph
.
get
(
incomingEdge
))
{
_costGraph
.
put
(
incomingEdge
,
totalCosts
);
_nextEdgeGraph
.
put
(
incomingEdge
,
roadNetworkEdge
);
}
}
}
}
}
else
{
for
(
int
i
=
0
;
i
<
pMaxDepth
;
i
++)
{
List
<
RoadNetworkEdge
>
labeledEdges
=
new
ArrayList
<>(
_costGraph
.
keySet
());
for
(
RoadNetworkEdge
roadNetworkEdge
:
labeledEdges
)
{
List
<
RoadNetworkEdge
>
incomingEdges
=
roadNetworkEdge
.
getIncomingEdges
();
for
(
RoadNetworkEdge
incomingEdge
:
incomingEdges
)
{
double
edgeCost
=
calculateEdgeCost
(
incomingEdge
);
double
totalCosts
=
_costGraph
.
get
(
roadNetworkEdge
)
+
edgeCost
;
if
(!
_costGraph
.
containsKey
(
incomingEdge
)
||
totalCosts
<
_costGraph
.
get
(
incomingEdge
))
{
_costGraph
.
put
(
incomingEdge
,
totalCosts
);
_nextEdgeGraph
.
put
(
incomingEdge
,
roadNetworkEdge
);
}
}
}
}
}
}
private
boolean
isCyclic
(
RoadNetworkEdge
pIncomingEdge
,
RoadNetworkEdge
pRoadNetworkEdge
)
{
RoadNetworkEdge
current
=
pRoadNetworkEdge
;
while
(
_nextEdgeGraph
.
containsKey
(
current
))
{
if
(
pIncomingEdge
.
equals
(
current
))
{
return
true
;
}
if
(
current
==
_destination
)
{
break
;
}
current
=
_nextEdgeGraph
.
get
(
current
);
}
return
false
;
}
public
double
get
(
RoadNetworkEdge
pEdge
)
{
return
_costGraph
.
get
(
pEdge
);
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/benefit/NodeProperties.java
0 → 100755
View file @
1f25a59c
/*
* 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.data.benefit
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
public
class
NodeProperties
{
private
final
INodeID
_id
;
public
NodeProperties
(
INodeID
pId
)
{
_id
=
pId
;
}
public
INodeID
getId
()
{
return
_id
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/benefit/RelevanceBasedVehicularBenefitEstimator.java
0 → 100755
View file @
1f25a59c
/*
* 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.data.benefit
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
import
de.tudarmstadt.maki.simonstrator.api.component.relevance.vehicular.RelevanceCalculationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.PropertyBenefitEstimator
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs.PropertyBenefitEstimatorFactory
;
public
class
RelevanceBasedVehicularBenefitEstimator
implements
BenefitEstimator
{
private
Host
_host
;
public
RelevanceBasedVehicularBenefitEstimator
(
Host
pHost
)
{
_host
=
pHost
;
}
@Override
public
void
initialize
()
{
}
@Override
public
void
shutdown
()
{
}
@Override
public
Host
getHost
()
{
return
_host
;
}
@Override
public
double
calculateBenefit
(
NodeProperties
pProperties
,
Notification
pNotification
)
{
try
{
RelevanceCalculationComponent
relevanceCalculationComponent
=
getHost
()
.
getComponent
(
RelevanceCalculationComponent
.
class
);
PropertyBenefitEstimator
costEstimator
=
PropertyBenefitEstimatorFactory
.
getPropertyBenefitEstimator
();
double
relevance
=
relevanceCalculationComponent
.
calculateRelevance
(
pProperties
.
getId
(),
pNotification
);
double
costs
=
costEstimator
.
calculateCostsIfKnown
(
pNotification
);
return
costs
*
relevance
;
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
e
);
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/DecisionPoint.java
0 → 100755
View file @
1f25a59c
/*
* 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.data.costs
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
public
class
DecisionPoint
{
private
Location
_location
;
private
double
_benefit
;
public
DecisionPoint
(
Location
pLocation
,
double
pBenefit
)
{
_location
=
pLocation
;
_benefit
=
pBenefit
;
}
public
Location
getLocation
()
{
return
_location
;
}
public
void
setLocation
(
Location
pLocation
)
{
_location
=
pLocation
;
}
public
double
getBenefit
()
{
return
_benefit
;
}
public
void
setBenefit
(
double
pBenefit
)
{
_benefit
=
pBenefit
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/DefaultVehicularPropertyCostEstimator.java
View file @
1f25a59c
...
...
@@ -20,6 +20,12 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.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.LocationBasedEnvironmentProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
...
...
@@ -28,11 +34,22 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.ha
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.jam.JamProperty
;
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
();
@Override
public
double
calculateCosts
(
Class
<?
extends
RoadProperty
>
pProperty
)
{
public
double
calculateCosts
IfKnown
(
Class
<?
extends
RoadProperty
>
pProperty
)
{
if
(
pProperty
.
equals
(
JamProperty
.
class
))
{
return
Math
.
pow
(
10
,
4
);
}
else
if
(
pProperty
.
equals
(
BumpProperty
.
class
))
{
...
...
@@ -44,15 +61,122 @@ public class DefaultVehicularPropertyCostEstimator implements VehicularPropertyC
}
@Override
public
double
calculateCosts
(
Notification
pNotification
)
{
public
double
calculateCostsIfKnown
(
Notification
pNotification
)
{
EnvironmentInformation
<?
extends
LocationBasedEnvironmentProperty
>
environmentInformation
=
EnvironmentInformation
.
createFromNotification
(
pNotification
);
if
(
environmentInformation
instanceof
RoadInformation
)
{
return
calculateCostsIfKnown
(((
RoadInformation
)
environmentInformation
).
getValue
());
}
throw
new
AssertionError
(
"Cost calculation only valid for road information!"
);
}
@Override
public
List
<
DecisionPoint
>
getDecisionPoints
(
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
;
}
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
calculateCosts
(((
RoadInformation
)
environmentInformation
).
getValue
());
return
calculateCosts
IfUnknown
(((
RoadInformation
)
environmentInformation
).
getValue
());
}
throw
new
AssertionError
(
"Cost calculation only valid for road information!"
);
}
@Override
public
double
calculateCostsIfUnknown
(
Class
<?
extends
RoadProperty
>
pProperty
)
{
if
(
pProperty
.
equals
(
JamProperty
.
class
))
{
return
Math
.
pow
(
10
,
2
);
}
else
if
(
pProperty
.
equals
(
BumpProperty
.
class
))
{
return
0
;
}
else
if
(
pProperty
.
equals
(
HazardProperty
.
class
))
{
return
Math
.
pow
(
10
,
4
);
}
return
0.01
;
}
@Override
public
double
calculateCostsIfUnknown
(
RoadProperty
pProperty
,
RoadNetworkEdge
pDecisionPoint
,
VehicleCostPreference
pVehicle
,
RoadNetworkRoute
pPath
)
{
return
0
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/PropertyBenefitEstimator.java
0 → 100755
View file @
1f25a59c
/*
* 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.data.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
);
List
<
DecisionPoint
>
getDecisionPoints
(
Notification
pNotification
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/Property
Cos
tEstimatorFactory.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/Property
Benefi
tEstimatorFactory.java
View file @
1f25a59c
...
...
@@ -20,10 +20,10 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs
;
public
class
Property
Cos
tEstimatorFactory
{
public
class
Property
Benefi
tEstimatorFactory
{
private
static
DefaultVehicularPropertyCostEstimator
_costEstimator
=
new
DefaultVehicularPropertyCostEstimator
();
public
static
Property
Cos
tEstimator
getProperty
Cos
tEstimator
()
{
public
static
Property
Benefi
tEstimator
getProperty
Benefi
tEstimator
()
{
return
_costEstimator
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/
PropertyCostEstimator
.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/
VehicleCostPreference
.java
View file @
1f25a59c
...
...
@@ -20,8 +20,6 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
public
class
VehicleCostPreference
{
public
interface
PropertyCostEstimator
{
double
calculateCosts
(
Notification
pNotification
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/VehicularDecisionPoint.java
0 → 100755
View file @
1f25a59c
/*
* 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.data.costs
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
public
class
VehicularDecisionPoint
extends
DecisionPoint
{
private
RoadNetworkEdge
_eventLocation
;
public
VehicularDecisionPoint
(
RoadNetworkEdge
pEventLocation
,
Location
pLocation
,
double
pBenefit
)
{
super
(
pLocation
,
pBenefit
);
_eventLocation
=
pEventLocation
;
}
public
RoadNetworkEdge
getEventEdge
()
{
return
_eventLocation
;
}
public
RoadNetworkEdge
getDecisionPoint
()
{
return
getEventEdge
();
}
public
void
setEdge
(
RoadNetworkEdge
pEdge
)
{
_eventLocation
=
pEdge
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/VehicularDetouringDecisionPoint.java
0 → 100755
View file @
1f25a59c
/*
* 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.data.costs
;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
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
VehicularDetouringDecisionPoint
extends
VehicularDecisionPoint
{
private
RoutingAlgorithm
routing
=
new
DijkstraAlgorithm
();
private
static
final
boolean
USE_STATIC_BENEFIT_FOR_DETOUR
=
true
;
private
RoadNetworkEdge
_detourLocation
;
public
VehicularDetouringDecisionPoint
(
RoadNetworkEdge
pDetourLocation
,
RoadNetworkEdge
pEventLocation
,
Location
pLocation
,
double
pBenefit
)
{
super
(
pEventLocation
,
pLocation
,
pBenefit
);
_detourLocation
=
pDetourLocation
;
}
@Override
public
RoadNetworkEdge
getDecisionPoint
()
{
return
_detourLocation
;
}
public
double
calculateBenefit
(
RoadNetworkRoute
pPath
)
{
VehiclePathTracker
tracker
=
VehiclePathTrackerFactory
.
getVehiclePathTracker
();
RoadNetworkEdge
start
=
_detourLocation
;
RoadNetworkEdge
destination
=
pPath
.
getDestination
();
RoadNetworkEdge
edgeToAvoid
=
getEventEdge
();
List
<
RoadNetworkRoute
>
knownRoutes
=
new
ArrayList
<>();
knownRoutes
.
add
(
pPath
);
List
<
RoadNetworkEdge
>
edgesToAvoid
=
new
ArrayList
<>();
edgesToAvoid
.
add
(
edgeToAvoid
);
RoadNetworkRoute
newRoute
=
routing
.
findRoute
(
RoadNetwork
.
CURRENT_ROAD_NETWORK
,
start
,
destination
,
knownRoutes
,
edgesToAvoid
);
if
(
newRoute
==
null
)
{
return
0
;
}
List
<
RoadNetworkEdge
>
oldSubEdges
=
new
ArrayList
<>();
boolean
add
=
false
;
for
(
RoadNetworkEdge
roadNetworkEdge
:
pPath
.
getRoute
())
{
if
(
roadNetworkEdge
.
equals
(
start
))
{
add
=
true
;
}
if
(
add
)
{
oldSubEdges
.
add
(
roadNetworkEdge
);
}
}
RoadNetworkRoute
oldRoute
=
new
RoadNetworkRoute
(
oldSubEdges
);
double
newRouteTravelTime
=
newRoute
.
getTravelTime
();
double
routeTravelTimeWithEvent
=
oldRoute
.
getTravelTime
();
double
routeTravelTimeWithoutEvent
=
oldRoute
.
getTravelTime
();
boolean
found
=
false
;
for
(
int
i
=
0
;
i
<
oldRoute
.
getRoute
().
size
()
-
1
;
i
++)
{
if
(
oldRoute
.
getRoute
().
get
(
i
).
equals
(
edgeToAvoid
))
{
routeTravelTimeWithEvent
-=
tracker
.
getTravelTime
(
oldRoute
.
getRoute
().
get
(
i
),
oldRoute
.
getRoute
().
get
(
i
+
1
));
routeTravelTimeWithoutEvent
-=
tracker
.
getTravelTime
(
oldRoute
.
getRoute
().
get
(
i
),
oldRoute
.
getRoute
().
get
(
i
+
1
));
found
=
true
;
}
}
if
(
found
)
{
routeTravelTimeWithEvent
+=
(
edgeToAvoid
.
getLength
()
/
edgeToAvoid
.
getMaxSpeed
());
routeTravelTimeWithoutEvent
+=
(
edgeToAvoid
.
getLength
()
/
edgeToAvoid
.
getOriginalMaxSpeed
());
}
if
(
USE_STATIC_BENEFIT_FOR_DETOUR
)
{
return
super
.
getBenefit
()
+
(
routeTravelTimeWithoutEvent
-
newRouteTravelTime
)
*
10
;
}
else
{
return
(
routeTravelTimeWithEvent
-
newRouteTravelTime
)
*
10
;
}
}
public
double
calculateOverhead
(
RoadNetworkRoute
pPath
)
{
VehiclePathTracker
tracker
=
VehiclePathTrackerFactory
.
getVehiclePathTracker
();
RoadNetworkEdge
start
=
_detourLocation
;
RoadNetworkEdge
destination
=
pPath
.
getDestination
();
RoadNetworkEdge
edgeToAvoid
=
getEventEdge
();
List
<
RoadNetworkRoute
>
knownRoutes
=
new
ArrayList
<>();
knownRoutes
.
add
(
pPath
);
List
<
RoadNetworkEdge
>
edgesToAvoid
=
new
ArrayList
<>();
edgesToAvoid
.
add
(
edgeToAvoid
);
RoadNetworkRoute
newRoute
=
routing
.
findRoute
(
RoadNetwork
.
CURRENT_ROAD_NETWORK
,
start
,
destination
,
knownRoutes
,
edgesToAvoid
);
if
(
newRoute
==
null
)
{
return
0
;
}
List
<
RoadNetworkEdge
>
oldSubEdges
=
new
ArrayList
<>();
boolean
add
=
false
;
for
(
RoadNetworkEdge
roadNetworkEdge
:
pPath
.
getRoute
())
{
if
(
roadNetworkEdge
.
equals
(
start
))
{
add
=
true
;
}
if
(
add
)
{
oldSubEdges
.
add
(
roadNetworkEdge
);
}
}
RoadNetworkRoute
oldRoute
=
new
RoadNetworkRoute
(
oldSubEdges
);
double
newRouteTravelTime
=
newRoute
.
getTravelTime
();
double
routeTravelTimeWithoutEvent
=
oldRoute
.
getTravelTime
();
boolean
found
=
false
;
for
(
int
i
=
0
;
i
<
oldRoute
.
getRoute
().
size
()
-
1
;
i
++)
{
if
(
oldRoute
.
getRoute
().
get
(
i
).
equals
(
edgeToAvoid
))
{
routeTravelTimeWithoutEvent
-=
tracker
.
getTravelTime
(
oldRoute
.
getRoute
().
get
(
i
),
oldRoute
.
getRoute
().
get
(
i
+
1
));
found
=
true
;
}
}
if
(
found
)
{
routeTravelTimeWithoutEvent
+=
(
edgeToAvoid
.
getLength
()
/
edgeToAvoid
.
getOriginalMaxSpeed
());
}
return
(
routeTravelTimeWithoutEvent
-
newRouteTravelTime
)
*
10
;
}
@Override
public
double
getBenefit
()
{
throw
new
UnsupportedOperationException
();
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/costs/VehicularPropertyCostEstimator.java
View file @
1f25a59c
...
...
@@ -21,11 +21,26 @@
package
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.costs
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.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
Property
Cos
tEstimator
{
default
double
calculateCosts
(
RoadProperty
pProperty
)
{
return
calculateCosts
(
pProperty
.
getClass
());
public
interface
VehicularPropertyCostEstimator
extends
Property
Benefi
tEstimator
{
default
double
calculateCosts
IfKnown
(
RoadProperty
pProperty
)
{
return
calculateCosts
IfKnown
(
pProperty
.
getClass
());
}
double
calculateCosts
(
Class
<?
extends
RoadProperty
>
pProperty
);
double
calculateCostsIfKnown
(
Class
<?
extends
RoadProperty
>
pProperty
);
double
calculateCostsIfKnown
(
RoadProperty
pProperty
,
RoadNetworkEdge
pDecisionPoint
,
VehicleCostPreference
pVehicle
,
RoadNetworkRoute
pPath
);
default
double
calculateCostsIfUnknown
(
RoadProperty
pProperty
)
{
return
calculateCostsIfUnknown
(
pProperty
.
getClass
());
}
double
calculateCostsIfUnknown
(
Class
<?
extends
RoadProperty
>
pProperty
);
double
calculateCostsIfUnknown
(
RoadProperty
pProperty
,
RoadNetworkEdge
pDecisionPoint
,
VehicleCostPreference
pVehicle
,
RoadNetworkRoute
pPath
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/hazard/HazardProperty.java
View file @
1f25a59c
...
...
@@ -54,4 +54,9 @@ public class HazardProperty extends AbstractRoadProperty {
return
hasHazard
();
}
@Override
public
boolean
isDetourable
()
{
return
true
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/data/jam/VectoralJamProperty.java
View file @
1f25a59c
...
...
@@ -37,7 +37,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
*
*/
public
class
VectoralJamProperty
extends
NumericVectoralProperty
{
public
static
final
double
SCALING
=
3
;
public
static
final
double
SCALING
=
6
;
public
static
final
int
DIMENSIONS
=
15
;
// private static Map<Double, Double> _requiredStandardDeviation = new
...
...
Prev
1
2
Next
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