def __init__(self, sim, connections, **kwargs): """ Initialize the workload with the simulation (containing both the environment and the topology for work), the set of connections to cause outages for as a group, and any additional arguments. """ self.sim = sim self.connections = connections self.do_outage = Bernoulli( kwargs.pop('outage_prob', settings.simulation.outage_prob)) # NOTE: This will not call any methods on the connections (on purpose) self._state = ONLINE # Distribution of outage duration self.outage_duration = BoundedNormal( kwargs.pop('outage_mean', settings.simulation.outage_mean), kwargs.pop('outage_stddev', settings.simulation.outage_stddev), floor=10.0, ) # Distribution of online duration self.online_duration = BoundedNormal( kwargs.pop('online_mean', settings.simulation.online_mean), kwargs.pop('online_stddev', settings.simulation.online_stddev), floor=10.0, ) # Initialize the Process super(OutageGenerator, self).__init__(sim.env)
def __init__(self, sim, **kwargs): """ Initialize workload probabilities and distributions before passing all optional keyword arguments to the super class. """ # Distribution for whether or not to change objects self.do_object = Bernoulli( kwargs.pop('object_prob', settings.simulation.object_prob)) self.do_read = Bernoulli( kwargs.pop('read_prob', settings.simulation.read_prob)) # Interval distribution for the wait (in ms) to the next access. self.next_access = BoundedNormal( kwargs.pop('access_mean', settings.simulation.access_mean), kwargs.pop('access_stddev', settings.simulation.access_stddev), floor=1.0, ) # Initialize the Workload super(RoutineWorkload, self).__init__(sim, **kwargs) # If current is None, update the state of the workload: if self.current is None: self.update()