示例#1
0
 def __init__(self,
              arrival_rate: float,
              service_rate: float,
              precision: float = 1e-9):
     arrival = Poisson(arrival_rate)
     service = Poisson(service_rate)
     super().__init__(arrival, service, precision=precision)
示例#2
0
 def __init__(self,
              arrival_rate: float,
              service_rate: float,
              queue_capacity: int,
              precision: float = 1e-9):
     if abs(np.math.modf(queue_capacity)[0]) > 1e-12 or queue_capacity <= 0:
         raise ValueError(f"positive integer expected, "
                          f"but {queue_capacity} found")
     arrival = Poisson(arrival_rate)
     service = Poisson(service_rate)
     super().__init__(arrival,
                      service,
                      queue_capacity=queue_capacity,
                      precision=precision)
示例#3
0
    def test_moments_poisson_arrival(self):
        source = Poisson(3.0)

        self.assertIsInstance(stats.moment(source, 1), np.ndarray)
        self.assertIsInstance(stats.moment(source, 2), np.ndarray)
        assert_almost_equal(stats.moment(source, 1), [1 / 3], 10)
        assert_almost_equal(stats.moment(source, 2), [1 / 3, 2 / 9], 10)
    arrival_avg: Sequence[float]
    response_time_avg: Sequence[float]
    wait_time_avg: Sequence[float]
    delivery_delay_avg: Sequence[float]

    # Test parameters:
    tol: float = 1e-1
    max_packets: int = int(1.5e5)


# noinspection DuplicatedCode
@pytest.mark.parametrize(
    'props',
    [
        TandemProps(
            arrival=Poisson(2),
            service=[Poisson(5)],
            queue_capacity=4,
            # System and queue sizes:
            system_size_avg=[0.642],
            system_size_std=[0.981],
            queue_size_avg=[0.2444],
            queue_size_std=[0.6545],
            busy_avg=[0.3975],
            busy_std=[0.4894],
            # Scalar probabilities and rates:
            drop_prob=[0.0062],
            delivery_prob=[0.9938],
            utilization=[0.3975],
            # Intervals:
            departure_avg=[0.5031],
示例#5
0
from numpy.testing import assert_allclose

from pyqumo import stats
from pyqumo.arrivals import MarkovArrival, Poisson, \
    GIProcess


#
# POISSON PROCESS
# #######################
from pyqumo.random import Const, Uniform


@pytest.mark.parametrize('proc, m1, m2, m3, l1, string', [
    # Poisson process:
    (Poisson(1.0), 1, 2, 6, 0.0, '(Poisson: r=1)'),
    (Poisson(2.5), 0.4, 0.32, 0.384, 0.0, '(Poisson: r=2.5)'),
    # GI with uniform or constant distributions:
    (GIProcess(Const(3)), 3, 9, 27, 0, '(GI: f=(Const: value=3))'),
    (GIProcess(Uniform(2, 10)), 6, 124 / 3, 312, 0,
     '(GI: f=(Uniform: a=2, b=10))'),
    # MAP variants of Poisson or Erlang processes:
    (
        MarkovArrival.poisson(2.5),
        0.4, 0.32, 0.384, 0.0,
        '(MAP: d0=[[-2.5]], d1=[[2.5]])'
    ), (
        MarkovArrival.erlang(3, rate=4.2),
        0.714286, 0.680272, 0.809848, 0.0,
        '(MAP: d0=[[-4.2, 4.2, 0], [0, -4.2, 4.2], [0, 0, -4.2]], '
        'd1=[[0, 0, 0], [0, 0, 0], [4.2, 0, 0]])'
示例#6
0
 def departure(self):
     return Poisson(self.lambda_)
    utilization: float

    # Departure process properties:
    departure_rate: float

    # Response and wait time:
    response_time_avg: float
    wait_time_avg: float

    # Test parameters:
    tol: float = 1e-1
    max_packets: int = int(1e5)


@pytest.mark.parametrize('props', [
    GG1Props(arrival=Poisson(2),
             service=Poisson(5),
             queue_capacity=4,
             system_size_avg=0.642,
             system_size_std=0.981,
             queue_size_avg=0.2444,
             queue_size_std=0.6545,
             loss_prob=0.0062,
             utilization=0.3975,
             departure_rate=1.9877,
             response_time_avg=0.323,
             wait_time_avg=0.123),
    GG1Props(arrival=Exponential(42),
             service=Exponential(34),
             queue_capacity=7,
             system_size_avg=5.3295,
    arrival_avg: Sequence[float]
    response_time_avg: Sequence[float]
    wait_time_avg: Sequence[float]
    delivery_delay_avg: Sequence[float]

    # Test parameters:
    tol: float = 1e-1
    max_packets: int = int(1.5e5)


# noinspection DuplicatedCode
@pytest.mark.parametrize(
    'props',
    [
        TandemProps(
            arrival=Poisson(2),
            service=Poisson(5),
            queue_capacity=4,
            num_stations=1,
            # System and queue sizes:
            system_size_avg=[0.642],
            system_size_std=[0.981],
            queue_size_avg=[0.2444],
            queue_size_std=[0.6545],
            busy_avg=[0.3975],
            busy_std=[0.4894],
            # Scalar probabilities and rates:
            drop_prob=[0.0062],
            delivery_prob=[0.9938],
            utilization=[0.3975],
            # Intervals:
示例#9
0
    # Departure process properties:
    departure_rate: float

    # Response and wait time:
    response_time_avg: float
    wait_time_avg: float

    # Test parameters:
    tol: float = 1e-1
    max_packets: int = int(1e5)


@pytest.mark.parametrize('props', [
    GG1Props(
        arrival=Poisson(2), service=Poisson(5), queue_capacity=4,
        system_size_avg=0.642, system_size_std=0.981,
        queue_size_avg=0.2444, queue_size_std=0.6545,
        loss_prob=0.0062, utilization=0.3975, departure_rate=1.9877,
        response_time_avg=0.323, wait_time_avg=0.123),
    GG1Props(
        arrival=Exponential(42), service=Exponential(34),
        queue_capacity=7,
        system_size_avg=5.3295, system_size_std=5.6015**0.5,
        queue_size_avg=4.3708, queue_size_std=5.2010**0.5,
        loss_prob=0.2239, utilization=0.9587, departure_rate=32.5959,
        response_time_avg=0.163, wait_time_avg=0.134,
        max_packets=int(1e5)
    ),
    GG1Props(
        arrival=Poisson(1), service=Exponential(2),