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
PeerfactSim.KOM
Commits
8e78f5af
Commit
8e78f5af
authored
Mar 15, 2019
by
Tobias Meuser
Browse files
Finshed offlaoding
parent
863a0954
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/api/linklayer/mac/PhyType.java
View file @
8e78f5af
...
...
@@ -2,17 +2,17 @@
* 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/>.
*
...
...
@@ -31,10 +31,10 @@ import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.N
* all parameter-related stuff has to be implemented in the {@link Link}. This
* enum is used throughout the new {@link LinkLayer} and also on application
* level if you want to explicitly specify which component to use.
*
*
* It provides basic defaults for MTU and Drop rates in the medium, which might
* be used inside the MacLayer or as part of a {@link Link}
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 25.02.2012
*/
...
...
@@ -44,16 +44,16 @@ public enum PhyType {
* Direct wireless connections between adjacent hosts or AP-based (decided
* by the MAC/TopologyView used). Based on
* "WiFi in Ad Hoc Mode: A Meaurement Study" by Anastasi et al. (2004),
*
*
* Assuming the following defaults: 1% drop-rate of LinkLayer-Packets
* (LinkLayer might add retransmission behavior as in 802.11), 5MBit/s netto
* (802.11b) BW, 500us latency, 2,2kB MTU, Broadcast
*/
WIFI
(
NetInterfaceName
.
WIFI
,
0.01
,
5
*
Rate
.
Mbit_s
,
500
*
Time
.
MICROSECOND
,
WIFI
(
NetInterfaceName
.
WIFI
,
0.01
,
12
*
Rate
.
Mbit_s
,
500
*
Time
.
MICROSECOND
,
2334
,
true
),
/**
* A wired connection based on a TopologyView
*
*
* Assuming the following defaults: 0.1% link-layer loss, 100 Mbit/s, 1ms
* Link-Latency, 1,5kB MTU
*/
...
...
@@ -71,7 +71,7 @@ public enum PhyType {
500
*
Simulator
.
MICROSECOND_UNIT
,
1472
,
false
),
/**
*
*
* Bluetooth, short-ranged wireless transmissions between adjacent hosts
*
* Assuming the following defaults: zero link-layer packet loss, 3Mbit/s BW,
...
...
@@ -101,7 +101,7 @@ public enum PhyType {
private
NetInterfaceName
netInterfaceName
;
/**
*
*
* @param defaultDropProbability
* @param defaultRawBW
* bw in bit/s
...
...
@@ -133,7 +133,7 @@ public enum PhyType {
/**
* The Default BW of a link (unidirectional) in bit/s
*
*
* @return
*/
public
long
getDefaultBW
()
{
...
...
@@ -144,7 +144,7 @@ public enum PhyType {
* has to return true if the medium is by its nature a broadcast medium (ie.
* sending a message will prohibit sending for all other hosts in range). If
* the medium supports Multiplexing such as UMTS, set this to false.
*
*
* @return
*/
public
boolean
isBroadcastMedium
()
{
...
...
@@ -153,7 +153,7 @@ public enum PhyType {
/**
* Long-term replacement of PHY
*
*
* @return
*/
public
NetInterfaceName
getNetInterfaceName
()
{
...
...
src/de/tud/kom/p2psim/impl/linklayer/mac/AbstractMacLayer.java
View file @
8e78f5af
...
...
@@ -2,17 +2,17 @@
* 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/>.
*
...
...
@@ -60,16 +60,16 @@ import de.tudarmstadt.maki.simonstrator.api.component.network.NetID;
* As with the {@link ModularLinkLayer} you should extend this class to add a
* more advanced MAC to ensure basic functionality and consistent behavior. For
* this reason, some methods in this class are marked as final...
*
*
* If a MAC wants to implement a protocol (ie. send messages to other MACs
* without triggering a deliver to higher layers) it can do so by implementing a
* corresponding Message type and/or {@link MacEventInformation}. <b>A Message
* is only delivered to the higher layers if notifyLinkLayer is called</b>.
*
*
* This Layer takes care of energy consumption, as long as the sendUnicast and
* sendBroadcast-methods are used to dispatch all messages (also the
* control-messages, if a protocol is implemented)
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 21.02.2012
*/
...
...
@@ -98,7 +98,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* Our own MacAddress on this PHY
*/
private
MacAddress
macAddress
;
/**
* Our own IP used by the NetLayer on this PHY. Not available during initialization.
*/
...
...
@@ -127,7 +127,7 @@ public abstract class AbstractMacLayer implements MacLayer {
private
final
boolean
enableErrorControl
;
/**
*
*
*/
private
boolean
isOnline
;
...
...
@@ -156,7 +156,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* Returns an approximation of the current bandwidth
*/
protected
final
BandwidthEstimator
currentBandwidth
;
private
final
Random
random
=
Randoms
.
getRandom
(
AbstractMacLayer
.
class
);
/*
...
...
@@ -179,7 +179,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Create a new MacLayer without bounds on the outgoing message queue (ie.
* endless size, no limit on the waiting time).
*
*
* @param ownMacAddress
* @param phy
* @param maxRetransmissions
...
...
@@ -198,7 +198,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Create a new MacLayer with a bounded outgoing queue (max length) and a
* timeout for messages in said queue.
*
*
* @param ownMacAddress
* @param phy
* @param maxQueueLength
...
...
@@ -291,7 +291,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Use this component to account for energy consumption. This is safe to
* use, as it is always backed by a stub - it is never null.
*
*
* @return
*/
@Override
...
...
@@ -301,7 +301,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Current size of the outgoing Queue
*
*
* @return
*/
protected
final
int
getQueueSize
()
{
...
...
@@ -310,7 +310,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Maximum length of the outgoing queue, if equal to zero there is no limit
*
*
* @return
*/
protected
final
int
getMaxQueueLength
()
{
...
...
@@ -319,7 +319,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Gets the maximal retransmissions.
*
*
* @return the maximal retransmissions.
*/
public
final
int
getMaxRetransmissions
()
{
...
...
@@ -329,7 +329,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Maximum time a message is kept in the outgoing queue. If equal to zero
* there is no limit.
*
*
* @return
*/
protected
final
long
getMaxTimeInQueue
()
{
...
...
@@ -339,7 +339,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Retrieves and <b>removes</b> the first element in the Queue, after all
* entries that already timed out are deleted.
*
*
* @return
*/
protected
final
QueueEntry
getQueueHead
()
{
...
...
@@ -351,7 +351,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* Removes all messages that are already waiting longer than maxTimeInQueue,
* notifying messageDropped() for each dropped message. The reason will be
* QUEUE_TIMEOUT in this case.
*
*
*/
private
void
removeOutdatedQueueEntries
()
{
if
(
maxTimeInQueue
==
0
)
{
...
...
@@ -371,11 +371,11 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* This is called whenever a drop occurs within the MAC/PHY. A great
* opportunity to add an Analyzer or some error handling for higher layers.
*
*
* Please note, that this might happen asynchronously - the messages are not
* removed from the queue the second their timeout expires but instead as
* soon as a new send() or a new getQueueHead() is issued.
*
*
* @param reason
* @param msg
*/
...
...
@@ -402,7 +402,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Notification: a message arrived!
*
*
* @param message
* the message itself
* @param info
...
...
@@ -413,7 +413,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* This is to be called by the MAC if a Message should be passed to upper
* layers (ie. it is no MAC_ctrl-Message)
*
*
* @param eventInfo
*/
protected
final
void
notifyLinkLayer
(
LinkMessageEvent
eventInfo
)
{
...
...
@@ -424,7 +424,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Send a Message to the MAC on the receiver-side (event scheduling).
*
*
* @param receiver
* @param eventInformation
* @param delay
...
...
@@ -454,7 +454,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Use this method to dispatch a broadcast message in your MAC-Layer. It
* will take care of energy consumption and scheduling.
*
*
* @param eventInfo
* an implementation of {@link MacEventInformation} containing
* information about the message to send as well as the message
...
...
@@ -516,7 +516,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Send an unicast message
*
*
* @param toSend
*/
protected
final
long
sendUnicast
(
MacEventInformation
eventInfo
)
{
...
...
@@ -592,13 +592,13 @@ public abstract class AbstractMacLayer implements MacLayer {
* broadcast, the BW should be constant across all links (we assume the PHY
* selects a fixed, more robust modulation for Broadcasts), as there is no
* handshaking. Therefore, Broadcasts have no retransmits.
*
*
* This method <b>must be called exactly once</b> for every receiver of a
* message (in the unicast case, it will be called only once). The receiver
* is determined by the link-object. Access this method via the sendUnicast
* and sendBroadcast methods to ensure correct behavior of all callbacks and
* events.
*
*
* @param eventInfo
* containing the Message
* @param l
...
...
@@ -758,10 +758,10 @@ public abstract class AbstractMacLayer implements MacLayer {
* sending would be possible at the full RawBandwidth of the PHY). A more
* advanced MAC will add some coding (making the message larger) and access
* control scheme for multiple transmissions.
*
*
* This time is later used to account for energy consumption at sender and
* receiver.
*
*
* @param msg
* @param l
* @return
...
...
@@ -782,7 +782,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* Overwrite this method to implement additional event handling, if needed.
*
*
* @param se
*/
protected
void
handleEvent
(
Object
data
,
int
type
)
{
...
...
@@ -896,7 +896,7 @@ public abstract class AbstractMacLayer implements MacLayer {
public
final
MacAddress
getMacAddress
()
{
return
macAddress
;
}
@Override
public
NetID
getNetId
()
{
if
(
netID
==
null
)
{
...
...
@@ -926,7 +926,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/**
* An entry in the Message queue of the MAC
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 21.02.2012
*/
...
...
@@ -965,7 +965,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* A Stub for an {@link EnergyCommunicationComponent} to allow simulations
* without an energy model. Otherwise we would have to flood the code with
* if == null statements.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 27.02.2012
*/
...
...
@@ -1028,14 +1028,14 @@ public abstract class AbstractMacLayer implements MacLayer {
@Override
public
void
doFakeStateChange
()
{
// TODO Auto-generated method stub
}
}
/**
* A Live-Analyzer that aggregates Message Drop reasons inside the MAC.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 26.03.2012
*/
...
...
src/de/tud/kom/p2psim/impl/linklayer/mac/EnqueuingMac.java
View file @
8e78f5af
...
...
@@ -2,17 +2,17 @@
* 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/>.
*
...
...
@@ -37,7 +37,7 @@ import de.tudarmstadt.maki.simonstrator.api.Time;
* the other (this does not imply that this MAC handles collisions on a
* broadcast medium). It just mimics the behavior of the ModularNetLayer with a
* TrafficControl-Strategy enabled.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 24.03.2012
*/
...
...
@@ -64,7 +64,7 @@ public class EnqueuingMac extends AbstractMacLayer {
* A MAC that provides an outgoing queue (messages are sent one after the
* other). This may lead to packet drop if the queue is bound or if a
* timeout is configured and the message has been in the queue for too long.
*
*
* @param ownMacAddress
* @param phy
* @param maxQueueLength
...
...
src/de/tud/kom/p2psim/impl/scenario/DefaultConfigurator.java
View file @
8e78f5af
...
...
@@ -145,6 +145,8 @@ public class DefaultConfigurator implements Configurator {
private
Map
<
String
,
String
>
variables
=
new
LinkedHashMap
<
String
,
String
>();
private
boolean
_parseOnly
=
false
;
/**
* Create new configurator instance with the configuration data in the given
* XML file.
...
...
@@ -199,6 +201,13 @@ public class DefaultConfigurator implements Configurator {
}
}
public
Map
<
String
,
String
>
parseAllDefaults
()
throws
ConfigurationException
{
_parseOnly
=
true
;
configureAll
();
_parseOnly
=
false
;
return
getVariables
();
}
/**
* Configure all components of the simulator. The single components are
* either registered via the <code>register(name, component)</code> method
...
...
@@ -273,7 +282,9 @@ public class DefaultConfigurator implements Configurator {
}
else
if
(
elem
.
getName
().
equals
(
Configurator
.
DEFAULT_TAG
))
{
configureDefaults
(
elem
);
}
else
{
configureComponent
(
elem
);
if
(!
_parseOnly
)
{
configureComponent
(
elem
);
}
}
}
}
...
...
src/de/tud/kom/p2psim/impl/vehicular/caching/DefaultCachingComponent.java
View file @
8e78f5af
...
...
@@ -416,7 +416,10 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
@Override
public
String
getNodeDescription
()
{
return
" "
+
getHost
().
getId
();
if
(
getHost
().
getId
().
value
()
>
47
)
{
return
" "
+
getHost
().
getId
();
}
return
""
;
}
@Override
...
...
src/de/tud/kom/p2psim/impl/vehicular/decision/AbstractVehicleDecisionComponent.java
View file @
8e78f5af
...
...
@@ -20,6 +20,8 @@
package
de.tud.kom.p2psim.impl.vehicular.decision
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
...
...
@@ -27,6 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Monitor;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.AnalyzerNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.EnvironmentSensor
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.Environment
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleDecisionComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.CachingComponent
;
...
...
@@ -45,6 +49,8 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
private
boolean
_routeAnalyzerInit
=
false
;
private
VehicleRouteAnalyzer
_routeAnalyzer
=
null
;
private
EnvironmentSensor
_sensors
;
public
AbstractVehicleDecisionComponent
(
Host
pHost
)
{
_host
=
pHost
;
}
...
...
@@ -52,7 +58,8 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
@Override
public
void
initialize
()
{
try
{
_cache
=
getHost
().
getComponent
(
CachingComponent
.
class
);
_cache
=
getHost
().
getComponent
(
CachingComponent
.
class
);
_sensors
=
getHost
().
getComponent
(
EnvironmentSensor
.
class
);
}
catch
(
ComponentNotAvailableException
e
)
{
throw
new
AssertionError
(
e
);
}
...
...
@@ -90,29 +97,27 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
case
EVENT_DECISION_MAKING_CYCLE:
RoadNetworkRoute
currentRoute
=
getVehicleInformation
().
getCurrentRoute
();
if
(
currentRoute
!=
null
&&
currentRoute
.
getRoute
().
size
()
>
2
)
{
if
(
currentRoute
!=
null
)
{
boolean
changed
=
false
;
BenefitBasedRoute
optimalRouteWithBenefit
=
getOptimalRoute
(
currentRoute
,
_cache
.
getDecidedCacheEntries
(
RoadInformation
.
class
));
if
(
optimalRouteWithBenefit
!=
null
)
{
RoadNetworkRoute
optimalRoute
=
optimalRouteWithBenefit
.
getRoute
();
if
(
optimalRouteWithBenefit
.
getRoute
().
getRoute
().
size
()
>
1
)
{
if
(
currentRoute
.
getRoute
().
get
(
1
)
!=
optimalRoute
.
getRoute
().
get
(
1
))
{
if
(
hasRouteAnalyzer
())
{
getRouteAnalyzer
().
routeChanged
(
getHost
().
getId
(),
currentRoute
,
optimalRoute
);
}
changed
=
true
;
getVehicleInformation
().
changeCurrentRoute
(
optimalRouteWithBenefit
.
getRoute
());
}
}
}
if
(!
changed
)
{
if
(
hasRouteAnalyzer
())
{
getRouteAnalyzer
().
routeUnchanged
(
getHost
().
getId
(),
currentRoute
);
}
}
if
(
currentRoute
.
getRoute
().
size
()
>
2
)
{
BenefitBasedRoute
optimalRouteWithBenefit
=
getOptimalRoute
(
currentRoute
,
_cache
.
getDecidedCacheEntries
(
RoadInformation
.
class
),
_sensors
.
getEnvironment
());
if
(
optimalRouteWithBenefit
!=
null
)
{
RoadNetworkRoute
optimalRoute
=
optimalRouteWithBenefit
.
getRoute
();
if
(
optimalRouteWithBenefit
.
getRoute
().
getRoute
().
size
()
>
1
)
{
if
(
currentRoute
.
getRoute
().
get
(
1
)
!=
optimalRoute
.
getRoute
().
get
(
1
))
{
if
(
hasRouteAnalyzer
())
{
getRouteAnalyzer
().
routeChanged
(
getHost
().
getId
(),
currentRoute
,
optimalRoute
);
}
changed
=
true
;
getVehicleInformation
().
changeCurrentRoute
(
optimalRouteWithBenefit
.
getRoute
());
}
}
}
}
if
(!
changed
&&
hasRouteAnalyzer
())
{
getRouteAnalyzer
().
routeUnchanged
(
getHost
().
getId
(),
currentRoute
);
}
}
Event
.
scheduleWithDelay
(
Time
.
SECOND
,
this
,
null
,
EVENT_DECISION_MAKING_CYCLE
);
...
...
src/de/tud/kom/p2psim/impl/vehicular/decision/DefaultVehicleDecisionComponent.java
View file @
8e78f5af
...
...
@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.impl.vehicular.decision;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
...
...
src/de/tud/kom/p2psim/impl/vehicular/decision/LatestPossibleVehicleDecisionComponent.java
0 → 100755
View file @
8e78f5af
/*
* 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.tud.kom.p2psim.impl.vehicular.decision
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
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.routing.DijkstraAlgorithm
;
public
class
LatestPossibleVehicleDecisionComponent
extends
AbstractVehicleDecisionComponent
{
public
LatestPossibleVehicleDecisionComponent
(
Host
pHost
)
{
super
(
pHost
);
}
@Override
public
BenefitBasedRoute
getOptimalRoute
(
RoadNetworkRoute
pInvestigatedRoute
,
List
<
RoadInformation
>
knownInformation
)
{
List
<
RoadInformation
>
actualKnownInformation
=
new
ArrayList
<>();
if
(
getVehicleInformation
().
isValid
()
&&
knownInformation
!=
null
)
{
for
(
RoadInformation
roadInformation
:
knownInformation
)
{
RoadProperty
property
=
roadInformation
.
getValue
();
if
(!
property
.
getValue
().
equals
(
property
.
getDefaultProperty
().
getValue
()))
{
if
(
pInvestigatedRoute
.
getStart
().
getAccessibleEdges
().
contains
(
roadInformation
.
getEdge
()))
{
actualKnownInformation
.
add
(
roadInformation
);
}
}
}
DijkstraAlgorithm
dijkstraAlgorithm
=
new
DijkstraAlgorithm
();
List
<
RoadNetworkEdge
>
blocked
=
new
ArrayList
<>();
for
(
RoadInformation
roadInformation
:
actualKnownInformation
)
{
if
(!
blocked
.
contains
(
roadInformation
.
getEdge
()))
{
blocked
.
add
(
roadInformation
.
getEdge
());
}
}
RoadNetworkRoute
route
=
dijkstraAlgorithm
.
findRoute
(
RoadNetwork
.
CURRENT_ROAD_NETWORK
,
getVehicleInformation
().
getCurrentRoute
().
getStart
(),
getVehicleInformation
().
getCurrentRoute
().
getDestination
(),
Collections
.
emptyList
(),
blocked
);
if
(
route
!=
null
)
{
double
oldCosts
=
0
;
for
(
RoadNetworkEdge
edge
:
pInvestigatedRoute
.
getRoute
())
{
oldCosts
+=
edge
.
calculateStandardEdgeCosts
();
if
(
knownInformation
!=
null
)
{
for
(
RoadInformation
roadInformation
:
actualKnownInformation
)
{
oldCosts
+=
edge
.
calculateAdditionalCostIfKnown
(
roadInformation
.
getValue
());
}
}
}
double
newCosts
=
0
;
for
(
RoadNetworkEdge
edge
:
route
.
getRoute
())
{
newCosts
+=
edge
.
calculateStandardEdgeCosts
();
if
(
knownInformation
!=
null
)
{
for
(
RoadInformation
roadInformation
:
actualKnownInformation
)
{
newCosts
+=
edge
.
calculateAdditionalCostIfKnown
(
roadInformation
.
getValue
());
}
}
}
if
(
oldCosts
>
newCosts
)
{
return
new
BenefitBasedRoute
(
oldCosts
-
newCosts
,
route
);
}
}
return
new
BenefitBasedRoute
(
0
,
pInvestigatedRoute
);
}
return
null
;
}
}
src/de/tud/kom/p2psim/impl/vehicular/decision/VisionBasedVehicleDecisionComponent.java
View file @
8e78f5af
...
...
@@ -25,6 +25,7 @@ import java.util.Collections;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.Environment
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork
;
...
...
@@ -39,24 +40,34 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision
}
@Override
public
BenefitBasedRoute
getOptimalRoute
(
RoadNetworkRoute
pInvestigatedRoute
,
List
<
RoadInformation
>
knownInformation
)
{
List
<
RoadInformation
>
actualKnownInformation
=
new
ArrayList
<>();
public
BenefitBasedRoute
getOptimalRoute
(
RoadNetworkRoute
pInvestigatedRoute
,
List
<
RoadInformation
>
pKnownInformation
)
{
return
new
BenefitBasedRoute
(
0
,
pInvestigatedRoute
);
}
@Override
public
BenefitBasedRoute
getOptimalRoute
(
RoadNetworkRoute
pInvestigatedRoute
,
List
<
RoadInformation
>
knownInformation
,
Environment
pEnvironment
)
{
List
<
RoadProperty
>
actualKnownInformation
=
new
ArrayList
<>();
if
(
getVehicleInformation
().
isValid
()
&&
knownInformation
!=
null
)
{
for
(
RoadInformation
roadInformation
:
knownInformation
)
{
RoadProperty
property
=
roadInformation
.
getValue
();
if
(!
property
.
getValue
().
equals
(
property
.
getDefaultProperty
().
getValue
()))
{
if
(
pInvestigatedRoute
.
getStart
().
getAccessibleEdges
().
contains
(
roadInformation
.
getEdge
()))
{
actualKnownInformation
.
add
(
roadInformation
);
if
(
getVehicleInformation
().
isValid
())
{
if
(
knownInformation
!=
null
)
{
for
(
RoadInformation
roadInformation
:
knownInformation
)
{
RoadProperty
property
=
roadInformation
.
getValue
();
if
(!
property
.
getValue
().
equals
(
property
.
getDefaultProperty
().
getValue
()))
{
if
(
pInvestigatedRoute
.
getStart
().
getAccessibleEdges
().
contains
(
roadInformation
.
getEdge
()))
{
actualKnownInformation
.
add
(
roadInformation
.
getValue
());
}
}
}
}
actualKnownInformation
.
addAll
(
pEnvironment
.
getProperties
(
RoadProperty
.
class
));
DijkstraAlgorithm
dijkstraAlgorithm
=
new
DijkstraAlgorithm
();
List
<
RoadNetworkEdge
>
blocked
=
new
ArrayList
<>();
for
(
Road
Information
roadInformation
:
actualKnownInformation
)
{
if
(!
blocked
.
contains
(
roadInformation
.
getEdge
()))
{
for
(
Road
Property
roadInformation
:
actualKnownInformation
)
{
if
(!
blocked
.
contains
(
roadInformation
.
getEdge
())
&&
roadInformation
.
getEdge
().
isActive
()
)
{
blocked
.
add
(
roadInformation
.
getEdge
());
}
}
...
...
@@ -66,20 +77,16 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision
double
oldCosts
=
0
;
for
(
RoadNetworkEdge
edge
:
pInvestigatedRoute
.
getRoute
())
{
oldCosts
+=
edge
.
calculateStandardEdgeCosts
();
if
(
knownInformation
!=
null
)
{
for
(
RoadInformation
roadInformation
:
actualKnownInformation
)
{
oldCosts
+=
edge
.
calculateAdditionalCostIfKnown
(
roadInformation
.
getValue
());
}
for
(
RoadProperty
roadInformation
:
actualKnownInformation
)
{
oldCosts
+=
edge
.
calculateAdditionalCostIfKnown
(
roadInformation
);
}
}
double
newCosts
=
0
;
for
(
RoadNetworkEdge
edge
:
route
.
getRoute
())
{
newCosts
+=
edge
.
calculateStandardEdgeCosts
();
if
(
knownInformation
!=
null
)
{
for
(
RoadInformation
roadInformation
:
actualKnownInformation
)
{
newCosts
+=
edge
.
calculateAdditionalCostIfKnown
(
roadInformation
.
getValue
());
}
for
(
RoadProperty
roadInformation
:
actualKnownInformation
)
{
newCosts
+=
edge
.
calculateAdditionalCostIfKnown
(
roadInformation
);
}
}
...
...
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