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
41865f71
Commit
41865f71
authored
Nov 22, 2019
by
Julian Zobel
Browse files
Area Roaming adaptions and minimum distance in random attraction generator from ocnfig
parent
722b46a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/RandomAttractionGenerator.java
View file @
41865f71
...
...
@@ -60,8 +60,8 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
private
double
minimumRadius
=
10
;
@XMLConfigurableConstructor
({
"numberOfAttractionPoints"
})
public
RandomAttractionGenerator
(
int
numberOfAttractionPoints
)
{
@XMLConfigurableConstructor
({
"numberOfAttractionPoints"
,
"maximumRadius"
,
"minimumRadius"
,
"minimumDistance"
})
public
RandomAttractionGenerator
(
int
numberOfAttractionPoints
,
double
maximumRadius
,
double
minimumRadius
,
double
minimumDistance
)
{
this
.
rand
=
Randoms
.
getRandom
(
RandomAttractionGenerator
.
class
);
this
.
worldDimension
=
Binder
.
getComponentOrNull
(
Topology
.
class
)
.
getWorldDimensions
();
...
...
@@ -71,6 +71,9 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
}
this
.
numberOfAPsSet
=
true
;
this
.
numberOfAttractionPoints
=
numberOfAttractionPoints
;
this
.
maximumRadius
=
maximumRadius
;
this
.
minimumRadius
=
minimumRadius
;
this
.
minimumDistance
=
minimumDistance
;
attractionPoints
.
clear
();
createAttractionPoints
();
}
...
...
@@ -93,7 +96,7 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
// make a break counter to prevent more than 10 iterations and an infinity loop in general.
int
c
=
0
;
create:
for
(
int
i
=
0
;
i
<
numberOfAttractionPoints
;
i
++)
{
PositionVector
posVec
=
createPosVec
();
...
...
@@ -155,7 +158,7 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
}
/**
* Set a maximum radius that an attraction point can have.
Minimum is 10 meters.
* Set a maximum radius that an attraction point can have.
* @param radius
*/
public
void
setMaximumRadius
(
double
radius
)
{
...
...
@@ -163,10 +166,16 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
}
/**
* Set a m
ax
imum radius that an attraction point can have. Minimum is 10 meters.
* Set a m
in
imum radius that an attraction point can have. Minimum is 10 meters.
* @param radius
*/
public
void
setMinimumRadius
(
double
radius
)
{
this
.
minimumRadius
=
radius
;
if
(
radius
<
10
)
{
this
.
minimumRadius
=
10
;
}
else
{
this
.
minimumRadius
=
radius
;
}
}
}
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/InAreaRoamingTransitionStrategy.java
View file @
41865f71
...
...
@@ -51,6 +51,8 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
protected
final
static
int
EVENT_ROAMING_PAUSE_ENDED
=
2
;
private
boolean
useGaussianDistributedPauseTime
=
false
;
@Override
public
void
addComponent
(
SimLocationActuator
comp
)
{
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
TRANSITION
);
...
...
@@ -68,15 +70,27 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
// start roaming if the AP was reached
if
(
roamingStates
.
get
(
comp
)
==
roamingTransitionState
.
TRANSITION
)
{
// schedule the end of the roaming phase, which will make a new transition
Event
.
scheduleWithDelay
(
g
aussianDistributionPauseTime
(
pauseTimeMax
-
pauseTimeMin
,
0.5
*(
pauseTimeMax
-
pauseTimeMin
)
),
this
,
comp
,
EVENT_PAUSE_ENDED
);
Event
.
scheduleWithDelay
(
g
etPauseTime
(
),
this
,
comp
,
EVENT_PAUSE_ENDED
);
}
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
PAUSE
);
// schedule roaming
Event
.
scheduleWithDelay
(
gaussianDistributionPauseTime
(
Time
.
MINUTE
*
1
,
Time
.
MINUTE
),
this
,
comp
,
EVENT_ROAMING_PAUSE_ENDED
);
Event
.
scheduleWithDelay
(
gaussianDistributionPauseTime
(
Time
.
MINUTE
,
Time
.
MINUTE
),
this
,
comp
,
EVENT_ROAMING_PAUSE_ENDED
);
}
@Override
protected
long
getPauseTime
()
{
if
(
useGaussianDistributedPauseTime
)
{
return
gaussianDistributionPauseTime
(
pauseTimeMax
-
pauseTimeMin
,
0.5
*(
pauseTimeMax
-
pauseTimeMin
));
}
else
{
return
super
.
getPauseTime
();
}
}
/**
* Use a gaussian distribution for the pause time interval generation, using a mean value and a standard deviation
*
...
...
@@ -131,6 +145,9 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
}
}
public
void
setGaussianPauseTime
(
boolean
useGaussian
)
{
useGaussianDistributedPauseTime
=
useGaussian
;
}
private
AttractionPoint
pickNewAttractionPoint
(
SimLocationActuator
component
)
{
double
score
=
rnd
.
nextDouble
();
...
...
src/de/tud/kom/p2psim/impl/topology/views/VisualizationTopologyView.java
View file @
41865f71
...
...
@@ -156,7 +156,7 @@ public class VisualizationTopologyView extends JFrame
worldPanel
.
setPreferredSize
(
new
Dimension
(
VisualizationInjector
.
getWorldX
(),
VisualizationInjector
.
getWorldY
()));
this
.
setPreferredSize
(
new
Dimension
(
800
,
6
00
));
this
.
setPreferredSize
(
new
Dimension
(
VisualizationInjector
.
getWorldX
()
+
50
,
VisualizationInjector
.
getWorldY
()
+
1
00
));
this
.
setExtendedState
(
Frame
.
MAXIMIZED_BOTH
);
Thread
t
=
new
Thread
(
this
);
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/ui/PlottingView.java
View file @
41865f71
...
...
@@ -30,6 +30,8 @@ import javax.swing.border.BevelBorder;
import
com.google.common.collect.Maps
;
import
de.tud.kom.p2psim.impl.util.guirunner.Config
;
/**
* JFrame which holds all the live plots.
*
...
...
@@ -42,9 +44,16 @@ import com.google.common.collect.Maps;
* they will stay add a minimum height of 250 px and a scrollbar will be added instead.
*/
public
class
PlottingView
extends
JFrame
{
private
static
final
int
VIEW_WIDTH
=
900
;
private
static
final
int
VIEW_HEIGHT
=
800
;
/*
* Configuration paths
*/
static
final
String
CONF_PATH
=
"GUIRunner/LivePlotWindow/"
;
static
final
String
CONF_PATH_POSX
=
CONF_PATH
+
"PosX"
;
static
final
String
CONF_PATH_POSY
=
CONF_PATH
+
"PosY"
;
static
final
String
CONF_PATH_WIDTH
=
CONF_PATH
+
"Width"
;
static
final
String
CONF_PATH_HEIGHT
=
CONF_PATH
+
"Height"
;
private
static
final
int
PLOT_HEIGHT_MIN
=
250
;
private
static
final
Color
PLOT_BACKGROUND_COLOR
=
Color
.
WHITE
;
...
...
@@ -69,8 +78,16 @@ public class PlottingView extends JFrame {
spane
=
new
JScrollPane
(
plotBox
);
add
(
spane
);
setSize
(
VIEW_WIDTH
,
VIEW_HEIGHT
);
setPreferredSize
(
new
Dimension
(
VIEW_WIDTH
,
VIEW_HEIGHT
));
int
locationX
=
Config
.
getValue
(
CONF_PATH_POSX
,
0
);
int
locationY
=
Config
.
getValue
(
CONF_PATH_POSY
,
0
);
setLocation
(
locationX
,
locationY
);
int
winWidth
=
Config
.
getValue
(
CONF_PATH_WIDTH
,
900
);
int
winHeight
=
Config
.
getValue
(
CONF_PATH_HEIGHT
,
800
);
setSize
(
winWidth
,
winHeight
);
setPreferredSize
(
new
Dimension
(
winWidth
,
winHeight
));
}
public
XYChart
createPlot
(
String
name
,
String
seriesName
)
{
...
...
@@ -170,7 +187,7 @@ public class PlottingView extends JFrame {
private
class
PlotBox
extends
JPanel
implements
Scrollable
{
private
boolean
enableScroll
=
false
;
private
Dimension
preferredSize
=
new
Dimension
(
VIEW_WIDTH
,
800
);
private
Dimension
preferredSize
=
new
Dimension
(
Config
.
getValue
(
CONF_PATH_WIDTH
,
900
)
,
800
);
@Override
public
Component
add
(
Component
comp
)
...
...
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