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
1fd89662
Commit
1fd89662
authored
Jul 31, 2017
by
Nils Richerzhagen
Browse files
Using Randoms.getRandom with class reference instead of "this"
parent
3174a624
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/churn/MaxPeerCountChurnGenerator.java
View file @
1fd89662
...
...
@@ -99,7 +99,7 @@ public class MaxPeerCountChurnGenerator
private
PriorityQueue
<
HostSessionInfo
>
offlineHostsSortedByOfflineTime
;
private
Random
rnd
=
Randoms
.
getRandom
(
new
Object
()
);
private
Random
rnd
=
Randoms
.
getRandom
(
MaxPeerCountChurnGenerator
.
class
);
/**
* Comparator used to sort client infos by offline time
...
...
src/de/tud/kom/p2psim/impl/topology/DefaultTopologyComponent.java
View file @
1fd89662
...
...
@@ -38,7 +38,13 @@ import de.tud.kom.p2psim.api.topology.movement.MovementModel;
import
de.tud.kom.p2psim.api.topology.placement.PlacementModel
;
import
de.tud.kom.p2psim.api.topology.views.TopologyView
;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tudarmstadt.maki.simonstrator.api.*
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.Graphs
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.NodeDebugMonitor
;
import
de.tudarmstadt.maki.simonstrator.api.Oracle
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.Graph
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.IEdge
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INode
;
...
...
@@ -258,7 +264,14 @@ public class DefaultTopologyComponent implements TopologyComponent {
public
void
updateCurrentLocation
(
Location
location
)
{
position
.
set
(
location
);
NodeDebugMonitor
.
update
(
this
.
getClass
(),
getHost
().
getId
(),
"Current Location"
,
location
);
NodeDebugMonitor
.
update
(
this
.
getClass
(),
getHost
().
getId
(),
"Distance to target"
,
location
.
distanceTo
(
movementModel
.
getTargetLocation
(
this
)));
try
{
NodeDebugMonitor
.
update
(
this
.
getClass
(),
getHost
().
getId
(),
"Distance to target"
,
location
.
distanceTo
(
movementModel
.
getTargetLocation
(
this
)));
}
catch
(
UnsupportedOperationException
e
)
{
// This is not supported by the movement model (which may happen see
// MovementModel.java - thus catch and ignore)
}
// notify "non-request" listeners
for
(
LocationListener
locationListener
:
listeners
)
{
locationListener
.
onLocationChanged
(
getHost
(),
getLastLocation
());
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/RandomInAreaTransitionStrategy.java
View file @
1fd89662
package
de.tud.kom.p2psim.impl.topology.movement.modularosm.transition
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Set
;
import
de.tud.kom.p2psim.api.topology.Topology
;
import
de.tud.kom.p2psim.api.topology.movement.SimLocationActuator
;
import
de.tud.kom.p2psim.impl.topology.PositionVector
;
...
...
@@ -10,8 +19,6 @@ import de.tudarmstadt.maki.simonstrator.api.Randoms;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
java.util.*
;
/**
* This {@link ITransitionStrategy} 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
...
...
@@ -23,7 +30,8 @@ import java.util.*;
public
class
RandomInAreaTransitionStrategy
implements
ITransitionStrategy
{
private
Random
random
;
private
final
Random
random
=
Randoms
.
getRandom
(
RandomInAreaTransitionStrategy
.
class
);
private
LinkedHashSet
<
AttractionPoint
>
aPoints
=
new
LinkedHashSet
<>();
...
...
@@ -45,11 +53,6 @@ public class RandomInAreaTransitionStrategy implements ITransitionStrategy
*/
private
int
defaultRadius
;
public
RandomInAreaTransitionStrategy
()
{
random
=
Randoms
.
getRandom
(
this
.
getClass
());
}
@Override
public
AttractionPoint
getAssignment
(
SimLocationActuator
comp
)
{
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/CustomDistribution.java
View file @
1fd89662
...
...
@@ -27,7 +27,7 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
*/
public
class
CustomDistribution
implements
Distribution
{
private
Random
rand
=
Randoms
.
getRandom
(
thi
s
);
private
Random
rand
=
Randoms
.
getRandom
(
CustomDistribution
.
clas
s
);
private
String
csvFile
=
""
;
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/ExponentialDistribution.java
View file @
1fd89662
...
...
@@ -50,7 +50,8 @@ public class ExponentialDistribution implements Distribution {
if
(
distr
==
null
)
throw
new
ConfigurationException
(
"Mu was not set for exponential distribution "
+
this
);
double
random
=
Randoms
.
getRandom
(
this
).
nextDouble
();
double
random
=
Randoms
.
getRandom
(
ExponentialDistribution
.
class
)
.
nextDouble
();
double
result
;
try
{
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/LimitedNormalDistribution.java
View file @
1fd89662
...
...
@@ -132,7 +132,9 @@ public class LimitedNormalDistribution implements Distribution {
}
public
double
returnValue
()
{
double
random
=
pmin
+
Randoms
.
getRandom
(
this
).
nextDouble
()
*
pfactor
;
double
random
=
pmin
+
Randoms
.
getRandom
(
LimitedNormalDistribution
.
class
)
.
nextDouble
()
*
pfactor
;
double
result
;
try
{
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/LognormalDistribution.java
View file @
1fd89662
...
...
@@ -22,10 +22,10 @@
package
de.tud.kom.p2psim.impl.util.stat.distributions
;
import
umontreal.iro.lecuyer.probdist.LognormalDist
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.util.Distribution
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
import
umontreal.iro.lecuyer.probdist.LognormalDist
;
public
class
LognormalDistribution
implements
Distribution
{
...
...
@@ -48,7 +48,8 @@ public class LognormalDistribution implements Distribution {
}
public
double
returnValue
()
{
double
random
=
Randoms
.
getRandom
(
this
).
nextDouble
();
double
random
=
Randoms
.
getRandom
(
LognormalDistribution
.
class
)
.
nextDouble
();
double
result
=
0
;
try
{
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/MixedLogNormalDistribution.java
View file @
1fd89662
...
...
@@ -22,10 +22,10 @@
package
de.tud.kom.p2psim.impl.util.stat.distributions
;
import
umontreal.iro.lecuyer.probdist.LognormalDist
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.util.Distribution
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
import
umontreal.iro.lecuyer.probdist.LognormalDist
;
public
class
MixedLogNormalDistribution
implements
Distribution
{
...
...
@@ -65,7 +65,8 @@ public class MixedLogNormalDistribution implements Distribution {
}
public
double
returnValue
()
{
double
random
=
Randoms
.
getRandom
(
this
).
nextDouble
();
double
random
=
Randoms
.
getRandom
(
MixedLogNormalDistribution
.
class
)
.
nextDouble
();
double
result
=
0
;
try
{
result
=
weight1
*
distr1
.
inverseF
(
random
)
+
weight2
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/NormalDistribution.java
View file @
1fd89662
...
...
@@ -35,7 +35,7 @@ public class NormalDistribution implements Distribution {
private
NormalDistributionImpl
normal
;
private
Random
randomGen
=
Randoms
.
getRandom
(
thi
s
);
private
Random
randomGen
=
Randoms
.
getRandom
(
NormalDistribution
.
clas
s
);
private
double
mu
;
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/PoissonDistribution.java
View file @
1fd89662
...
...
@@ -42,7 +42,7 @@ public class PoissonDistribution implements Distribution {
// returns the x-value for a random value in the cdf
public
double
returnValue
()
{
double
random
=
Randoms
.
getRandom
(
thi
s
)
double
random
=
Randoms
.
getRandom
(
PoissonDistribution
.
clas
s
)
.
nextDouble
();
int
result
;
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/UniformDistribution.java
View file @
1fd89662
...
...
@@ -50,7 +50,8 @@ public class UniformDistribution implements Distribution {
*/
public
double
returnValue
()
{
return
min
+
factor
*
Randoms
.
getRandom
(
this
).
nextDouble
();
return
min
+
factor
*
Randoms
.
getRandom
(
UniformDistribution
.
class
).
nextDouble
();
}
/**
...
...
src/de/tud/kom/p2psim/impl/util/stat/distributions/ZipfDistribution.java
View file @
1fd89662
...
...
@@ -66,7 +66,8 @@ public class ZipfDistribution implements Distribution {
// rank = 1 ... maximum_Number_Of_Ranks => 1/rank = 0..1
return
1
/
(
Math
.
pow
(
1
/
(
Randoms
.
getRandom
(
this
).
nextDouble
()
*
harmonicNormFactor
),
.
pow
(
1
/
(
Randoms
.
getRandom
(
ZipfDistribution
.
class
).
nextDouble
()
*
harmonicNormFactor
),
1
/
zipfExponent
));
}
...
...
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