Exemplo n.º 1
0
def test53():
    en =sim.Environment()
    d=sim.Normal(10, 3)
    d.print_info()
    d=sim.Normal(10, coefficient_of_variation=0.3)
    d.print_info()    
    d=sim.Normal(0, standard_deviation=3)
    d.print_info()
    d=sim.Normal(0, coefficient_of_variation=4)
    d.print_info()    
Exemplo n.º 2
0
 def discharge_cargo(self):
     self.location = self.cargo.discharge_port
     port_time = LOAD_DISCHARGE_TIME + sim.Normal(MEAN_PORT_DISRUPT, 0.25)
     yield self.hold(port_time)
     self.cargo.activate()
     log_file.write("{:.2f} - {}: {} discharged in {} \n".format(
         env.now(), self.name(), self.cargo.name(), self.location))
Exemplo n.º 3
0
 def process(self):
     while True:  # Continuous loop
         Cargo(load_port=self.load_port,
               discharge_port=random.choice(self.discharge_ports))
         yield self.hold(
             sim.Normal(
                 mean=self.cargo_interval_mean,
                 standard_deviation=self.cargo_interval_std).sample())
Exemplo n.º 4
0
def test56():
    env = sim.Environment()
    mon = sim.Monitor('number per second')
    for i in range(100):
        sample = sim.Normal(0.083,0.00166)()
        mon.tally(sample)
        
    mon = sim.Monitor('number per second')
    env.run(100)
    mon.print_histogram()
Exemplo n.º 5
0
def test43():
    def test(d):
        d.print_info()
        print('mean=', d.mean())
        l=[d() for i in range(10000)]
        print('one sample', d())
        print('mean sampled =', sum(l)/(len(l)+1))
        print('-'  * 79)

    env=sim.Environment()

    test(sim.IntUniform(1,6))
    test(sim.Weibull(2,1))
    test(sim.Gamma(5,9))
    test(sim.Erlang(2,scale=3))
    test(sim.Exponential(rate=2))
    test(sim.Beta(32,300))
    test(sim.Normal(5,7))
    test(sim.Normal(5,7,use_gauss=True))

    test(sim.Distribution('Exponential(rate=2)'))
    test(sim.Normal(5,5))
Exemplo n.º 6
0
def test3():
    print('test3')

    sim.Environment(random_seed=1234567)
    print('string')
    d = sim.Distribution('Exponential (1000)')
    sample_and_print(d, 5)
    sim.random_seed(1234567)
    sample_and_print(d, 5)
    sim.random_seed(None)
    sample_and_print(d, 5)

    print('triangular')
    tr = sim.Triangular(1, 5, 3)
    sample_and_print(tr, 5)

    print('uniform')
    u = sim.Uniform(1, 1.1)
    sample_and_print(u, 5)
    print('constant')
    c = sim.Constant(10)
    sample_and_print(c, 5)

    print('normal')
    n = sim.Normal(1, 2)
    sample_and_print(n, 5)
    sample_and_print(n, 5)

    print('cdf')
    cdf = sim.Cdf((1, 0, 2, 25, 2, 75, 3, 100))
    sample_and_print(cdf, 5)
    sample_and_print(cdf, 5)

    print('pdf')
    pdf = sim.Pdf((1, 2), 1)
    sample_and_print(pdf, 5)

    print('pdf 1')
    pdf = sim.Pdf((sim.Uniform(10, 20), 10, sim.Uniform(20, 30), 80,
                   sim.Uniform(30, 40), 10))
    sample_and_print(pdf, 5)

    print('pdf 2')
    pdf = sim.Pdf(
        (sim.Uniform(10, 20), sim.Uniform(20, 30), sim.Uniform(30, 40)),
        (10, 80, 10))
    sample_and_print(pdf, 5)

    print('pdf 3')
    pdf = sim.Pdf(('red', 'green', 1000), (10, 1, 10))
    sample_and_print(pdf, 5)
Exemplo n.º 7
0
def truncated_normal(m, sd):
    r = sim.Normal(m, sd).sample()
    while r < 0:
        r = sim.Normal(m, sd).sample()
    return r
Exemplo n.º 8
0
 def load_cargo(self):
     port_time = LOAD_DISCHARGE_TIME + sim.Normal(MEAN_PORT_DISRUPT, 0.25)
     yield self.hold(port_time)
Exemplo n.º 9
0
import salabim as sim

# Simulation Controls
TRACE = False
SIM_LENGTH = 5000
SIM_SPEED = 250

# Debugging
VERBOSE_ALL = 0
VERBOSE_BASE = 0
VERBOSE_CONSUMERS = 0
VERBOSE_SUPPLIERS = 0

# DDG
DDG_ARRIVAL_DIST = sim.Uniform(60, 110)
DDG_N_CONSUMED_DIST = sim.Uniform(20, 30)

# TAKEs
# TAKE_ARRIVAL_DIST = sim.Uniform(800, 1000)
TAKE_ARRIVAL_DIST = sim.Normal(800, 200)
TAKE_N_SUPPLIED = 200

# ERTs
NUM_FAST_ERT = 3
NUM_SLOW_ERT = 3

FAST_ERT_RELOAD_TIME = 15
SLOW_ERT_RELOAD_TIME = 30