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
bd8eefc1
Commit
bd8eefc1
authored
Jan 29, 2020
by
Julian Zobel
Browse files
wip
parent
6ccbc90e
Changes
25
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/I
Transition
Strategy.java
→
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/I
AttractionAssigment
Strategy.java
View file @
bd8eefc1
...
...
@@ -34,7 +34,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
* @author Julian Zobel
* @version 1.1, 27.01.2020
*/
public
interface
I
Transition
Strategy
{
public
interface
I
AttractionAssigment
Strategy
{
/**
* Currently assigned attraction point.
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/InAreaRoamingTransitionStrategy.java
View file @
bd8eefc1
...
...
@@ -21,8 +21,6 @@
package
de.tud.kom.p2psim.impl.topology.movement.modularosm.transition
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
de.tud.kom.p2psim.api.topology.movement.SimLocationActuator
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.ModularMovementModel
;
...
...
@@ -66,7 +64,7 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
@Override
public
void
addComponent
(
SimLocationActuator
comp
)
{
this
.
roamingStates
.
put
(
comp
,
roamingTransitionState
.
TRANSITION
);
AttractionPoint
nextAP
=
pick
NewAttractionPoint
(
comp
);
AttractionPoint
nextAP
=
get
NewAttractionPoint
Assignment
(
comp
);
updateTargetAttractionPoint
(
comp
,
nextAP
);
}
...
...
@@ -157,27 +155,5 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
useGaussianDistributedPauseTime
=
useGaussian
;
}
private
AttractionPoint
pickNewAttractionPoint
(
SimLocationActuator
component
)
{
double
score
=
rnd
.
nextDouble
();
List
<
AttractionPoint
>
candidates
=
new
LinkedList
<>();
for
(
AttractionPoint
ap
:
IAttractionGenerator
.
attractionPoints
)
{
if
(
ap
==
null
)
{
continue
;
}
if
(
ap
.
getWeight
()
>=
score
)
{
if
(
lastAssignments
.
get
(
component
)
==
null
||
!
ap
.
equals
(
lastAssignments
.
get
(
component
)))
{
candidates
.
add
(
ap
);
}
}
}
if
(
candidates
.
isEmpty
())
{
candidates
.
addAll
(
IAttractionGenerator
.
attractionPoints
);
}
AttractionPoint
assignment
=
candidates
.
get
(
rnd
.
nextInt
(
candidates
.
size
()));
return
assignment
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/ManualAssignmentStrategy.java
View file @
bd8eefc1
...
...
@@ -6,14 +6,14 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
import
java.util.*
;
/**
* This {@link I
Transition
Strategy} works with manual assignments. Initially components will be assigned
* This {@link I
AttractionAssigment
Strategy} works with manual assignments. Initially components will be assigned
* one of the attraction points, but at any further point, the set list of attraction points doesn't really matter.
* New target can be assigned by using the {@link #updateTargetAttractionPoint(SimLocationActuator, AttractionPoint)} method,
* otherwise the components will stop moving upon reaching their target.
*
* @author Clemens Krug
*/
public
class
ManualAssignmentStrategy
implements
I
Transition
Strategy
public
class
ManualAssignmentStrategy
implements
I
AttractionAssigment
Strategy
{
private
LinkedHashSet
<
AttractionPoint
>
aPoints
=
new
LinkedHashSet
<>();
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/RandomInAreaTransitionStrategy.java
View file @
bd8eefc1
...
...
@@ -13,14 +13,14 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
/**
* This {@link I
Transition
Strategy} makes clients move around randomly in a specified area. You can specify the target
* This {@link I
AttractionAssigment
Strategy} makes clients move around randomly in a specified area. You can specify the target
* area center via the {@link #updateTargetAttractionPoint(SimLocationActuator, AttractionPoint)} method. The client will then start
* to roam the area randomly till a new target area is assigned.
*
* @author Clemens Krug
*
* Made the transition strategy extend the {@link AbstractAttractionBasedTransitionStrategy} for a more generalized approach on
* the {@link I
Transition
Strategy} implementation for attraction point based strategies.
* the {@link I
AttractionAssigment
Strategy} implementation for attraction point based strategies.
*
* @author Julian Zobel
* @version 1.1, January 2019
...
...
@@ -33,17 +33,11 @@ public class RandomInAreaTransitionStrategy extends AbstractAttractionBasedTrans
private
Map
<
SimLocationActuator
,
AttractionPoint
>
currentTarget
=
new
HashMap
<>();
private
Map
<
SimLocationActuator
,
Integer
>
currentSearchRadius
=
new
HashMap
<>();
/**
* The radius the target area should have. Should be set via XML config file.
*/
private
int
defaultRadius
;
@Override
public
AttractionPoint
getAssignment
(
SimLocationActuator
comp
)
{
return
currentTarget
.
get
(
comp
);
}
@Override
public
void
addComponent
(
SimLocationActuator
ms
)
{
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/WeightedTransitionStrategy.java
View file @
bd8eefc1
...
...
@@ -20,10 +20,7 @@
package
de.tud.kom.p2psim.impl.topology.movement.modularosm.transition
;
import
java.util.LinkedList
;
import
java.util.List
;
import
de.tud.kom.p2psim.api.topology.movement.SimLocationActuator
;
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractionGenerator
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint
;
...
...
@@ -36,7 +33,7 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
* @version 1.0, Jan 16, 2017
*
* Made the transition strategy extend the {@link AbstractAttractionBasedTransitionStrategy} for a more generalized approach on
* the {@link I
Transition
Strategy} implementation for attraction point based strategies.
* the {@link I
AttractionAssigment
Strategy} implementation for attraction point based strategies.
*
* @author Julian Zobel
* @version 1.1, January 2019
...
...
@@ -55,32 +52,17 @@ public class WeightedTransitionStrategy extends AbstractAttractionBasedTransitio
@Override
public
void
addComponent
(
SimLocationActuator
ms
)
{
this
.
assignments
.
put
(
ms
,
getNewAssignment
(
ms
));
AttractionPoint
nextAP
=
getNewAttractionPointAssignment
(
ms
);
updateTargetAttractionPoint
(
ms
,
nextAP
);
}
private
AttractionPoint
getNewAssignment
(
SimLocationActuator
component
)
{
double
score
=
rnd
.
nextDouble
();
List
<
AttractionPoint
>
candidates
=
new
LinkedList
<>();
for
(
AttractionPoint
ap
:
IAttractionGenerator
.
attractionPoints
)
{
if
(
ap
.
getWeight
()
>=
score
)
{
candidates
.
add
(
ap
);
}
}
if
(
candidates
.
isEmpty
())
{
candidates
.
addAll
(
IAttractionGenerator
.
attractionPoints
);
}
AttractionPoint
assignment
=
candidates
.
get
(
rnd
.
nextInt
(
candidates
.
size
()));
notifyListenersOfAssignmentUpdate
(
component
,
assignment
);
return
assignment
;
}
@Override
public
void
eventOccurred
(
Object
content
,
int
type
)
{
assert
type
==
EVENT_PAUSE_ENDED
;
SimLocationActuator
comp
=
(
SimLocationActuator
)
content
;
if
(!
this
.
assignments
.
containsKey
(
comp
))
{
// maybe someone assigned a new AP in the meantime. ignore.
this
.
assignments
.
put
(
comp
,
getNewAssignment
(
comp
));
this
.
assignments
.
put
(
comp
,
getNewA
ttractionPointA
ssignment
(
comp
));
}
}
...
...
Prev
1
2
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