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
dd725273
Commit
dd725273
authored
Nov 30, 2020
by
Julian Zobel
Browse files
Distributions for Movement Model speeds
Static & Gaussian Distributions
parent
623f8b8f
Changes
9
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/api/topology/movement/MovementModel.java
View file @
dd725273
...
@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.api.topology.movement;
...
@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.api.topology.movement;
import
java.util.Set
;
import
java.util.Set
;
import
de.tud.kom.p2psim.api.topology.TopologyComponent
;
import
de.tud.kom.p2psim.api.topology.TopologyComponent
;
import
de.tud.kom.p2psim.impl.topology.movement.distributions.ISpeedDistributionProvider
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint
;
/**
/**
...
@@ -98,4 +99,13 @@ public interface MovementModel {
...
@@ -98,4 +99,13 @@ public interface MovementModel {
*/
*/
public
void
setTimeBetweenMoveOperations
(
long
time
);
public
void
setTimeBetweenMoveOperations
(
long
time
);
/**
* OPTIONAL: returns a movement speed provided by the model
*
* @return
*/
default
public
ISpeedDistributionProvider
getMovementSpeedDistribution
()
{
throw
new
UnsupportedOperationException
();
}
}
}
src/de/tud/kom/p2psim/impl/topology/component/DefaultTopologyComponent.java
View file @
dd725273
...
@@ -25,12 +25,10 @@ import java.util.Set;
...
@@ -25,12 +25,10 @@ import java.util.Set;
import
de.tud.kom.p2psim.api.common.HostProperties
;
import
de.tud.kom.p2psim.api.common.HostProperties
;
import
de.tud.kom.p2psim.api.common.SimHost
;
import
de.tud.kom.p2psim.api.common.SimHost
;
import
de.tud.kom.p2psim.api.topology.Topology
;
import
de.tud.kom.p2psim.api.topology.Topology
;
import
de.tud.kom.p2psim.api.topology.TopologyComponent
;
import
de.tud.kom.p2psim.api.topology.TopologyComponent
;
import
de.tud.kom.p2psim.api.topology.movement.MovementModel
;
import
de.tud.kom.p2psim.api.topology.movement.MovementModel
;
import
de.tud.kom.p2psim.api.topology.placement.PlacementModel
;
import
de.tud.kom.p2psim.api.topology.placement.PlacementModel
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint
;
...
@@ -48,7 +46,6 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
...
@@ -48,7 +46,6 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
private
double
currentMovementSpeed
=
-
1
;
private
double
currentMovementSpeed
=
-
1
;
/**
/**
* Create a TopologyComponent for the current host.
* Create a TopologyComponent for the current host.
*
*
...
@@ -68,16 +65,29 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
...
@@ -68,16 +65,29 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
@Override
@Override
public
double
getMinMovementSpeed
()
{
public
double
getMinMovementSpeed
()
{
try
{
return
movementModel
.
getMovementSpeedDistribution
().
getMinSpeed
();
}
catch
(
UnsupportedOperationException
e
)
{
// FIXME should not be used in the future anymore
// fallback
HostProperties
properties
=
getHost
().
getProperties
();
HostProperties
properties
=
getHost
().
getProperties
();
return
properties
.
getMinMovementSpeed
();
return
properties
.
getMinMovementSpeed
();
}
}
}
@Override
@Override
public
double
getMaxMovementSpeed
()
{
public
double
getMaxMovementSpeed
()
{
try
{
return
movementModel
.
getMovementSpeedDistribution
().
getMaxSpeed
();
}
catch
(
UnsupportedOperationException
e
)
{
// FIXME should not be used in the future anymore
// fallback
HostProperties
properties
=
getHost
().
getProperties
();
HostProperties
properties
=
getHost
().
getProperties
();
return
properties
.
getMaxMovementSpeed
();
return
properties
.
getMaxMovementSpeed
();
}
}
}
private
void
calcRandomMovementSpeed
()
{
private
void
calcRandomMovementSpeed
()
{
double
min_speed
=
getMinMovementSpeed
();
double
min_speed
=
getMinMovementSpeed
();
...
@@ -90,9 +100,18 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
...
@@ -90,9 +100,18 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
@Override
@Override
public
double
getMovementSpeed
()
{
public
double
getMovementSpeed
()
{
try
{
if
(
currentMovementSpeed
==
-
1
)
{
this
.
currentMovementSpeed
=
movementModel
.
getMovementSpeedDistribution
().
calculateSpeed
();
}
}
catch
(
UnsupportedOperationException
e
)
{
if
(
currentMovementSpeed
==
-
1
)
{
if
(
currentMovementSpeed
==
-
1
)
{
calcRandomMovementSpeed
();
calcRandomMovementSpeed
();
}
}
}
return
this
.
currentMovementSpeed
;
return
this
.
currentMovementSpeed
;
}
}
...
@@ -117,6 +136,7 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
...
@@ -117,6 +136,7 @@ public class DefaultTopologyComponent extends AbstractTopologyComponent {
return
movementModel
.
getAllAttractionPoints
();
return
movementModel
.
getAllAttractionPoints
();
}
}
public
static
class
Factory
implements
TopologyComponentFactory
{
public
static
class
Factory
implements
TopologyComponentFactory
{
@Override
@Override
...
...
src/de/tud/kom/p2psim/impl/topology/movement/distributions/GaussianSpeedDistribution.java
0 → 100644
View file @
dd725273
/*
* 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.topology.movement.distributions
;
import
java.util.Random
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
public
class
GaussianSpeedDistribution
implements
ISpeedDistributionProvider
{
private
Random
random
=
Randoms
.
getRandom
(
GaussianSpeedDistribution
.
class
);
private
double
std
;
private
double
mean
;
private
double
min
=
0
;
private
double
max
=
10
;
@Override
public
double
getMaxSpeed
()
{
return
max
;
}
@Override
public
double
getMinSpeed
()
{
return
min
;
}
@Override
public
double
calculateSpeed
()
{
double
speed
=
random
.
nextGaussian
()
*
std
+
mean
;
Math
.
min
(
speed
,
max
);
Math
.
max
(
speed
,
min
);
return
speed
;
}
public
void
setStd
(
double
std
)
{
this
.
std
=
std
;
}
public
void
setMean
(
double
mean
)
{
this
.
mean
=
mean
;
}
public
void
setMin
(
double
min
)
{
this
.
min
=
min
;
}
public
void
setMax
(
double
max
)
{
this
.
max
=
max
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/distributions/ISpeedDistributionProvider.java
0 → 100644
View file @
dd725273
/*
* 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.topology.movement.distributions
;
/**
* Interface for the provision of speed distributions.
*
* @author Julian Zobel
* @version 1.0, 30.11.2020
*/
public
interface
ISpeedDistributionProvider
{
/**
* Minimum speed provided by this distribution.
*
* @return
*/
public
double
getMinSpeed
();
/**
* Maximum speed provided by this distribution.
*
* @return
*/
public
double
getMaxSpeed
();
/**
* Draw a speed value from this speed distribution.
*
* @return
*/
public
double
calculateSpeed
();
}
src/de/tud/kom/p2psim/impl/topology/movement/distributions/StaticSpeedDistribution.java
0 → 100644
View file @
dd725273
/*
* 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.topology.movement.distributions
;
/**
* Static speed distribution provider, always returns 0.
*
* @author Julian Zobel
* @version 1.0, 30.11.2020
*/
public
class
StaticSpeedDistribution
implements
ISpeedDistributionProvider
{
private
double
value
=
0
;
@Override
public
double
getMinSpeed
()
{
return
value
;
}
@Override
public
double
getMaxSpeed
()
{
return
value
;
}
@Override
public
double
calculateSpeed
()
{
return
value
;
}
public
void
setValue
(
double
value
)
{
this
.
value
=
value
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/ModularMovementModel.java
View file @
dd725273
...
@@ -23,9 +23,7 @@ package de.tud.kom.p2psim.impl.topology.movement.modularosm;
...
@@ -23,9 +23,7 @@ package de.tud.kom.p2psim.impl.topology.movement.modularosm;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.Set
;
import
java.util.Vector
;
import
java.util.Vector
;
import
de.tud.kom.p2psim.api.scenario.ConfigurationException
;
import
de.tud.kom.p2psim.api.scenario.ConfigurationException
;
...
@@ -37,6 +35,7 @@ import de.tud.kom.p2psim.api.topology.placement.PlacementModel;
...
@@ -37,6 +35,7 @@ import de.tud.kom.p2psim.api.topology.placement.PlacementModel;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tud.kom.p2psim.impl.topology.DefaultTopology
;
import
de.tud.kom.p2psim.impl.topology.DefaultTopology
;
import
de.tud.kom.p2psim.impl.topology.TopologyFactory
;
import
de.tud.kom.p2psim.impl.topology.TopologyFactory
;
import
de.tud.kom.p2psim.impl.topology.movement.distributions.ISpeedDistributionProvider
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.AttractionPointViz
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.AttractionPointViz
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractionProvider
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractionProvider
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.MobileAttractionPoint
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.MobileAttractionPoint
;
...
@@ -107,6 +106,8 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
...
@@ -107,6 +106,8 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
protected
IAttractionProvider
attractionProvider
;
protected
IAttractionProvider
attractionProvider
;
protected
ISpeedDistributionProvider
speedProvider
;
protected
LocalMovementStrategy
localMovementStrategy
;
protected
LocalMovementStrategy
localMovementStrategy
;
protected
IMapVisualization
mapVisualization
;
protected
IMapVisualization
mapVisualization
;
...
@@ -229,6 +230,10 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
...
@@ -229,6 +230,10 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
throw
new
ConfigurationException
(
throw
new
ConfigurationException
(
"TransitionStrategy is missing in ModularMovementModel!"
);
"TransitionStrategy is missing in ModularMovementModel!"
);
}
}
if
(
speedProvider
==
null
)
{
throw
new
ConfigurationException
(
"SpeedDistributionProvider is missing in ModularMovementModel!"
);
}
}
}
@Override
@Override
...
@@ -361,6 +366,11 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
...
@@ -361,6 +366,11 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
}
}
}
}
@Override
public
ISpeedDistributionProvider
getMovementSpeedDistribution
()
{
return
speedProvider
;
}
/*
/*
* =====================================================================================================
* =====================================================================================================
* === GETTER AND SETTER FUNCTIONS
* === GETTER AND SETTER FUNCTIONS
...
@@ -389,6 +399,15 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
...
@@ -389,6 +399,15 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
this
.
attractionProvider
=
attractionProvider
;
this
.
attractionProvider
=
attractionProvider
;
}
}
public
void
setISpeedDistributionProvider
(
ISpeedDistributionProvider
speedDistributionProvider
)
{
if
(
speedDistributionProvider
==
null
)
{
throw
new
ConfigurationException
(
"SpeedDistributionProvider is missing in ModularMovementModel!"
);
}
this
.
speedProvider
=
speedDistributionProvider
;
}
public
void
setLocalMovementStrategy
(
LocalMovementStrategy
localMovementStrategy
)
{
public
void
setLocalMovementStrategy
(
LocalMovementStrategy
localMovementStrategy
)
{
if
(
localMovementStrategy
==
null
)
{
if
(
localMovementStrategy
==
null
)
{
throw
new
ConfigurationException
(
throw
new
ConfigurationException
(
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/SocialGroupMovementModel.java
View file @
dd725273
...
@@ -57,12 +57,9 @@ public class SocialGroupMovementModel extends ModularMovementModel {
...
@@ -57,12 +57,9 @@ public class SocialGroupMovementModel extends ModularMovementModel {
protected
IAttractionAssigmentStrategy
groupAttractionAssignment
;
protected
IAttractionAssigmentStrategy
groupAttractionAssignment
;
private
LinkedHashSet
<
SimLocationActuator
>
singleHosts
=
new
LinkedHashSet
<
SimLocationActuator
>();
private
LinkedHashSet
<
SimLocationActuator
>
singleHosts
=
new
LinkedHashSet
<
SimLocationActuator
>();
private
int
numberOfSingleHosts
;
private
int
numberOfSingleHosts
;
@Override
@Override
public
void
initialize
()
{
public
void
initialize
()
{
...
@@ -321,10 +318,11 @@ public class SocialGroupMovementModel extends ModularMovementModel {
...
@@ -321,10 +318,11 @@ public class SocialGroupMovementModel extends ModularMovementModel {
@Override
@Override
public
void
changeTargetLocation
(
SimLocationActuator
actuator
,
IAttractionPoint
ap
)
{
public
void
changeTargetLocation
(
SimLocationActuator
actuator
,
IAttractionPoint
ap
)
{
if
(
singleHosts
.
contains
(
actuator
))
{
if
(
singleHosts
.
contains
(
actuator
))
{
attractionAssigment
.
updateTargetAttractionPoint
(
actuator
,
ap
);
super
.
changeTargetLocation
(
actuator
,
ap
);
}
}
else
{
else
{
groupAttractionAssignment
.
updateTargetAttractionPoint
(
actuator
,
ap
);
groupAttractionAssignment
.
updateTargetAttractionPoint
(
actuator
,
ap
);
actuator
.
setMovementSpeed
(
this
.
speedProvider
.
calculateSpeed
());
}
}
}
}
...
@@ -475,5 +473,4 @@ public class SocialGroupMovementModel extends ModularMovementModel {
...
@@ -475,5 +473,4 @@ public class SocialGroupMovementModel extends ModularMovementModel {
this
.
groupAttractionAssignment
=
groupAttractionAssignment
;
this
.
groupAttractionAssignment
=
groupAttractionAssignment
;
}
}
}
}
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/AttractionPointRoamingStrategy.java
View file @
dd725273
...
@@ -23,9 +23,9 @@ package de.tud.kom.p2psim.impl.topology.movement.modularosm.transition;
...
@@ -23,9 +23,9 @@ package de.tud.kom.p2psim.impl.topology.movement.modularosm.transition;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
de.tud.kom.p2psim.api.topology.movement.SimLocationActuator
;
import
de.tud.kom.p2psim.api.topology.movement.SimLocationActuator
;
import
de.tud.kom.p2psim.impl.topology.movement.distributions.ISpeedDistributionProvider
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ISocialGroupMovementAnalyzer
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ISocialGroupMovementAnalyzer
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ModularMovementModel
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ModularMovementModel
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractionProvider
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.Monitor
;
import
de.tudarmstadt.maki.simonstrator.api.Monitor
;
...
@@ -47,6 +47,8 @@ public class AttractionPointRoamingStrategy extends AbstractAttractionBasedAssig
...
@@ -47,6 +47,8 @@ public class AttractionPointRoamingStrategy extends AbstractAttractionBasedAssig
ROAMING
ROAMING
}
}
protected
ISpeedDistributionProvider
roamSpeedProvider
;
protected
Map
<
SimLocationActuator
,
roamingTransitionState
>
roamingStates
=
new
LinkedHashMap
<>();
protected
Map
<
SimLocationActuator
,
roamingTransitionState
>
roamingStates
=
new
LinkedHashMap
<>();
@XMLConfigurableConstructor
({
"defaultPauseTimeMin"
,
"defaultPauseTimeMax"
})
@XMLConfigurableConstructor
({
"defaultPauseTimeMin"
,
"defaultPauseTimeMax"
})
...
@@ -58,6 +60,10 @@ public class AttractionPointRoamingStrategy extends AbstractAttractionBasedAssig
...
@@ -58,6 +60,10 @@ public class AttractionPointRoamingStrategy extends AbstractAttractionBasedAssig
public
void
addComponent
(
SimLocationActuator
comp
)
{
public
void
addComponent
(
SimLocationActuator
comp
)
{
this
.
roamingStates
.
put
(
comp
,
null
);
this
.
roamingStates
.
put
(
comp
,
null
);
IAttractionPoint
nextAP
=
getNewAttractionPointAssignment
(
comp
);
IAttractionPoint
nextAP
=
getNewAttractionPointAssignment
(
comp
);
// trigger recalculation of speed
comp
.
setMovementSpeed
(-
1
);
updateTargetAttractionPoint
(
comp
,
nextAP
);
updateTargetAttractionPoint
(
comp
,
nextAP
);
}
}
...
@@ -90,6 +96,9 @@ public class AttractionPointRoamingStrategy extends AbstractAttractionBasedAssig
...
@@ -90,6 +96,9 @@ public class AttractionPointRoamingStrategy extends AbstractAttractionBasedAssig
if
(
roamingStates
.
get
(
comp
)
==
roamingTransitionState
.
PAUSE
)
{
if
(
roamingStates
.
get
(
comp
)
==
roamingTransitionState
.
PAUSE
)
{
IAttractionPoint
currentAttractionPoint
=
this
.
assignments
.
get
(
comp
);
IAttractionPoint
currentAttractionPoint
=
this
.
assignments
.
get
(
comp
);
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
ROAMING
);
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
ROAMING
);
comp
.
setMovementSpeed
(
roamSpeedProvider
.
calculateSpeed
());
notifyListenersOfAssignmentUpdate
(
comp
,
currentAttractionPoint
);
notifyListenersOfAssignmentUpdate
(
comp
,
currentAttractionPoint
);
}
}
}
}
...
@@ -108,4 +117,8 @@ public class AttractionPointRoamingStrategy extends AbstractAttractionBasedAssig
...
@@ -108,4 +117,8 @@ public class AttractionPointRoamingStrategy extends AbstractAttractionBasedAssig
this
.
roamAroundAttractionPoint
(
comp
);
this
.
roamAroundAttractionPoint
(
comp
);
}
}
}
}
public
void
setRoamingSpeedDistribution
(
ISpeedDistributionProvider
dist
)
{
this
.
roamSpeedProvider
=
dist
;
}
}
}
\ No newline at end of file
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/InAreaRoamingTransitionStrategy.java
View file @
dd725273
...
@@ -23,9 +23,9 @@ package de.tud.kom.p2psim.impl.topology.movement.modularosm.transition;
...
@@ -23,9 +23,9 @@ package de.tud.kom.p2psim.impl.topology.movement.modularosm.transition;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
de.tud.kom.p2psim.api.topology.movement.SimLocationActuator
;
import
de.tud.kom.p2psim.api.topology.movement.SimLocationActuator
;
import
de.tud.kom.p2psim.impl.topology.movement.distributions.ISpeedDistributionProvider
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ISocialGroupMovementAnalyzer
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ISocialGroupMovementAnalyzer
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ModularMovementModel
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ModularMovementModel
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractionProvider
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.Monitor
;
import
de.tudarmstadt.maki.simonstrator.api.Monitor
;
...
@@ -48,6 +48,8 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
...
@@ -48,6 +48,8 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
TRANSITION
TRANSITION
}
}
protected
ISpeedDistributionProvider
roamSpeedProvider
;
protected
Map
<
SimLocationActuator
,
roamingTransitionState
>
roamingStates
=
new
LinkedHashMap
<>();
protected
Map
<
SimLocationActuator
,
roamingTransitionState
>
roamingStates
=
new
LinkedHashMap
<>();
protected
final
static
int
EVENT_ROAMING_PAUSE_ENDED
=
2
;
protected
final
static
int
EVENT_ROAMING_PAUSE_ENDED
=
2
;
...
@@ -63,6 +65,10 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
...
@@ -63,6 +65,10 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
public
void
addComponent
(
SimLocationActuator
comp
)
{
public
void
addComponent
(
SimLocationActuator
comp
)
{
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
TRANSITION
);
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
TRANSITION
);
IAttractionPoint
nextAP
=
getNewAttractionPointAssignment
(
comp
);
IAttractionPoint
nextAP
=
getNewAttractionPointAssignment
(
comp
);
// trigger recalculation of speed
comp
.
setMovementSpeed
(-
1
);
updateTargetAttractionPoint
(
comp
,
nextAP
);
updateTargetAttractionPoint
(
comp
,
nextAP
);
}
}
...
@@ -118,15 +124,10 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
...
@@ -118,15 +124,10 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
if
(
roamingStates
.
get
(
comp
)
!=
roamingTransitionState
.
TRANSITION
)
{
if
(
roamingStates
.
get
(
comp
)
!=
roamingTransitionState
.
TRANSITION
)
{
IAttractionPoint
currentAttractionPoint
=
this
.
assignments
.
get
(
comp
);
IAttractionPoint
currentAttractionPoint
=
this
.
assignments
.
get
(
comp
);
if
(
currentAttractionPoint
==
null
)
{
if
(
currentAttractionPoint
.
getRadius
()
>
0
)
{
System
.
err
.
println
(
"AP roaming failed: no AP"
);
}
if
(
currentAttractionPoint
.
getRadius
()
>
0
)
{
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
ROAMING
);
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
ROAMING
);
comp
.
setMovementSpeed
(
roamSpeedProvider
.
calculateSpeed
());
updateTargetAttractionPoint
(
comp
,
currentAttractionPoint
);
updateTargetAttractionPoint
(
comp
,
currentAttractionPoint
);
//notifyListenersOfAssignmentUpdate(comp, currentAttractionPoint);
}
}
}
}
}
}
...
@@ -160,5 +161,8 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
...
@@ -160,5 +161,8 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedAssi
useGaussianDistributedPauseTime
=
useGaussian
;
useGaussianDistributedPauseTime
=
useGaussian
;
}
}
public
void
setRoamingSpeedDistribution
(
ISpeedDistributionProvider
dist
)
{
this
.
roamSpeedProvider
=
dist
;
}
}
}
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