Exemple #1
0
 def test_init_method(self):
     number_of_servers = 2
     queueing_capacity = 'Inf'
     schedule = None
     class_change_matrix = [[0.2, 0.8], [1.0, 0.0]]
     arrival_distributions = [["Uniform", 4.0, 9.0], ["Exponential", 5.0],
                              ["Gamma", 0.6, 1.2]]
     service_distributions = [["Gamma", 4.0, 9.0], ["Uniform", 0.6, 1.2],
                              ["Exponential", 5]]
     transition_matrix = [[0.2, 0.6, 0.2], [0.0, 0.0, 0.0], [0.5, 0.0, 0.0]]
     priority_class = 0
     batching_distributions = [['Deterministic', 1], ['Deterministic', 1],
                               ['Deterministic', 1]]
     baulking_functions = [None, None, example_baulking_function]
     service_centres = [
         ciw.ServiceCentre(number_of_servers, queueing_capacity,
                           class_change_matrix, schedule) for i in range(4)
     ]
     customer_classes = [
         ciw.CustomerClass(arrival_distributions, service_distributions,
                           transition_matrix, priority_class,
                           baulking_functions, batching_distributions)
         for i in range(2)
     ]
     N = ciw.Network(service_centres, customer_classes)
     self.assertEqual(N.service_centres, service_centres)
     self.assertEqual(N.customer_classes, customer_classes)
     self.assertEqual(N.number_of_nodes, 4)
     self.assertEqual(N.number_of_classes, 2)
     self.assertEqual(N.number_of_priority_classes, 1)
     self.assertEqual(N.priority_class_mapping, {0: 0, 1: 0})
Exemple #2
0
    def test_init_method(self):
        arrival_distributions = [["Uniform", 4.0, 9.0], ["Exponential", 5],
                                 ["Gamma", 0.6, 1.2]]
        service_distributions = [["Gamma", 4.0, 9.0], ["Uniform", 0.6, 1.2],
                                 ["Exponential", 5]]
        transition_matrix = [[.2, .6, .2], [0, 0, 0], [.5, 0, 0]]
        priority_class = 2
        baulking_functions = [None, None, example_baulking_function]
        batching_distributions = [['Deterministic', 1], ['Deterministic', 1],
                                  ['Deterministic', 1]]

        CC = ciw.CustomerClass(arrival_distributions, service_distributions,
                               transition_matrix, priority_class,
                               baulking_functions, batching_distributions)
        self.assertEqual(CC.arrival_distributions, arrival_distributions)
        self.assertEqual(CC.service_distributions, service_distributions)
        self.assertEqual(CC.batching_distributions, batching_distributions)
        self.assertEqual(CC.transition_matrix, transition_matrix)
        self.assertEqual(CC.priority_class, priority_class)

        # check baulking function works
        self.assertEqual(CC.baulking_functions[2](0), 0.0)
        self.assertEqual(CC.baulking_functions[2](1), 0.0)
        self.assertEqual(CC.baulking_functions[2](2), 0.0)
        self.assertEqual(CC.baulking_functions[2](3), 0.0)
        self.assertEqual(CC.baulking_functions[2](4), 0.0)
        self.assertEqual(CC.baulking_functions[2](5), 1.0)
        self.assertEqual(CC.baulking_functions[2](6), 1.0)
        self.assertEqual(CC.baulking_functions[2](7), 1.0)
        self.assertEqual(CC.baulking_functions[2](8), 1.0)
