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
c8217a74
Commit
c8217a74
authored
Jan 30, 2017
by
Björn Richerzhagen
Browse files
Fixed potential AssertionError for out-of-world coordinates
parent
8853adf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/ModularMovementModel.java
View file @
c8217a74
...
...
@@ -239,12 +239,32 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
* host.
*/
PositionVector
attractionCenter
=
(
PositionVector
)
newAssignment
;
PositionVector
destination
=
new
PositionVector
(
attractionCenter
);
// Gaussian with std = 1 --> >99% of nodes
PositionVector
offset
=
new
PositionVector
(
rand
.
nextGaussian
()
*
newAssignment
.
getRadius
()
/
3
,
rand
.
nextGaussian
()
*
newAssignment
.
getRadius
()
/
3
);
destination
.
add
(
offset
);
PositionVector
destination
=
null
;
int
tries
=
0
;
do
{
destination
=
new
PositionVector
(
attractionCenter
);
// Gaussian with std = 1 --> >99% of nodes
PositionVector
offset
=
new
PositionVector
(
rand
.
nextGaussian
()
*
newAssignment
.
getRadius
()
/
3
,
rand
.
nextGaussian
()
*
newAssignment
.
getRadius
()
/
3
);
destination
.
add
(
offset
);
// Check constraints
if
(
destination
.
getX
()
<
0.0
||
destination
.
getX
()
>
Binder
.
getComponentOrNull
(
Topology
.
class
)
.
getWorldDimensions
().
getX
()
||
destination
.
getY
()
<
0.0
||
destination
.
getY
()
>
Binder
.
getComponentOrNull
(
Topology
.
class
)
.
getWorldDimensions
().
getY
())
{
destination
=
null
;
if
(
tries
>
100
)
{
throw
new
AssertionError
(
"Unable to find a valid target destination within <100 tries."
);
}
}
tries
++;
}
while
(
destination
==
null
);
currentTarget
.
put
(
component
,
destination
);
}
...
...
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