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
e157b605
Commit
e157b605
authored
Sep 22, 2020
by
Tobias Meuser
Browse files
Merged tm/vehicular-services into master-integration
parents
8b80fdfa
0fbcbc65
Changes
140
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
e157b605
...
...
@@ -101,17 +101,25 @@
</repositories>
<dependencies>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
18.0
</version>
</dependency>
<dependency>
<groupId>
javax.xml.bind
</groupId>
<artifactId>
jaxb-api
</artifactId>
<version>
2.3.1
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
<dependency>
<groupId>
gov.nist.math
</groupId>
<artifactId>
jama
</artifactId>
<version>
1.0.3
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-math3
</artifactId>
<version>
3.0
</version>
</dependency>
</dependencies>
</project>
src/de/tudarmstadt/maki/simonstrator/api/Oracle.java
View file @
e157b605
...
...
@@ -59,6 +59,11 @@ public final class Oracle {
public
List
<
Host
>
getAllHosts
()
{
return
null
;
}
@Override
public
Host
getHostByID
(
long
pValue
)
{
return
null
;
}
};
}
}
...
...
@@ -94,12 +99,7 @@ public final class Oracle {
* @return
*/
public
static
Host
getHostByID
(
INodeID
nodeId
)
{
for
(
Host
host
:
getAllHosts
())
{
if
(
host
.
getId
().
equals
(
nodeId
))
{
return
host
;
}
}
return
null
;
return
getOracle
().
getHostByID
(
nodeId
.
value
());
}
}
src/de/tudarmstadt/maki/simonstrator/api/common/metric/AbstractMetric.java
View file @
e157b605
...
...
@@ -94,6 +94,18 @@ public abstract class AbstractMetric<M extends MetricValue<?>> implements
perHost
.
put
(
host
.
getId
(),
value
);
}
protected
void
addId
(
INodeID
pId
,
M
value
)
{
if
(
perHost
==
null
)
{
perHost
=
new
LinkedHashMap
<
INodeID
,
M
>();
allPerHost
=
new
LinkedList
<
M
>();
}
if
(
perHost
.
containsKey
(
pId
))
{
throw
new
AssertionError
(
"Each id is only allowed once!"
);
}
allPerHost
.
add
(
value
);
perHost
.
put
(
pId
,
value
);
}
protected
void
setOverallMetric
(
M
aggregate
)
{
if
(
this
.
overallMetric
!=
null
)
{
throw
new
AssertionError
(
"Only one overallMetric is allowed."
);
...
...
src/de/tudarmstadt/maki/simonstrator/api/common/metric/ActiveSpatialMetric.java
0 → 100755
View file @
e157b605
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.common.metric
;
import
de.tudarmstadt.maki.simonstrator.api.common.metric.ActiveSpatialMetric.SpatialMetricValue
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
/**
* A metric that is actively updated (for example based on a sampling interval).
* Normally, only derived metrics (i.e. metrics that passed through a filter)
* should be active metrics, but in some cases overlays might want to provide
* metrics that are updated on specific operations.
*
* @author Tobias Meuser
* @version 1.0, 10.10.2018
*/
public
interface
ActiveSpatialMetric
<
M
extends
SpatialMetricValue
<?>>
extends
Metric
<
M
>
{
/**
* Add a listener that is informed whenever the metric is updated
*
* @param listener
*/
public
void
addActiveSpatialMetricListener
(
ActiveSpatialMetricListener
listener
);
void
notifyListeners
();
double
getResolution
();
boolean
isAggregated
();
/**
* Listener that is informed whenever the {@link ActiveSpatialMetric} is
* updated.
*
* @author Tobias Meuser
* @version 1.0, 10.10.2018
*/
public
interface
ActiveSpatialMetricListener
{
/**
* The given metric was updated
*
* @param metric
*/
public
void
onMetricUpdate
(
ActiveSpatialMetric
<?>
metric
);
}
/**
* Value of a metric. The {@link Metric}-concept implies that the aggregation of
* values is to be handled by the analyzer that calls getValue().
*
* For OverallMetrics (i.e. metrics that are already available as an aggregate),
* you should also implement toString in a meaningful way, as this string will
* be used by the live monitor.
*
* @author Tobias Meuser
* @version 1.0, 10.10.2018
* @param <T>
*/
public
interface
SpatialMetricValue
<
T
>
extends
MetricValue
<
T
>
{
/**
* Get the location of the value.
*
* @return
*/
public
Location
getLocation
();
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/core/OracleComponent.java
View file @
e157b605
...
...
@@ -43,6 +43,8 @@ public interface OracleComponent extends GlobalComponent {
*/
public
List
<
Host
>
getAllHosts
();
public
Host
getHostByID
(
long
pValue
);
/**
* Allows Overlays and Components to distinguish between real-world
* implementations and simulations - could be nifty for performance reasons
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/core/SimulationRuntimeAnalyzer.java
0 → 100755
View file @
e157b605
package
de.tudarmstadt.maki.simonstrator.api.component.core
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.Analyzer
;
public
interface
SimulationRuntimeAnalyzer
extends
Analyzer
{
void
startEventExecution
(
EventHandler
pHandler
,
int
pType
);
void
endEventExecution
(
EventHandler
pHandler
,
int
pType
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/privacy/PrivacyComponent.java
0 → 100755
View file @
e157b605
/*
* 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.privacy
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
public
class
PrivacyComponent
implements
HostComponent
{
private
Host
_host
;
private
PrivacyLevel
_privacy
=
PrivacyLevel
.
NO_PRIVACY
;
public
PrivacyComponent
(
Host
pHost
)
{
_host
=
pHost
;
}
public
void
setPrivacy
(
PrivacyLevel
pLevel
)
{
_privacy
=
pLevel
;
}
@Override
public
void
initialize
()
{
}
@Override
public
void
shutdown
()
{
}
@Override
public
Host
getHost
()
{
return
_host
;
}
public
Location
obscureLocation
(
Location
pLocation
)
{
Location
location
=
pLocation
.
clone
();
location
.
setAccuracy
(
_privacy
.
getImprecisionAreaRadius
());
return
location
;
}
public
PrivacyLevel
getPrivacyLevel
()
{
return
_privacy
;
}
public
void
setPrivacyLevel
(
PrivacyLevel
pPrivacy
)
{
_privacy
=
pPrivacy
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/privacy/PrivacyComponentFactory.java
0 → 100755
View file @
e157b605
/*
* 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.privacy
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponentFactory
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
public
class
PrivacyComponentFactory
implements
HostComponentFactory
{
private
List
<
PrivacyLevelFrequency
>
_levels
=
new
ArrayList
<>();
private
double
_sum
=
0
;
private
Random
_random
=
Randoms
.
getRandom
(
getClass
());
private
double
[]
_ratio
;
@Override
public
HostComponent
createComponent
(
Host
pHost
)
{
PrivacyLevel
level
=
PrivacyLevel
.
NO_PRIVACY
;
double
randomValue
=
_random
.
nextDouble
()
*
_sum
;
double
count
=
0
;
for
(
int
i
=
0
;
i
<
_levels
.
size
();
i
++)
{
count
+=
_levels
.
get
(
i
).
getProbability
();
if
(
count
>
randomValue
)
{
level
=
_levels
.
get
(
i
).
getLevel
();
break
;
}
}
PrivacyComponent
privacyComponent
=
new
PrivacyComponent
(
pHost
);
privacyComponent
.
setPrivacy
(
level
);
return
privacyComponent
;
}
public
void
setRatio
(
String
pRatio
)
{
String
[]
split
=
pRatio
.
split
(
"-"
);
_ratio
=
new
double
[
split
.
length
];
for
(
int
i
=
0
;
i
<
split
.
length
;
i
++)
{
_ratio
[
i
]
=
Double
.
valueOf
(
split
[
i
]);
_sum
+=
_ratio
[
i
];
}
}
public
void
setPrivacy
(
PrivacyLevel
pPrivacyLevel
)
{
_levels
.
add
(
new
PrivacyLevelFrequency
(
pPrivacyLevel
,
_ratio
[
_levels
.
size
()]));
PrivacyLevel
.
PRIVACY_LEVELS
.
add
(
pPrivacyLevel
);
}
public
static
class
PrivacyLevelFrequency
{
private
PrivacyLevel
_level
;
private
double
_probability
;
@XMLConfigurableConstructor
({
"privacy"
,
"probability"
})
public
PrivacyLevelFrequency
(
PrivacyLevel
pLevel
,
double
pProbability
)
{
_level
=
pLevel
;
_probability
=
pProbability
;
}
public
double
getProbability
()
{
return
_probability
;
}
public
PrivacyLevel
getLevel
()
{
return
_level
;
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/privacy/PrivacyLevel.java
0 → 100755
View file @
e157b605
package
de.tudarmstadt.maki.simonstrator.api.component.privacy
;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
public
class
PrivacyLevel
implements
Comparable
<
PrivacyLevel
>
{
public
static
final
PrivacyLevel
NO_PRIVACY
=
new
PrivacyLevel
(
0
);
public
static
final
List
<
PrivacyLevel
>
PRIVACY_LEVELS
=
new
ArrayList
<>();
private
static
int
staticID
=
0
;
private
final
int
id
;
private
double
imprecisionAreaRadius
;
private
int
[]
responsibility
=
new
int
[
0
];
@XMLConfigurableConstructor
({
"imprecision"
})
public
PrivacyLevel
(
double
pImprecisionAreaRadius
)
{
synchronized
(
PrivacyLevel
.
class
)
{
id
=
staticID
++;
}
imprecisionAreaRadius
=
pImprecisionAreaRadius
;
}
@XMLConfigurableConstructor
({
"imprecision"
,
"responsibility"
})
public
PrivacyLevel
(
double
pImprecisionAreaRadius
,
String
responsibility
)
{
synchronized
(
PrivacyLevel
.
class
)
{
id
=
staticID
++;
}
imprecisionAreaRadius
=
pImprecisionAreaRadius
;
String
[]
responsibilityLevels
;
if
(
responsibility
.
trim
().
length
()
>
0
)
{
responsibilityLevels
=
responsibility
.
trim
().
split
(
";"
);
}
else
{
responsibilityLevels
=
new
String
[
0
];
}
this
.
responsibility
=
new
int
[
responsibilityLevels
.
length
];
for
(
int
i
=
0
;
i
<
responsibilityLevels
.
length
;
i
++)
{
this
.
responsibility
[
i
]
=
Integer
.
valueOf
(
responsibilityLevels
[
i
]);
}
}
public
String
getResponsibility
()
{
StringBuffer
result
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
responsibility
.
length
;
i
++)
{
if
(
i
!=
0
)
{
result
.
append
(
";"
);
}
result
.
append
(
responsibility
[
i
]);
}
return
result
.
toString
();
}
public
int
getId
()
{
return
id
;
}
public
double
getImprecisionAreaRadius
()
{
return
imprecisionAreaRadius
;
}
@Override
public
int
hashCode
()
{
return
id
;
}
public
void
setResponsibility
(
int
[]
responsibility
)
{
this
.
responsibility
=
responsibility
;
}
public
boolean
isResponsible
(
int
pState
)
{
for
(
int
i
=
0
;
i
<
responsibility
.
length
;
i
++)
{
if
(
responsibility
[
i
]
==
pState
)
{
return
true
;
}
}
return
false
;
}
@Override
public
boolean
equals
(
Object
pObj
)
{
if
(
pObj
instanceof
PrivacyLevel
)
{
return
((
PrivacyLevel
)
pObj
).
id
==
id
;
}
return
false
;
}
@Override
public
int
compareTo
(
PrivacyLevel
pArg0
)
{
int
compare
=
Double
.
compare
(
imprecisionAreaRadius
,
pArg0
.
getImprecisionAreaRadius
());
if
(
compare
==
0
)
{
compare
=
Double
.
compare
(
id
,
pArg0
.
getId
());
}
return
compare
;
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/pubsub/BypassCloudListener.java
0 → 100755
View file @
e157b605
/*
* 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.pubsub
;
import
de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayContact
;
public
interface
BypassCloudListener
{
void
onSubscribeAtBroker
(
OverlayContact
pSubscriber
,
Subscription
[]
subscriptions
);
void
onNotificationArrivedAtBroker
(
Notification
pNotification
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/pubsub/ImpactBasedPubSubComponent.java
0 → 100755
View file @
e157b605
/*
* 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.pubsub
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Attribute
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic
;
public
interface
ImpactBasedPubSubComponent
extends
PubSubComponent
{
public
Subscription
createSubscription
(
Topic
topic
,
Filter
filter
,
double
impact
);
public
Subscription
createSubscription
(
Topic
topic
,
Filter
filter
,
double
[]
impact
);
public
Subscription
createSubscription
(
Topic
topic
,
Filter
filter
,
double
[]
impact
,
double
bandwidth
);
public
Notification
createNotification
(
Topic
topic
,
List
<
Attribute
<?>>
attributes
,
double
costs
,
byte
[]
payload
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/AbstractRelevanceCalculationComponent.java
0 → 100755
View file @
e157b605
/*
* 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.relevance
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.relevance.vehicular.RelevanceCalculationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSInformationConsumer.SiSConsumerHandle
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.SiSRequest
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSType
;
public
abstract
class
AbstractRelevanceCalculationComponent
implements
RelevanceCalculationComponent
{
private
SiSComponent
_sis
;
private
Host
_host
;
private
List
<
SiSConsumerHandle
>
sisHandles
=
new
ArrayList
<>();
public
AbstractRelevanceCalculationComponent
(
Host
pHost
)
{
_host
=
pHost
;
}
public
abstract
Map
<
SiSType
<?>,
SiSRequest
>
getRequiredInformation
();
@Override
public
Host
getHost
()
{
return
_host
;
}
protected
SiSComponent
getSiS
()
{
if
(
_sis
==
null
)
{
try
{
_sis
=
getHost
().
getComponent
(
SiSComponent
.
class
);
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
e
);
}
}
return
_sis
;
}
@Override
public
void
initialize
()
{
Map
<
SiSType
<?>,
SiSRequest
>
metrics
=
getRequiredInformation
();
for
(
Map
.
Entry
<
SiSType
<?>,
SiSRequest
>
metric
:
metrics
.
entrySet
())
{
SiSConsumerHandle
handle
=
getSiS
().
get
().
rawObservations
(
metric
.
getKey
(),
metric
.
getValue
(),
null
);
sisHandles
.
add
(
handle
);
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/path/PathPredictionComponent.java
0 → 100755
View file @
e157b605
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 @
e157b605
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 @
e157b605
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
)
{
int
compare
=
Integer
.
compare
(
pPath0
.
getPath
().
getRoute
().
size
(),
pPath1
.
getPath
().
getRoute
().
size
());
if
(
compare
==
0
)
{
compare
=
-
Double
.
compare
(
pPath0
.
getProbability
(),
pPath1
.
getProbability
());
}
return
compare
;
}
}
\ No newline at end of file
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/path/StatisticalRoadNetworkRoute.java
0 → 100755
View file @
e157b605
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/relevance/vehicular/ImpactFunction.java
0 → 100755
View file @
e157b605
/*
* 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.relevance.vehicular
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
public
interface
ImpactFunction
<
T
extends
PointInformation
>
{
default
double
calculateImpact
(
T
pInformation
)
{
return
calculateImpact
(
pInformation
.
getDetectionDate
());
}
double
calculateImpact
(
long
pDetectionDate
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/vehicular/RelevanceCalculationComponent.java
0 → 100755
View file @
e157b605
/*
* 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.relevance.vehicular
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.pubsub.Notification
;
public
interface
RelevanceCalculationComponent
extends
HostComponent
{
public
double
calculateRelevance
(
INodeID
receivingNode
,
Notification
pNotification
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/
vehicular/relevance/Event
RelevanceCalculationComponent.java
→
src/de/tudarmstadt/maki/simonstrator/api/component/
relevance/vehicular/Vehicular
RelevanceCalculationComponent.java
View file @
e157b605
...
...
@@ -18,9 +18,10 @@
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.
vehicular.relevance
;
package
de.tudarmstadt.maki.simonstrator.api.component.
relevance.vehicular
;
import
de.tudarmstadt.maki.simonstrator.api.component.HostComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.VehicularPointInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
...
...
@@ -32,10 +33,16 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.Road
* @version 1.0.0
*
*/
public
interface
EventRelevanceCalculationComponent
extends
HostComponent
{
public
interface
VehicularRelevanceCalculationComponent
extends
HostComponent
,
RelevanceCalculationComponent
{
public
enum
PositionRepresentation
{
ROAD_BASED
,
LOCATION_BASED
}
PositionRepresentation
getPositionRepresentation
();
/**
* This method calculates the relevance of an event for a vehicle, combining
*
the
temporal and the geographical relevance.
* This method calculates the relevance of an event for a vehicle, combining
the
* temporal and the geographical relevance.
*
* @param pVehiclePosition
* The vehicle's position
...
...
@@ -45,6 +52,18 @@ public interface EventRelevanceCalculationComponent extends HostComponent {
*/
double
calculateRelevance
(
RoadNetworkEdge
pVehiclePosition
,
VehicularPointInformation
pInformation
);
/**
* This method calculates the relevance of an event for a vehicle, combining the
* temporal and the geographical relevance.
*
* @param pVehiclePosition
* The vehicle's position
* @param pInformation
* The information for which the relevance is calculated.
* @return The relevance of the event.
*/
double
calculateRelevance
(
Location
pLocation
,
VehicularPointInformation
pInformation
);
/**
* This method calculates the relevance of an event for a vehicle, combining
* the temporal and the geographical relevance.
...
...
@@ -56,5 +75,4 @@ public interface EventRelevanceCalculationComponent extends HostComponent {
* @return The relevance of the event.
*/
double
calculateRelevanceWithoutAnalyzer
(
RoadNetworkEdge
pVehiclePosition
,
VehicularPointInformation
pInformation
);
}
src/de/tudarmstadt/maki/simonstrator/api/component/relevance/vehicular/impl/AbstractQoIBasedImpactFunction.java
0 → 100755
View file @
e157b605
/*
* 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.relevance.vehicular.impl
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.relevance.vehicular.ImpactFunction
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.vectoral.VectoralProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AggregatedInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.AvailableInformationAttributes
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation
;
public
abstract
class
AbstractQoIBasedImpactFunction
<
T
extends
PointInformation
>
implements
ImpactFunction
<
T
>
{
protected
static
final
long
SCALING
=
Time
.
SECOND
;
protected
static
final
double
ACCURACY_FACTOR
=
100000
;
protected
double
accuracy
;
protected
double
costWrongKeep
=
1
;
protected
double
costWrongChange
=
1
;
protected
double
b
;
protected
double
rate
;
protected
double
numberOfMessages
;
protected
long
ttl
;
protected
long
maxTimestamp
;
protected
long
minTimestamp
;
protected
int
maxCacheSize
;
protected
Object
_lastDecision
;
public
AbstractQoIBasedImpactFunction
(
List
<
T
>
pInformation
,
double
pAccuracy
,
int
pMaxCacheSize
)
{
this
(
pInformation
,
pAccuracy
,
pMaxCacheSize
,
null
);
}
public
AbstractQoIBasedImpactFunction
(
List
<
T
>
pInformation
,
double
pAccuracy
,
int
pMaxCacheSize
,
Object
pLastDecision
)
{
accuracy
=
pAccuracy
;
maxCacheSize
=
pMaxCacheSize
;
_lastDecision
=
pLastDecision
;
minTimestamp
=
Long
.
MAX_VALUE
;
maxTimestamp
=
0
;
Object
value
=
pInformation
.
get
(
0
).
getValue
();
if
(
value
instanceof
VectoralProperty
)
{
value
=
((
VectoralProperty
)
value
).
getMostProbableIndex
();
}
List
<
Object
>
possibleValues
=
new
ArrayList
<>();
for
(
T
t
:
pInformation
)
{
if
(!
t
.
hasAttribute
(
AvailableInformationAttributes
.
TTL
))
{
throw
new
AssertionError
(
"Unable to perform TTL-based majority voting witout TTL"
);
}
long
timestamp
=
t
.
getDetectionDate
();
if
(
timestamp
<
minTimestamp
)
{
minTimestamp
=
timestamp
;
}
if
(
timestamp
>
maxTimestamp
)
{
maxTimestamp
=
timestamp
;
}
if
(
pInformation
instanceof
AggregatedInformation
)
{
if
(((
AggregatedInformation
)
pInformation
).
isAggregated
())
{
long
temp
=
((
AggregatedInformation
)
pInformation
).
getAggregationInformation
().
getMinTimestamp
();
if
(
temp
<
minTimestamp
)
{
minTimestamp
=
temp
;
}
}
}
Object
currentValue
=
t
.
getValue
();
if
(
currentValue
instanceof
VectoralProperty
)
{
VectoralProperty
currentProperty
=
(
VectoralProperty
)
currentValue
;
currentValue
=
currentProperty
.
getMostProbableIndex
();
for
(
int
i
=
0
;
i
<
currentProperty
.
getValueProbabilities
().
length
;
i
++)
{
if
(!
possibleValues
.
contains
(
i
))
{
possibleValues
.
add
(
i
);
}
}
}
else
{
if
(!
possibleValues
.
contains
(
currentValue
))
{
possibleValues
.
add
(
currentValue
);
}
}
}
long
difference
=
maxTimestamp
-
minTimestamp
;
int
amount
=
0
;
for
(
T
t
:
pInformation
)
{
if
(
t
instanceof
AggregatedInformation
&&
((
AggregatedInformation
)
t
).
isAggregated
())
{
amount
+=
((
AggregatedInformation
)
t
).
getAggregationInformation
().
getNumberOfIndiviualMeasurements
();
}
else
{
amount
++;
}
}
ttl
=
getTTL
(
pInformation
.
get
(
0
));
numberOfMessages
=
amount
*
ttl
*
SCALING
/
(
difference
+
Time
.
SECOND
);
rate
=
ttl
/
(
double
)
numberOfMessages
;
List
<
Double
>
bValues
=
new
ArrayList
<>();
for
(
Object
possibleValue
:
possibleValues
)
{
double
temp
=
determineB
(
pInformation
.
get
(
0
).
getValue
(),
possibleValue
,
getChangeRate
(
pInformation
.
get
(
0
),
rate
),
rate
,
1
-
pAccuracy
,
numberOfMessages
,
costWrongKeep
,
costWrongChange
);
if
(!
Double
.
isNaN
(
temp
))
{
bValues
.
add
(
temp
);
}
}
Collections
.
sort
(
bValues
);
if
(
bValues
.
size
()
>
0
)
{
if
(
bValues
.
size
()
%
2
==
0
)
{
b
=
(
bValues
.
get
(
bValues
.
size
()
/
2
)
+
bValues
.
get
(
bValues
.
size
()
/
2
-
1
))
/
2.0
;
}
else
{
b
=
bValues
.
get
(
bValues
.
size
()
/
2
);
}
}
else
{
b
=
Double
.
NEGATIVE_INFINITY
;
}
}
protected
abstract
double
determineB
(
Object
pExampleValue
,
Object
pPossibleValue
,
double
pChangeRate
,
double
pRate
,
double
pErrorProbability
,
double
pNumberOfMessages
,
double
pCostWrongKeep
,
double
pCostWrongChange
);
@Override
public
double
calculateImpact
(
long
pDetectionDate
)
{
double
impact
=
calculateImpact
(
1
-
accuracy
,
numberOfMessages
,
((
ttl
-
(
maxTimestamp
-
pDetectionDate
)
/
SCALING
)
/
(
double
)
ttl
)
*
numberOfMessages
,
b
)
/
(
accuracy
);
return
impact
;
}
protected
<
T
extends
PointInformation
>
long
getTTL
(
T
pT
)
{
return
(
long
)
pT
.
getAttribute
(
AvailableInformationAttributes
.
TTL
)
/
SCALING
;
}
protected
<
T
extends
PointInformation
>
double
getChangeRate
(
T
pT
,
double
pRate
)
{
return
getChangeProbability
((
long
)
(
getTTL
(
pT
)
/
pRate
));
}
protected
double
getChangeProbability
(
long
ttl
)
{
return
1
-
Math
.
pow
(
0.5
,
1
/
(
double
)
ttl
);
}
protected
int
getOptimalMessageAmountForSwitch
(
double
changeProbability
,
double
errorProbability
,
double
costSlow
,
double
costFast
)
{
return
(
int
)
Math
.
round
(
Math
.
log
(-
changeProbability
/
Math
.
log
(
errorProbability
)
*
costSlow
/
costFast
)
/
Math
.
log
(
errorProbability
));
}
public
double
calculateImpact
(
double
errorProbability
,
double
pNumberOfMessages
,
double
pMessageNumber
,
double
b
)
{
double
age
=
pNumberOfMessages
-
pMessageNumber
;
if
(
errorProbability
==
0
)
{
if
(
pMessageNumber
==
pNumberOfMessages
)
{
return
1
;
}
else
{
return
0
;
}
}
else
if
(
errorProbability
==
1
)
{
return
1
;
}
else
if
(
errorProbability
==
0.5
||
b
==
0
)
{
return
(
1
-
errorProbability
)
/
pNumberOfMessages
*
age
+
errorProbability
;
}
else
if
(
b
==
Double
.
NEGATIVE_INFINITY
)
{
if
(
pMessageNumber
==
pNumberOfMessages
)
{
return
1
-
errorProbability
;
}
else
{
return
0
;
}
}
else
if
(
b
==
Double
.
POSITIVE_INFINITY
)
{
return
1
;
}
return
(
1
-
errorProbability
)
*
(
Math
.
exp
(
b
*
age
)
-
Math
.
exp
(
b
*
pNumberOfMessages
))
/
(
1
-
Math
.
exp
(
b
*
pNumberOfMessages
));
}
}
Prev
1
2
3
4
5
…
7
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