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
91c0dfe2
Commit
91c0dfe2
authored
Jan 31, 2020
by
Julian Zobel
Browse files
Adaptions for social group movements
parent
bf9feaa7
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/groups/groupencounter/Dissolve.java
View file @
91c0dfe2
...
...
@@ -46,7 +46,7 @@ public class Dissolve extends AbstractGroupEncounter {
//------------------------------------------
/**
*
{@inheritDoc}
*
* Lets both groups dissolve with a certain probability in case they encounter.
*/
@Override
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/groups/groupencounter/Merge.java
View file @
91c0dfe2
...
...
@@ -45,7 +45,7 @@ public class Merge extends AbstractGroupEncounter {
}
/**
*
{@inheritDoc}
*
* Lets both groups merge fully with a certain probability in case they encounter.
*/
@Override
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/groups/groupencounter/Wait.java
View file @
91c0dfe2
...
...
@@ -61,8 +61,6 @@ public class Wait extends AbstractGroupEncounter{
*
* @param SocialMovementGroup The first group.
* @param SocialMovementGroup The second group.
*
* @author Marcel Verst
*/
private
void
wait
(
SocialMovementGroup
group1
,
SocialMovementGroup
group2
)
{
// Do not apply waiting process if one of both groups is already waiting
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/groups/groupforming/AbstractGroupForming.java
View file @
91c0dfe2
...
...
@@ -183,18 +183,12 @@ public abstract class AbstractGroupForming implements IGroupFormingBehavior {
*/
protected
void
createGroup
(
Set
<
SimLocationActuator
>
members
)
{
SocialMovementGroup
group
=
new
SocialMovementGroup
(
members
);
// Guarantee that the new destination of a group is not equal to the current AttractionPoint where the group is created
// This would be the case if the destination of the group leader is the current position of the group.
AttractionPoint
leaderTarget
=
group
.
getLeader
().
getCurrentTargetAttractionPoint
();
movementModel
.
getAttractionAssignmentStrategy
().
addComponent
(
group
.
getLeader
());
AttractionPoint
nextDestination
=
movementModel
.
getAttractionAssignmentStrategy
().
getAssignment
(
group
.
getLeader
());
System
.
out
.
println
(
leaderTarget
+
" vs. "
+
nextDestination
);
// Add Offset to destination
// Add Offset to group destination
PositionVector
destination
=
movementModel
.
addGaussianOffsetToPosition
(
new
PositionVector
(
nextDestination
),
nextDestination
.
getRadius
()
/
3
);
...
...
@@ -234,7 +228,6 @@ public abstract class AbstractGroupForming implements IGroupFormingBehavior {
*
* @return AttractionPoint
*
* @author Marcel Verst, Julian Zobel
*/
protected
AttractionPoint
getAttractionPointWithOldestHost
()
{
AttractionPoint
result
=
null
;
...
...
@@ -254,69 +247,7 @@ public abstract class AbstractGroupForming implements IGroupFormingBehavior {
return
result
;
}
/**
* Returns an Array of SimLocationActuators sorted in ascending order of stayDuration values.
*
* @param Set<SimLocationActuator> The candidates to sort.
* @return SimLocationActuator[]
*
* @author Marcel Verst
*/
protected
SimLocationActuator
[]
getHostsSortedByStayDurationAscending
(
Set
<
SimLocationActuator
>
candidates
)
{
int
size
=
candidates
.
size
();
SimLocationActuator
[]
youngestHostsSorted
=
new
SimLocationActuator
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
long
largestDuration
=
Integer
.
MAX_VALUE
;
SimLocationActuator
youngesHost
=
null
;
for
(
SimLocationActuator
candidate
:
candidates
)
{
INodeID
id
=
candidate
.
getHost
().
getId
();
long
duration
=
stayDuration
.
get
(
id
).
getA
();
if
(
duration
<=
largestDuration
)
{
largestDuration
=
duration
;
youngesHost
=
candidate
;
}
}
youngestHostsSorted
[
i
]
=
youngesHost
;
candidates
.
remove
(
youngesHost
);
}
return
youngestHostsSorted
;
}
/**
* Returns an Array of SimLocationActuators sorted in descending order of stayDuration values.
*
* @param Set<SimLocationActuator> The candidates to sort.
* @return SimLocationActuator[]
*
* @author Marcel Verst
*/
protected
SimLocationActuator
[]
getHostsSortedByStayDurationDescending
(
Set
<
SimLocationActuator
>
candidates
)
{
int
size
=
candidates
.
size
();
SimLocationActuator
[]
oldestHostsSorted
=
new
SimLocationActuator
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
long
largestDuration
=
0
;
SimLocationActuator
oldestHost
=
null
;
for
(
SimLocationActuator
candidate
:
candidates
)
{
if
(!
groupCon
.
isGroupMember
(
candidate
))
{
INodeID
id
=
candidate
.
getHost
().
getId
();
long
duration
=
stayDuration
.
get
(
id
).
getA
();
if
(
duration
>=
largestDuration
)
{
largestDuration
=
duration
;
oldestHost
=
candidate
;
}
}
}
if
(
oldestHost
!=
null
)
{
oldestHostsSorted
[
i
]
=
oldestHost
;
}
candidates
.
remove
(
oldestHost
);
}
return
oldestHostsSorted
;
}
protected
AttractionPoint
getAttractionPointWithMostHosts
()
{
AttractionPoint
apCandidate
=
null
;
int
size
=
0
;
...
...
@@ -335,8 +266,6 @@ public abstract class AbstractGroupForming implements IGroupFormingBehavior {
* Returns true if willing to join, false else.
*
* @return boolean
*
* @author Marcel Verst
*/
protected
boolean
wantsToJoin
()
{
return
(
rand
.
nextDouble
()
<=
probabilityToJoin
);
...
...
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