Package sim2net.speed
¶
This package provides a collection of speed distribution classes.
Speed is a scalar quantity that describes the rate of change of a node position
in a simulation area (see: sim2net.area
).
Note
In all speed distribution classes the quantity of speed should be
considered as simulation area units per one simulation time unit (see:
sim2net._time
).
For example, the value of speed equal to \(5\) would mean five units of simulation area per one unit of simulation time.
Package modules:
See also
Module sim2net.speed._speed
¶
Contains an abstract class that should be implemented by all speed distribution classes.
-
class
sim2net.speed._speed.
Speed
(name)¶ Bases:
object
This class is an abstract class that should be implemented by all speed distribution classes.
- Parameters:
- name (str): a name of the implemented speed distribution.
-
current
¶ (Property) A value of the current speed of type float.
- Raises:
- NotImplementedError: this property is an abstract property.
-
get_new
()¶ Assigns a new speed value.
- Returns:
- (float) a new speed value.
- Raises:
- NotImplementedError: this method is an abstract method.
-
logger
¶ (Property) A logger object of the
logging.Logger
class with an appropriate channel name.See also
-
random_generator
¶ (Property) An object representing the
sim2net.utility.randomness._Randomness
pseudo-random number generator.
Module sim2net.speed.constant
¶
Provides an implementation of a constant node speed. In this case a speed of a node is constant at a given value.
-
class
sim2net.speed.constant.
Constant
(speed)¶ Bases:
sim2net.speed._speed.Speed
This class implements a constant node speed fixed at a given value.
- Parameters:
- speed (float): a value of the node speed.
Example:
>>> speed = Constant(5.0) >>> speed.current 5.0 >>> speed.get_new() 5.0 >>> speed = Constant(-5.0) >>> speed.current 5.0 >>> speed.get_new() 5.0
-
current
¶ (Property) The absolute value of the current speed of type float.
-
get_new
()¶ Returns the absolute value of the given node speed of type float.
Module sim2net.speed.normal
¶
Provides an implementation of the normal speed distribution. In this case a speed of a node is assigned at random with the normal, i.e. Gaussian, probability distribution.
-
class
sim2net.speed.normal.
Normal
(mean=0.0, standard_deviation=0.2)¶ Bases:
sim2net.speed._speed.Speed
This class implements the normal speed distribution that assigns node’s speeds with the Gaussian probability distribution.
(Defaults to standard normal distribution.)
- Parameters:
- mean (float): a value of the expectation (default: 0.0);
- standard_deviation (float): a value of the standard deviation (default: 0.2).
-
current
¶ (Property) A value of the current speed of type float (or None if the value has yet not been assigned).
-
get_new
()¶ Assigns a new speed value.
Warning
Depending on distribution parameters, negative values may be randomly selected.
- Returns:
- (float) the absolute value of a new speed.
-
mean
¶ (Property) A value of the expectation of type float.
Module sim2net.speed.uniform
¶
Provides an implementation of the uniform speed distribution. In this case a speed of a node is assigned at random with the uniform probability distribution.
-
class
sim2net.speed.uniform.
Uniform
(minimal_speed, maximal_speed)¶ Bases:
sim2net.speed._speed.Speed
This class implements the uniform speed distribution that assigns node’s speeds from a given range with equal probability.
- Parameters:
- minimal_speed (float): a value of a node’s minimal speed;
- maximal_speed (float): a value of a node’s maximal speed.
-
current
¶ (Property) A value of the current speed of type float (or None if the value has yet not been assigned).
-
get_new
()¶ Assigns a new speed value.
Warning
Depending on distribution parameters, negative values may be randomly selected.
- Returns:
- (float) the absolute value of a new speed.