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
edf3c56d
Commit
edf3c56d
authored
Dec 07, 2017
by
Tobias Meuser
Browse files
Working version for WoWMoM paper
parent
2b9f8ebc
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/relevance/EmptyFilter.java
deleted
100755 → 0
View file @
2b9f8ebc
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.vehicular.relevance
;
import
java.util.Set
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayContact
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 13.11.2017
*
*/
public
class
EmptyFilter
implements
SubscriberFilter
{
private
Host
_host
;
public
EmptyFilter
(
Host
pHost
)
{
_host
=
pHost
;
}
@Override
public
void
startMechanism
(
Callback
pCb
)
{
pCb
.
finished
(
true
);
}
@Override
public
void
stopMechanism
(
Callback
pCb
)
{
pCb
.
finished
(
true
);
}
@Override
public
void
filterSubscribers
(
Set
<
OverlayContact
>
pContacts
,
Notification
pNotification
,
SubscriptionFilterResultCallback
pCallback
,
Object
...
pParametersToStore
)
{
pCallback
.
onComplete
(
pContacts
,
pParametersToStore
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/relevance/SubscriberFilter.java
deleted
100755 → 0
View file @
2b9f8ebc
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.vehicular.relevance
;
import
java.util.Set
;
import
de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayContact
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
import
de.tudarmstadt.maki.simonstrator.api.component.transition.TransitionEnabled
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 13.11.2017
*
*/
public
interface
SubscriberFilter
extends
TransitionEnabled
{
/**
*
* @param pContacts
* @param pNotification
* @param pCloud
* @return
*/
void
filterSubscribers
(
Set
<
OverlayContact
>
pContacts
,
Notification
pNotification
,
SubscriptionFilterResultCallback
pCallback
,
Object
...
pParametersToStore
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/relevance/SubscriptionFilterResultCallback.java
deleted
100755 → 0
View file @
2b9f8ebc
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.vehicular.relevance
;
import
java.util.Set
;
import
de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayContact
;
/**
* @author Tobias Meuser (tobias.meuser@kom.tu-darmstadt.de)
* @version 1.0 at 13.11.2017
*
*/
public
interface
SubscriptionFilterResultCallback
{
/**
*
* @param pNotifiedSubscribers
* @param pParametersToStore
*/
void
onComplete
(
Set
<
OverlayContact
>
pNotifiedSubscribers
,
Object
...
pStoredParameters
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/RoadNetworkEdge.java
View file @
edf3c56d
...
@@ -34,6 +34,11 @@ public class RoadNetworkEdge {
...
@@ -34,6 +34,11 @@ public class RoadNetworkEdge {
private
double
_originalMaxSpeed
=
0
;
private
double
_originalMaxSpeed
=
0
;
private
double
_maxSpeed
=
0
;
private
double
_maxSpeed
=
0
;
private
boolean
_isUsableInit
=
false
;
private
boolean
_isUsable
=
false
;
private
double
_length
=
Double
.
NaN
;
private
List
<
RoadNetworkLane
>
_lanes
=
new
ArrayList
<>();
private
List
<
RoadNetworkLane
>
_lanes
=
new
ArrayList
<>();
private
List
<
RoadNetworkEdge
>
_accessibleEdges
=
new
ArrayList
<>();
private
List
<
RoadNetworkEdge
>
_accessibleEdges
=
new
ArrayList
<>();
...
@@ -150,7 +155,10 @@ public class RoadNetworkEdge {
...
@@ -150,7 +155,10 @@ public class RoadNetworkEdge {
}
}
public
double
getLength
()
{
public
double
getLength
()
{
return
_edgeController
.
getEdgeLength
(
_edgeID
);
if
(
Double
.
isNaN
(
_length
))
{
_length
=
_edgeController
.
getEdgeLength
(
_edgeID
);
}
return
_length
;
}
}
public
String
getDescription
()
{
public
String
getDescription
()
{
...
@@ -172,7 +180,11 @@ public class RoadNetworkEdge {
...
@@ -172,7 +180,11 @@ public class RoadNetworkEdge {
}
}
public
boolean
isUsable
()
{
public
boolean
isUsable
()
{
return
_edgeController
.
isEdgeUsable
(
getEdgeID
());
if
(!
_isUsableInit
)
{
_isUsableInit
=
true
;
_isUsable
=
_edgeController
.
isEdgeUsable
(
getEdgeID
());
}
return
_isUsable
;
}
}
public
List
<
List
<
Location
>>
getRoadShape
()
{
public
List
<
List
<
Location
>>
getRoadShape
()
{
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/RoadNetworkRoute.java
View file @
edf3c56d
...
@@ -102,4 +102,39 @@ public class RoadNetworkRoute {
...
@@ -102,4 +102,39 @@ public class RoadNetworkRoute {
}
}
return
false
;
return
false
;
}
}
/**
* @return
*/
public
double
getTravelTime
()
{
double
time
=
0
;
for
(
RoadNetworkEdge
roadNetworkEdge
:
_route
)
{
time
+=
roadNetworkEdge
.
getLength
()
/
roadNetworkEdge
.
getMaxSpeed
();
}
return
time
;
}
/**
* @param pEdge
* @param pEdge2
* @return
*/
public
RoadNetworkRoute
subRoute
(
RoadNetworkEdge
pStart
,
RoadNetworkEdge
pEnd
)
{
List
<
RoadNetworkEdge
>
edges
=
new
ArrayList
<>();
boolean
startFound
=
false
;
boolean
endFound
=
false
;
for
(
RoadNetworkEdge
roadNetworkEdge
:
_route
)
{
if
(
roadNetworkEdge
.
equals
(
pStart
))
{
startFound
=
true
;
}
if
(
startFound
^
endFound
)
{
edges
.
add
(
roadNetworkEdge
);
}
if
(
roadNetworkEdge
.
equals
(
pEnd
))
{
endFound
=
true
;
}
}
return
new
RoadNetworkRoute
(
edges
);
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/paths/PathDetectionAlgorithm.java
View file @
edf3c56d
...
@@ -41,10 +41,10 @@ public interface PathDetectionAlgorithm {
...
@@ -41,10 +41,10 @@ public interface PathDetectionAlgorithm {
private
final
RoadNetworkRoute
_route
;
private
final
RoadNetworkRoute
_route
;
private
final
double
_length
;
private
final
double
_length
;
public
ProbabilisticRoadNetworkRoute
(
double
pProbability
,
RoadNetworkRoute
pRoute
,
double
pLength
)
{
public
ProbabilisticRoadNetworkRoute
(
double
pProbability
,
RoadNetworkRoute
pRoute
)
{
_probability
=
pProbability
;
_probability
=
pProbability
;
_route
=
pRoute
;
_route
=
pRoute
;
_length
=
p
Length
;
_length
=
p
Route
.
getTravelTime
()
;
}
}
public
double
getProbability
()
{
public
double
getProbability
()
{
...
@@ -58,5 +58,10 @@ public interface PathDetectionAlgorithm {
...
@@ -58,5 +58,10 @@ public interface PathDetectionAlgorithm {
public
double
getLength
()
{
public
double
getLength
()
{
return
_length
;
return
_length
;
}
}
@Override
public
String
toString
()
{
return
_route
.
toString
()
+
" with probability of "
+
_probability
;
}
}
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/paths/
DijkstraBased
PathDetectionAlgorithm.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/paths/
Simple
PathDetectionAlgorithm.java
View file @
edf3c56d
...
@@ -36,7 +36,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
...
@@ -36,7 +36,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0 at 28.11.2017
* @version 1.0 at 28.11.2017
*
*
*/
*/
public
class
DijkstraBased
PathDetectionAlgorithm
implements
PathDetectionAlgorithm
{
public
class
Simple
PathDetectionAlgorithm
implements
PathDetectionAlgorithm
{
private
static
final
double
ABORT_THRESHOLD
=
0.001d
;
private
static
final
double
ABORT_THRESHOLD
=
0.001d
;
@Override
@Override
...
@@ -58,25 +58,33 @@ public class DijkstraBasedPathDetectionAlgorithm implements PathDetectionAlgorit
...
@@ -58,25 +58,33 @@ public class DijkstraBasedPathDetectionAlgorithm implements PathDetectionAlgorit
List
<
RoadNetworkEdge
>
accessibleEdges
=
roadNetworkPath
.
getEdge
().
getAccessibleEdges
();
List
<
RoadNetworkEdge
>
accessibleEdges
=
roadNetworkPath
.
getEdge
().
getAccessibleEdges
();
for
(
RoadNetworkEdge
accessibleEdge
:
accessibleEdges
)
{
for
(
RoadNetworkEdge
accessibleEdge
:
accessibleEdges
)
{
double
travelTime
=
accessibleEdge
.
getLength
()
/
accessibleEdge
.
getMaxSpeed
();
if
(
accessibleEdge
.
isUsable
())
{
double
probability
=
VehiclePathTrackerFactory
.
getVehiclePathTracker
()
double
travelTime
=
accessibleEdge
.
getLength
()
/
accessibleEdge
.
getMaxSpeed
();
.
getTransitionProbability
(
roadNetworkPath
.
getEdge
(),
accessibleEdge
);
double
probability
=
VehiclePathTrackerFactory
.
getVehiclePathTracker
()
.
getTransitionProbability
(
roadNetworkPath
.
getEdge
(),
accessibleEdge
);
RoadNetworkPath
newPath
=
roadNetworkPath
.
createPath
(
accessibleEdge
,
probability
,
travelTime
);
RoadNetworkPath
newPath
=
roadNetworkPath
.
createPath
(
accessibleEdge
,
probability
,
travelTime
);
if
(
newPath
.
getEdge
()
==
pDestination
)
{
if
(
newPath
.
getEdge
()
==
pDestination
)
{
double
totalTravelTime
=
newPath
.
getTravelTime
();
double
totalTravelTime
=
newPath
.
getTravelTime
();
double
totalProbability
=
newPath
.
getProbability
();
double
totalProbability
=
newPath
.
getProbability
();
RoadNetworkRoute
route
=
newPath
.
getRoute
();
double
temporalRelevance
=
1
;
// TODO: To be done!
double
temporalRelevance
=
1
;
// TODO: To be done!
routes
.
add
(
routes
.
add
(
new
ProbabilisticRoadNetworkRoute
(
totalProbability
,
route
));
new
ProbabilisticRoadNetworkRoute
(
totalProbability
,
newPath
.
getRoute
(),
totalTravelTime
));
}
else
{
}
else
{
currentPaths
.
add
(
newPath
);
currentPaths
.
add
(
newPath
);
}
}
}
}
}
}
}
double
sum
=
0
;
for
(
ProbabilisticRoadNetworkRoute
probabilisticRoadNetworkRoute
:
routes
)
{
sum
+=
probabilisticRoadNetworkRoute
.
getProbability
();
}
return
routes
;
return
routes
;
}
}
...
@@ -125,6 +133,7 @@ public class DijkstraBasedPathDetectionAlgorithm implements PathDetectionAlgorit
...
@@ -125,6 +133,7 @@ public class DijkstraBasedPathDetectionAlgorithm implements PathDetectionAlgorit
public
RoadNetworkRoute
getRoute
()
{
public
RoadNetworkRoute
getRoute
()
{
List
<
RoadNetworkEdge
>
edges
=
new
ArrayList
<>();
List
<
RoadNetworkEdge
>
edges
=
new
ArrayList
<>();
getRoute
(
edges
);
return
new
RoadNetworkRoute
(
edges
);
return
new
RoadNetworkRoute
(
edges
);
}
}
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/routing/BreadthFirstSearch.java
View file @
edf3c56d
...
@@ -49,6 +49,12 @@ public class BreadthFirstSearch implements RoutingAlgorithm {
...
@@ -49,6 +49,12 @@ public class BreadthFirstSearch implements RoutingAlgorithm {
@Override
@Override
public
RoadNetworkRoute
findRoute
(
RoadNetwork
pNetwork
,
RoadNetworkEdge
pCurrentPosition
,
RoadNetworkEdge
pDestination
,
public
RoadNetworkRoute
findRoute
(
RoadNetwork
pNetwork
,
RoadNetworkEdge
pCurrentPosition
,
RoadNetworkEdge
pDestination
,
List
<
RoadNetworkRoute
>
pKnownRoutes
,
List
<
RoadNetworkEdge
>
pEdgesToAvoid
)
{
List
<
RoadNetworkRoute
>
pKnownRoutes
,
List
<
RoadNetworkEdge
>
pEdgesToAvoid
)
{
if
(
pCurrentPosition
.
equals
(
pDestination
))
{
List
<
RoadNetworkEdge
>
segments
=
new
ArrayList
<>();
segments
.
add
(
pCurrentPosition
);
return
new
RoadNetworkRoute
(
segments
);
}
List
<
RoadNetworkEdge
>
visitedEdges
=
new
ArrayList
<>();
List
<
RoadNetworkEdge
>
visitedEdges
=
new
ArrayList
<>();
Queue
<
PathInformation
>
buffer
=
new
PriorityQueue
<>(
new
PathInformationComparator
());
Queue
<
PathInformation
>
buffer
=
new
PriorityQueue
<>(
new
PathInformationComparator
());
PathInformation
rootPathInformation
=
new
PathInformation
(
pCurrentPosition
,
null
,
0
,
0
);
PathInformation
rootPathInformation
=
new
PathInformation
(
pCurrentPosition
,
null
,
0
,
0
);
...
@@ -58,7 +64,7 @@ public class BreadthFirstSearch implements RoutingAlgorithm {
...
@@ -58,7 +64,7 @@ public class BreadthFirstSearch implements RoutingAlgorithm {
double
currentPathLength
=
Double
.
MAX_VALUE
;
double
currentPathLength
=
Double
.
MAX_VALUE
;
RoadNetworkRoute
currentShortestRoute
=
null
;
RoadNetworkRoute
currentShortestRoute
=
null
;
double
maxDepth
=
1
0
;
double
maxDepth
=
1
2
;
for
(
RoadNetworkRoute
roadNetworkRoute
:
pKnownRoutes
)
{
for
(
RoadNetworkRoute
roadNetworkRoute
:
pKnownRoutes
)
{
if
(
roadNetworkRoute
.
getRoute
().
size
()
*
MAX_DEPTH_RATIO
>
maxDepth
)
{
if
(
roadNetworkRoute
.
getRoute
().
size
()
*
MAX_DEPTH_RATIO
>
maxDepth
)
{
maxDepth
=
roadNetworkRoute
.
getRoute
().
size
()
*
MAX_DEPTH_RATIO
;
maxDepth
=
roadNetworkRoute
.
getRoute
().
size
()
*
MAX_DEPTH_RATIO
;
...
@@ -128,7 +134,11 @@ public class BreadthFirstSearch implements RoutingAlgorithm {
...
@@ -128,7 +134,11 @@ public class BreadthFirstSearch implements RoutingAlgorithm {
@Override
@Override
public
int
compare
(
PathInformation
pO1
,
PathInformation
pO2
)
{
public
int
compare
(
PathInformation
pO1
,
PathInformation
pO2
)
{
return
Double
.
compare
(
pO1
.
getLength
(),
pO2
.
getLength
());
int
compare
=
Double
.
compare
(
pO1
.
getLength
(),
pO2
.
getLength
());
if
(
compare
==
0
)
{
compare
=
Double
.
compare
(
pO1
.
getHops
(),
pO2
.
getHops
());
}
return
compare
;
}
}
}
}
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/routing/DijkstraAlgorithm.java
View file @
edf3c56d
...
@@ -49,6 +49,12 @@ public class DijkstraAlgorithm implements RoutingAlgorithm {
...
@@ -49,6 +49,12 @@ public class DijkstraAlgorithm implements RoutingAlgorithm {
@Override
@Override
public
RoadNetworkRoute
findRoute
(
RoadNetwork
pNetwork
,
RoadNetworkEdge
pCurrentPosition
,
RoadNetworkEdge
pDestination
,
public
RoadNetworkRoute
findRoute
(
RoadNetwork
pNetwork
,
RoadNetworkEdge
pCurrentPosition
,
RoadNetworkEdge
pDestination
,
List
<
RoadNetworkRoute
>
pKnownRoutes
,
List
<
RoadNetworkEdge
>
pEdgesToAvoid
)
{
List
<
RoadNetworkRoute
>
pKnownRoutes
,
List
<
RoadNetworkEdge
>
pEdgesToAvoid
)
{
if
(
pCurrentPosition
.
equals
(
pDestination
))
{
List
<
RoadNetworkEdge
>
segments
=
new
ArrayList
<>();
segments
.
add
(
pCurrentPosition
);
return
new
RoadNetworkRoute
(
segments
);
}
List
<
RoadNetworkEdge
>
visitedEdges
=
new
ArrayList
<>();
List
<
RoadNetworkEdge
>
visitedEdges
=
new
ArrayList
<>();
Queue
<
PathInformation
>
buffer
=
new
PriorityQueue
<>(
new
PathInformationComparator
());
Queue
<
PathInformation
>
buffer
=
new
PriorityQueue
<>(
new
PathInformationComparator
());
PathInformation
rootPathInformation
=
new
PathInformation
(
pCurrentPosition
,
null
,
0
,
0
);
PathInformation
rootPathInformation
=
new
PathInformation
(
pCurrentPosition
,
null
,
0
,
0
);
...
@@ -58,7 +64,7 @@ public class DijkstraAlgorithm implements RoutingAlgorithm {
...
@@ -58,7 +64,7 @@ public class DijkstraAlgorithm implements RoutingAlgorithm {
double
currentPathLength
=
Double
.
MAX_VALUE
;
double
currentPathLength
=
Double
.
MAX_VALUE
;
RoadNetworkRoute
currentShortestRoute
=
null
;
RoadNetworkRoute
currentShortestRoute
=
null
;
double
maxDepth
=
1
0
;
double
maxDepth
=
1
2
;
for
(
RoadNetworkRoute
roadNetworkRoute
:
pKnownRoutes
)
{
for
(
RoadNetworkRoute
roadNetworkRoute
:
pKnownRoutes
)
{
if
(
roadNetworkRoute
.
getRoute
().
size
()
*
MAX_DEPTH_RATIO
>
maxDepth
)
{
if
(
roadNetworkRoute
.
getRoute
().
size
()
*
MAX_DEPTH_RATIO
>
maxDepth
)
{
maxDepth
=
roadNetworkRoute
.
getRoute
().
size
()
*
MAX_DEPTH_RATIO
;
maxDepth
=
roadNetworkRoute
.
getRoute
().
size
()
*
MAX_DEPTH_RATIO
;
...
...
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