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
aad65d61
Commit
aad65d61
authored
Nov 25, 2020
by
Julian Zobel
Browse files
separated assignment strategy for single nodes and social groups to allow for single node movement
parent
1562bfc2
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/SocialGroupMovementModel.java
View file @
aad65d61
...
...
@@ -34,6 +34,7 @@ import de.tud.kom.p2psim.impl.topology.movement.modularosm.groups.groupforming.I
import
de.tud.kom.p2psim.impl.topology.movement.modularosm.transition.IAttractionAssigmentStrategy
;
import
de.tud.kom.p2psim.impl.topology.util.PositionVector
;
import
de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector
;
import
de.tud.kom.p2psim.impl.util.Either
;
import
de.tudarmstadt.maki.simonstrator.api.Binder
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.Monitor
;
...
...
@@ -53,7 +54,10 @@ public class SocialGroupMovementModel extends ModularMovementModel {
protected
MovementGroupContainer
groupContainer
;
protected
IGroupFormingBehavior
groupFormingBehavior
;
protected
IGroupEncounterBehavior
groupEncounterBehavior
;
protected
IAttractionAssigmentStrategy
groupAttractionAssignment
;
private
LinkedHashSet
<
SimLocationActuator
>
singleHosts
=
new
LinkedHashSet
<
SimLocationActuator
>();
private
int
numberOfSingleHosts
;
...
...
@@ -104,16 +108,39 @@ public class SocialGroupMovementModel extends ModularMovementModel {
attractionAssigment
.
addAttractionAssignmentListener
(
this
);
attractionAssigment
.
setAttractionProvider
(
attractionProvider
);
groupAttractionAssignment
.
addAttractionAssignmentListener
(
this
);
groupAttractionAssignment
.
setAttractionProvider
(
attractionProvider
);
// This adds the mobile hosts (smartphones/users) to the transition
// strategy
for
(
SimLocationActuator
ms
:
moveableHosts
)
{
attractionAssigment
.
addComponent
(
ms
);
if
(
placeNodesAtAP
)
{
IAttractionPoint
assignment
=
attractionAssigment
.
getAssignment
(
ms
);
ms
.
updateCurrentLocation
(
this
.
addOffset
(
new
PositionVector
(
assignment
),
(
assignment
.
hasRadius
()
?
Math
.
max
(
assignment
.
getRadius
(),
25.0
)
:
25.0
)));
attractionAssigment
.
updateTargetAttractionPoint
(
ms
,
assignment
);
}
if
(
singleHosts
.
contains
(
ms
))
{
attractionAssigment
.
addComponent
(
ms
);
if
(
placeNodesAtAP
)
{
IAttractionPoint
assignment
=
attractionAssigment
.
getAssignment
(
ms
);
ms
.
updateCurrentLocation
(
this
.
addOffset
(
new
PositionVector
(
assignment
),
(
assignment
.
hasRadius
()
?
Math
.
max
(
assignment
.
getRadius
(),
25.0
)
:
25.0
)));
attractionAssigment
.
updateTargetAttractionPoint
(
ms
,
assignment
);
}
}
else
{
groupAttractionAssignment
.
addComponent
(
ms
);
if
(
placeNodesAtAP
)
{
IAttractionPoint
assignment
=
groupAttractionAssignment
.
getAssignment
(
ms
);
ms
.
updateCurrentLocation
(
this
.
addOffset
(
new
PositionVector
(
assignment
),
(
assignment
.
hasRadius
()
?
Math
.
max
(
assignment
.
getRadius
(),
25.0
)
:
25.0
)));
groupAttractionAssignment
.
updateTargetAttractionPoint
(
ms
,
assignment
);
}
}
// //attractionAssigment.addComponent(ms);
// if(placeNodesAtAP) {
// IAttractionPoint assignment = attractionAssigment.getAssignment(ms);
// ms.updateCurrentLocation(this.addOffset(new PositionVector(assignment),
// (assignment.hasRadius() ? Math.max(assignment.getRadius(), 25.0) : 25.0)));
// attractionAssigment.updateTargetAttractionPoint(ms, assignment);
// }
}
setTimeBetweenMoveOperations
(
timeBetweenMoveOperation
);
...
...
@@ -173,7 +200,10 @@ public class SocialGroupMovementModel extends ModularMovementModel {
assert
currentTargets
.
containsKey
(
host
);
// Single Host Movement
if
(
singleHosts
.
contains
(
host
)
||
!
groupContainer
.
isGroupMember
(
host
))
{
if
(
singleHosts
.
contains
(
host
))
{
super
.
doLocalMovement
(
host
,
currentTargets
.
get
(
host
));
}
else
if
(
!
groupContainer
.
isGroupMember
(
host
))
{
doLocalMovement
(
host
,
currentTargets
.
get
(
host
));
}
else
if
(
groupContainer
.
isGroupMember
(
host
)){
...
...
@@ -194,6 +224,22 @@ public class SocialGroupMovementModel extends ModularMovementModel {
Event
.
scheduleWithDelay
(
timeBetweenMoveOperation
,
this
,
null
,
EVENT_MOVE
);
}
@Override
protected
void
doLocalMovement
(
SimLocationActuator
ms
,
PositionVector
destination
)
{
Either
<
PositionVector
,
Boolean
>
either
=
localMovementStrategy
.
nextPosition
(
ms
,
destination
);
if
(
either
.
hasLeft
())
{
ms
.
updateCurrentLocation
(
either
.
getLeft
());
if
(!
checkBoundaries
(
ms
.
getRealPosition
()))
{
System
.
err
.
println
(
"Social Group Movement Model: Host moved outside of simulated area!"
);
}
}
else
{
groupAttractionAssignment
.
reachedAttractionPoint
(
ms
,
ms
.
getCurrentTargetAttractionPoint
());
}
}
/**
* Applies movement of the host according to different circumstances:
*
...
...
@@ -272,6 +318,28 @@ public class SocialGroupMovementModel extends ModularMovementModel {
}
@Override
public
void
changeTargetLocation
(
SimLocationActuator
actuator
,
IAttractionPoint
ap
)
{
if
(
singleHosts
.
contains
(
actuator
))
{
attractionAssigment
.
updateTargetAttractionPoint
(
actuator
,
ap
);
}
else
{
groupAttractionAssignment
.
updateTargetAttractionPoint
(
actuator
,
ap
);
}
}
@Override
public
IAttractionPoint
getTargetLocation
(
SimLocationActuator
actuator
)
{
if
(
singleHosts
.
contains
(
actuator
))
{
return
attractionAssigment
.
getAssignment
(
actuator
);
}
else
{
return
groupAttractionAssignment
.
getAssignment
(
actuator
);
}
}
/*
* =====================================================================================================
* === MEETING POINT FUNCTIONS
...
...
@@ -376,7 +444,7 @@ public class SocialGroupMovementModel extends ModularMovementModel {
}
public
IAttractionAssigmentStrategy
getAttractionAssignmentStrategy
()
{
return
a
ttractionAssigment
;
return
this
.
groupA
ttractionAssig
n
ment
;
}
public
IGroupFormingBehavior
getGroupFormingBehavior
()
{
...
...
@@ -398,4 +466,14 @@ public class SocialGroupMovementModel extends ModularMovementModel {
public
LinkedHashMap
<
SimLocationActuator
,
PositionVector
>
getCurrentTargets
(){
return
currentTargets
;
}
public
void
setGroupAttractionAssignmentStrategy
(
IAttractionAssigmentStrategy
groupAttractionAssignment
)
{
if
(
groupAttractionAssignment
==
null
)
{
throw
new
ConfigurationException
(
"IAttractionAssigmentStrategy for Groups is missing in SocialGroupMovementModel!"
);
}
this
.
groupAttractionAssignment
=
groupAttractionAssignment
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/groups/SocialMovementGroup.java
View file @
aad65d61
...
...
@@ -157,7 +157,7 @@ public class SocialMovementGroup {
@Override
public
String
toString
()
{
return
"Social Group of #"
+
leader
.
getHost
().
getId
()
+
" ("
+
members
.
size
()
+
")"
;
return
"Social Group of
Leader
#"
+
leader
.
getHost
().
getId
()
+
" ("
+
members
.
size
()
+
")"
;
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/groups/groupforming/AbstractGroupForming.java
View file @
aad65d61
...
...
@@ -145,7 +145,7 @@ public abstract class AbstractGroupForming implements IGroupFormingBehavior {
}
for
(
int
g
=
0
;
g
<
maxNumberOfGroups
;
g
++)
{
long
delay
=
Math
.
max
(
Time
.
MINUTE
,
(
long
)
((
rand
.
nextDouble
()
*
(
Time
.
MINUTE
*
45
)
+
Time
.
MINUTE
)));
long
delay
=
Math
.
max
(
Time
.
MINUTE
,
(
long
)
((
rand
.
nextDouble
()
*
(
Time
.
MINUTE
*
30
)
+
Time
.
MINUTE
)));
//System.out.println("("+g+") Init Group Formation Time " + Time.getFormattedTime(delay) );
Event
.
scheduleWithDelay
(
delay
,
new
EventHandler
()
{
...
...
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