Exemple #3
0
    def test_init_method(self):
        arrival_distributions = [
            ciw.dists.Uniform(4.0, 9.0),
            ciw.dists.Exponential(5),
            ciw.dists.Gamma(0.6, 1.2)
        ]
        service_distributions = [
            ciw.dists.Gamma(4.0, 9.0),
            ciw.dists.Uniform(0.6, 1.2),
            ciw.dists.Exponential(5)
        ]
        routing = [[.2, .6, .2], [0, 0, 0], [.5, 0, 0]]
        priority_class = 2
        baulking_functions = [None, None, example_baulking_function]
        batching_distributions = [
            ciw.dists.Deterministic(1),
            ciw.dists.Deterministic(1),
            ciw.dists.Deterministic(1)
        ]
        reneging_time_distributions = [None, None, None]
        reneging_destinations = [-1, -1, -1]
        class_change_time_distributions = [None]

        CC = ciw.CustomerClass(arrival_distributions, service_distributions,
                               routing, priority_class, baulking_functions,
                               batching_distributions,
                               reneging_time_distributions,
                               reneging_destinations,
                               class_change_time_distributions)
        self.assertEqual(CC.arrival_distributions, arrival_distributions)
        self.assertEqual(CC.service_distributions, service_distributions)
        self.assertEqual(CC.batching_distributions, batching_distributions)
        self.assertEqual(CC.routing, routing)
        self.assertEqual(CC.priority_class, priority_class)
        self.assertEqual(CC.reneging_time_distributions,
                         reneging_time_distributions)
        self.assertEqual(CC.reneging_destinations, reneging_destinations)
        self.assertEqual(CC.class_change_time_distributions,
                         class_change_time_distributions)

        # check baulking function works
        self.assertEqual(CC.baulking_functions[2](0), 0.0)
        self.assertEqual(CC.baulking_functions[2](1), 0.0)
        self.assertEqual(CC.baulking_functions[2](2), 0.0)
        self.assertEqual(CC.baulking_functions[2](3), 0.0)
        self.assertEqual(CC.baulking_functions[2](4), 0.0)
        self.assertEqual(CC.baulking_functions[2](5), 1.0)
        self.assertEqual(CC.baulking_functions[2](6), 1.0)
        self.assertEqual(CC.baulking_functions[2](7), 1.0)
        self.assertEqual(CC.baulking_functions[2](8), 1.0)
Exemple #4
0
 def test_init_method(self):
     number_of_servers = 2
     queueing_capacity = float('inf')
     schedule = None
     class_change_matrix = [[0.2, 0.8], [1.0, 0.0]]
     arrival_distributions = [
         ciw.dists.Uniform(4.0, 9.0),
         ciw.dists.Exponential(5.0),
         ciw.dists.Gamma(0.6, 1.2)
     ]
     service_distributions = [
         ciw.dists.Gamma(4.0, 9.0),
         ciw.dists.Uniform(0.6, 1.2),
         ciw.dists.Exponential(5)
     ]
     routing = [[0.2, 0.6, 0.2], [0.0, 0.0, 0.0], [0.5, 0.0, 0.0]]
     priority_class = 0
     batching_distributions = [
         ciw.dists.Deterministic(1),
         ciw.dists.Deterministic(1),
         ciw.dists.Deterministic(1)
     ]
     baulking_functions = [None, None, example_baulking_function]
     reneging_time_distributions = [None, None, None]
     reneging_destinations = [-1, -1, -1]
     class_change_time_distributions = [None, None]
     service_centres = [
         ciw.ServiceCentre(number_of_servers, queueing_capacity,
                           class_change_matrix, schedule) for i in range(3)
     ]
     customer_classes = [
         ciw.CustomerClass(arrival_distributions, service_distributions,
                           routing, priority_class, baulking_functions,
                           batching_distributions,
                           reneging_time_distributions,
                           reneging_destinations,
                           class_change_time_distributions)
         for i in range(2)
     ]
     N = ciw.Network(service_centres, customer_classes)
     self.assertEqual(N.service_centres, service_centres)
     self.assertEqual(N.customer_classes, customer_classes)
     self.assertEqual(N.number_of_nodes, 3)
     self.assertEqual(N.number_of_classes, 2)
     self.assertEqual(N.number_of_priority_classes, 1)
     self.assertEqual(N.priority_class_mapping, {0: 0, 1: 0})
     self.assertFalse(N.service_centres[0].reneging)
     self.assertFalse(N.service_centres[1].reneging)
     self.assertFalse(N.service_centres[0].class_change_time)
     self.assertFalse(N.service_centres[1].class_change_time)