memilio.surrogatemodel.utils.dampings
Functions
|
Calculating distance between two dampings if there are n_dampings on the interval (min_day, days) |
|
Producing damping factors using active damping method. |
|
" |
|
Generate the damping days using shadow damping and picking days uniformly with a given minimal distance. |
|
Generate random damping days according to the following rule. |
|
Producing dampings for timeseries of length days according to the used method. |
Sampling the damping days according to the established method. |
- memilio.surrogatemodel.utils.dampings.calc_dist_days(
- days,
- min_day,
- n_dampings,
- min_distance=1,
Calculating distance between two dampings if there are n_dampings on the interval (min_day, days)
- Parameters:
days – Total number of days
- Min_day:
First day on which a damping can be applied
- N_dampings:
Number of dampings
- Min_distance:
Lower bound for the distance between two dampings
- memilio.surrogatemodel.utils.dampings.calc_factors_active(
- n_ddays,
- gamma_pos=0,
- alpha=-1,
- p0=0.5,
- t1_max=-0.3,
- t1_min=-1.2,
- t2_max=2,
- t2_min=-0.5,
Producing damping factors using active damping method.
The idea is the following: Damping factors are produced randomly until a threshold value is achieved. In this case the factors are reduced stepwise until a moderate level is reached. The new contact matrix is always calculated with resepect to the initial matrix according to the following rule:
M = exp(h)*M_0
The h-values are generated by the following rule: 1) h is initialized as 0 2) If h > gamma_pos, we start to reduce the h-value actively by choosing changes delta_h uniformly in
the interval (t1_min, t1_max). After each step h is updated according to h = h + delta_h This procedure is repeated till h < alpha
- If h < gamma_pos the changes of h, called delta_h are chosen randomly, s.t. delta_h = 0 with
probability p0, otherwise the value is uniformly distributed on the interval (t2_min, t2_max).
- Parameters:
n_ddays – Number of damping days in time series
gamma_pos – upper bound for h value
alpha – upper bound for h value, where active damping should be stopped
p0 – probability for a change of the damping factor
t1_max – upper end point for size of active damping changes
t1_min – lower end point for size of active damping changes
t2_max – upper end point for size of active damping changes
t2_min – lower end point for size of base damping changes
- memilio.surrogatemodel.utils.dampings.dampings_active(
- days,
- number_dampings,
- min_damping_day,
” Generating list of damping days and corresponding damping factors using the active method.
The damping days are created with equal distance on the interval [1, days-3].
- Parameters:
days – Number of simulated days
number_dampings – Maximal number of dampings per simulation
min_damping_day – First day, where a damping can be applied
- Returns:
list of days and damping factors
- memilio.surrogatemodel.utils.dampings.dampings_classic(
- days,
- number_dampings,
- min_distance=2,
- min_damping_day=2,
Generate the damping days using shadow damping and picking days uniformly with a given minimal distance.
The idea behind shadow damping is the following: Days are picked randomly in the interval between min_damping_day and days. After picking one day a fixed number of days before and after the chosen day is blocked. The procedure is repeated till number_damping many days are chosen. To overcome the problem of higher probability at the boundary, the interval is artificially increased, artificial days are not counted. The corresponding factors are drawn uniformly from the interval (0,0.5)
- Parameters:
days – Number of days simulated per run.
number_dampings – Number of damping days generated.
min_distance – Minimal distance between two dampings
min_damping_day – First day, where a damping can be applied
- Returns:
Two lists of length number_dampingss containing the days and the factors.
- memilio.surrogatemodel.utils.dampings.dampings_random(
- days,
- number_dampings,
- min_damping_day=2,
- min_distance_damping_day=2,
Generate random damping days according to the following rule.
The days are drawn using geometrical distributed waiting times and a fixed minimal distance betweem two damping days. The first damping can occure at min_damping_day. The associated damping factors are drawn uniformly between 0 and 0.5.
- Parameters:
days – Number of days simulated per run.
number_dampings – Number of damping days generated.
min_distance – Minimal distance between two dampings
min_damping_day – First day, where a damping can be applied
- Returns:
Two lists of length number_dampingss containing the days and the factors.
- memilio.surrogatemodel.utils.dampings.generate_dampings(
- days,
- number_dampings,
- method,
- min_distance=2,
- min_damping_day=2,
Producing dampings for timeseries of length days according to the used method.
- Parameters:
days – Number of days per time series
number_dampings – Number of days on which damping can occur.
method – Method used to generate the dampings, possible values “classic”, “active”, “random”
min_distance – Minimal distance between two dampings
- Min_damping_day:
First day, where a damping can be applied
- Returns:
two lists containing the damping days and the associated damping factors
- memilio.surrogatemodel.utils.dampings.generate_dampings_withshadowdamp(
- number_of_dampings,
- days,
- min_distance,
- min_damping_day,
- number_of_runs,
Sampling the damping days according to the established method.
The idea is to draw dampings with a minimum distance while trying to keep the distribution of damping days uniformly. We create a list of all possible days, draw one damping day and delete all days before and after the damping that are within the range of the min_distance. To ensure that the the data is not biased, we include days outside the usual range. A day x in the middle of the list can be removed from the list by a drawn day before and after x. A day in the beggining of the list can be removed only by drawn days y , y>x. This leads to the effect that the first and last days are chosen more often. By drawing days ouside of the allowed range (forbidden dampings) which are removed after, we ensure that also the days at the beginning and end of the list can be removed from the list because of the minimum distance.
- Parameters:
number_of_dampings – Number of damping days per run
days – Total number of days per run
min_distance – Minimal distance between two damping days
min_damping_day – First day when a damping can be applied
- Number_of_runs:
Number of runs for which damping days should be generated
- Returns:
list of list of damping days.