version_initial
This commit is contained in:
0
faults/__init__.py
Normal file
0
faults/__init__.py
Normal file
BIN
faults/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
faults/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
faults/__pycache__/retry_delay.cpython-311.pyc
Normal file
BIN
faults/__pycache__/retry_delay.cpython-311.pyc
Normal file
Binary file not shown.
BIN
faults/__pycache__/wear_and_tear.cpython-311.pyc
Normal file
BIN
faults/__pycache__/wear_and_tear.cpython-311.pyc
Normal file
Binary file not shown.
31
faults/retry_delay.py
Normal file
31
faults/retry_delay.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import salabim as sim
|
||||
import numpy as np
|
||||
from math import exp
|
||||
|
||||
|
||||
class RetryDelay(sim.Component):
|
||||
"""
|
||||
This class represents the human operator retry delay type of fault.
|
||||
Simulated RetryDelay faults only apply to BowlFeeders.
|
||||
人为操作员重试延迟类型的故障。 模拟重试延迟故障
|
||||
"""
|
||||
def __init__(self, module, debug=True):
|
||||
super(RetryDelay, self).__init__()
|
||||
self.debug = debug
|
||||
self.t = 0
|
||||
self.module = module
|
||||
|
||||
def process(self):
|
||||
self.t = self.t + 1
|
||||
# (poissrnd((exp(t/5)-1)/4) * 0.2 + 1)
|
||||
# Note: The factor is zero-based so that it can be added as a separate delay.
|
||||
delay_factor = np.random.poisson((exp(self.t/5)-1)/4) * 0.2 # 泊松分布
|
||||
if self.debug:
|
||||
print("FAULT: RETRY_DELAY: ", delay_factor)
|
||||
yield self.add_delay(self.module.duration, delay_factor), 1
|
||||
|
||||
def add_delay(self, delay, delay_factor):
|
||||
return delay * delay_factor
|
||||
|
||||
# def spawn(self):
|
||||
# return self.env.process(self.process())
|
||||
31
faults/wear_and_tear.py
Normal file
31
faults/wear_and_tear.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from math import exp
|
||||
import salabim as sim
|
||||
|
||||
|
||||
class WearAndTear(sim.Component):
|
||||
|
||||
def __init__(self, module, debug=True):
|
||||
super(WearAndTear, self).__init__()
|
||||
self.debug = debug
|
||||
self.t = 0
|
||||
self.module = module
|
||||
|
||||
def process(self):
|
||||
# with self.request() as req:
|
||||
# yield req
|
||||
# yield self.request()
|
||||
self.t = self.t + 1
|
||||
# ((exp(t / 5.0) - 1) / 30 + 1)
|
||||
# Note: The factor is zero-based so that it can be added as a separate delay.
|
||||
delay_factor = (exp(self.t / 5.0) - 1) / 30
|
||||
extra_delay = delay_factor * self.module.duration
|
||||
if self.debug:
|
||||
print("FAULT: WEAR_AND_TEAR ", extra_delay)
|
||||
yield self.hold(extra_delay)
|
||||
return
|
||||
|
||||
def spawn(self):
|
||||
return self.process()
|
||||
|
||||
|
||||
# wear_and_tear = sim.Resource("wear_and_tear",10)
|
||||
Reference in New Issue
Block a user