Example #1
0
    def test_create_network_from_dictionary(self):
        params = {'Arrival_distributions': {'Class 0': [['Exponential', 3.0]]},
                  'Service_distributions': {'Class 0': [['Exponential', 7.0]]},
                  'Number_of_servers': [9],
                  'Number_of_classes': 1,
                  'Transition_matrices': {'Class 0': [[0.5]]},
                  'Number_of_nodes': 1,
                  'Queue_capacities': ['Inf']}
        N = ciw.create_network_from_dictionary(params)
        
        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].class_change_matrix, None)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.customer_classes[0].arrival_distributions, [['Exponential', 3.0]])
        self.assertEqual(N.customer_classes[0].service_distributions, [['Exponential', 7.0]])
        self.assertEqual(N.customer_classes[0].transition_matrix, [[0.5]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0:0})


        params = {'Arrival_distributions': [['Exponential', 3.0],
                                            ['Uniform', 0.2, 0.6]],
                  'Service_distributions': [['Exponential', 7.0],
                                            ['Deterministic', 0.7]],
                  'Number_of_servers': ['my_amazing_schedule', 3],
                  'Transition_matrices': [[0.5, 0.2],
                                          [0.0, 0.0]],
                  'Queue_capacities': [10, 'Inf'],
                  'my_amazing_schedule': [[20, 1],
                                          [50, 4]]}
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 2)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, 10)
        self.assertEqual(N.service_centres[0].number_of_servers, 'schedule')
        self.assertEqual(N.service_centres[0].class_change_matrix, None)
        self.assertEqual(N.service_centres[0].schedule, [[20, 1], [50, 4]])
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.service_centres[1].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[1].number_of_servers, 3)
        self.assertEqual(N.service_centres[1].class_change_matrix, None)
        self.assertEqual(N.service_centres[1].schedule, None)
        self.assertFalse(N.service_centres[1].preempt)
        self.assertEqual(N.customer_classes[0].arrival_distributions, [['Exponential', 3.0], ['Uniform', 0.2, 0.6]])
        self.assertEqual(N.customer_classes[0].service_distributions, [['Exponential', 7.0], ['Deterministic', 0.7]])
        self.assertEqual(N.customer_classes[0].transition_matrix, [[0.5, 0.2], [0.0, 0.0]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0:0})


        params = {'Arrival_distributions': {'Class 0': [['Exponential', 3.0]],
                                            'Class 1': [['Exponential', 4.0]]},
                  'Service_distributions': {'Class 0': [['Exponential', 7.0]],
                                            'Class 1': [['Uniform', 0.4, 1.2]]},
                  'Number_of_servers': [9],
                  'Transition_matrices': {'Class 0': [[0.5]],
                                          'Class 1': [[0.0]]},
                  'Number_of_nodes': 1,
                  'Queue_capacities': ['Inf'],
                  'Class_change_matrices': {'Node 1': [[0.0, 1.0],
                                                       [0.2, 0.8]]}}
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 2)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].class_change_matrix, [[0.0, 1.0], [0.2, 0.8]])
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.customer_classes[0].arrival_distributions, [['Exponential', 3.0]])
        self.assertEqual(N.customer_classes[0].service_distributions, [['Exponential', 7.0]])
        self.assertEqual(N.customer_classes[0].transition_matrix, [[0.5]])
        self.assertEqual(N.customer_classes[1].arrival_distributions, [['Exponential', 4.0]])
        self.assertEqual(N.customer_classes[1].service_distributions, [['Uniform', 0.4, 1.2]])
        self.assertEqual(N.customer_classes[1].transition_matrix, [[0.0]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0:0, 1:0})


        params = {'Arrival_distributions': {'Class 0': [['Exponential', 3.0]],
                                            'Class 1': [['Exponential', 4.0]]},
                  'Service_distributions': {'Class 0': [['Exponential', 7.0]],
                                            'Class 1': [['Uniform', 0.4, 1.2]]},
                  'Number_of_servers': [9],
                  'Transition_matrices': {'Class 0': [[0.5]],
                                          'Class 1': [[0.0]]},
                  'Number_of_nodes': 1,
                  'Queue_capacities': ['Inf'],
                  'Priority_classes': {'Class 0': 1,
                                       'Class 1': 0}}
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 2)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.customer_classes[0].arrival_distributions, [['Exponential', 3.0]])
        self.assertEqual(N.customer_classes[0].service_distributions, [['Exponential', 7.0]])
        self.assertEqual(N.customer_classes[0].transition_matrix, [[0.5]])
        self.assertEqual(N.customer_classes[1].arrival_distributions, [['Exponential', 4.0]])
        self.assertEqual(N.customer_classes[1].service_distributions, [['Uniform', 0.4, 1.2]])
        self.assertEqual(N.customer_classes[1].transition_matrix, [[0.0]])
        self.assertEqual(N.customer_classes[0].priority_class, 1)
        self.assertEqual(N.customer_classes[1].priority_class, 0)
        self.assertEqual(N.number_of_priority_classes, 2)
        self.assertEqual(N.priority_class_mapping, {0:1, 1:0})


        params = {'Arrival_distributions': [['Exponential', 3.0], ['Exponential', 4.0], ['Exponential', 2.0]],
                  'Service_distributions': [['Exponential', 7.0], ['Uniform', 0.4, 1.2], ['Deterministic', 5.33]],
                  'Number_of_servers': [9, 2, 4],
                  'Transition_matrices': [[0.5, 0.0, 0.1],
                                          [0.2, 0.1, 0.0],
                                          [0.0, 0.0, 0.0]],
                  'Number_of_nodes': 3,
                  'Queue_capacities': ['Inf', 'Inf', 'Inf'],
                  'Baulking_functions': [None, None, example_baulking_function]}
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 3)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.service_centres[1].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[1].number_of_servers, 2)
        self.assertEqual(N.service_centres[1].schedule, None)
        self.assertFalse(N.service_centres[1].preempt)
        self.assertEqual(N.service_centres[2].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[2].number_of_servers, 4)
        self.assertEqual(N.service_centres[2].schedule, None)
        self.assertFalse(N.service_centres[2].preempt)

        self.assertEqual(N.customer_classes[0].arrival_distributions, [['Exponential', 3.0], ['Exponential', 4.0], ['Exponential', 2.0]])
        self.assertEqual(N.customer_classes[0].service_distributions, [['Exponential', 7.0], ['Uniform', 0.4, 1.2], ['Deterministic', 5.33]])
        self.assertEqual(N.customer_classes[0].transition_matrix, [[0.5, 0.0, 0.1],
                                                                   [0.2, 0.1, 0.0],
                                                                   [0.0, 0.0, 0.0]])
        self.assertEqual(N.customer_classes[0].baulking_functions, [None, None, example_baulking_function])
        self.assertEqual(N.number_of_priority_classes, 1)
Example #2
0
    def test_create_network_from_dictionary(self):
        params = {
            'Arrival_distributions': {
                'Class 0': [['Exponential', 3.0]]
            },
            'Service_distributions': {
                'Class 0': [['Exponential', 7.0]]
            },
            'Number_of_servers': [9],
            'Transition_matrices': {
                'Class 0': [[0.5]]
            },
            'Queue_capacities': ['Inf']
        }
        N = ciw.create_network_from_dictionary(params)

        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].class_change_matrix, None)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.customer_classes[0].arrival_distributions,
                         [['Exponential', 3.0]])
        self.assertEqual(N.customer_classes[0].service_distributions,
                         [['Exponential', 7.0]])
        self.assertEqual(N.customer_classes[0].transition_matrix, [[0.5]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0: 0})

        params = {
            'Arrival_distributions': [['Exponential', 3.0],
                                      ['Uniform', 0.2, 0.6]],
            'Service_distributions': [['Exponential', 7.0],
                                      ['Deterministic', 0.7]],
            'Number_of_servers': [[[1, 20], [4, 50]], 3],
            'Transition_matrices': [[0.5, 0.2], [0.0, 0.0]],
            'Queue_capacities': [10, 'Inf']
        }
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 2)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, 10)
        self.assertEqual(N.service_centres[0].number_of_servers, 'schedule')
        self.assertEqual(N.service_centres[0].class_change_matrix, None)
        self.assertEqual(N.service_centres[0].schedule, [[1, 20], [4, 50]])
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.service_centres[1].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[1].number_of_servers, 3)
        self.assertEqual(N.service_centres[1].class_change_matrix, None)
        self.assertEqual(N.service_centres[1].schedule, None)
        self.assertFalse(N.service_centres[1].preempt)
        self.assertEqual(N.customer_classes[0].arrival_distributions,
                         [['Exponential', 3.0], ['Uniform', 0.2, 0.6]])
        self.assertEqual(N.customer_classes[0].service_distributions,
                         [['Exponential', 7.0], ['Deterministic', 0.7]])
        self.assertEqual(N.customer_classes[0].transition_matrix,
                         [[0.5, 0.2], [0.0, 0.0]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0: 0})

        params = {
            'Arrival_distributions': {
                'Class 0': [['Exponential', 3.0]],
                'Class 1': [['Exponential', 4.0]]
            },
            'Service_distributions': {
                'Class 0': [['Exponential', 7.0]],
                'Class 1': [['Uniform', 0.4, 1.2]]
            },
            'Number_of_servers': [9],
            'Transition_matrices': {
                'Class 0': [[0.5]],
                'Class 1': [[0.0]]
            },
            'Queue_capacities': ['Inf'],
            'Class_change_matrices': {
                'Node 1': [[0.0, 1.0], [0.2, 0.8]]
            }
        }
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 2)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].class_change_matrix,
                         [[0.0, 1.0], [0.2, 0.8]])
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.customer_classes[0].arrival_distributions,
                         [['Exponential', 3.0]])
        self.assertEqual(N.customer_classes[0].service_distributions,
                         [['Exponential', 7.0]])
        self.assertEqual(N.customer_classes[0].transition_matrix, [[0.5]])
        self.assertEqual(N.customer_classes[1].arrival_distributions,
                         [['Exponential', 4.0]])
        self.assertEqual(N.customer_classes[1].service_distributions,
                         [['Uniform', 0.4, 1.2]])
        self.assertEqual(N.customer_classes[1].transition_matrix, [[0.0]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0: 0, 1: 0})

        params = {
            'Arrival_distributions': {
                'Class 0': [['Exponential', 3.0]],
                'Class 1': [['Exponential', 4.0]]
            },
            'Service_distributions': {
                'Class 0': [['Exponential', 7.0]],
                'Class 1': [['Uniform', 0.4, 1.2]]
            },
            'Number_of_servers': [9],
            'Transition_matrices': {
                'Class 0': [[0.5]],
                'Class 1': [[0.0]]
            },
            'Queue_capacities': ['Inf'],
            'Priority_classes': {
                'Class 0': 1,
                'Class 1': 0
            }
        }
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 2)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.customer_classes[0].arrival_distributions,
                         [['Exponential', 3.0]])
        self.assertEqual(N.customer_classes[0].service_distributions,
                         [['Exponential', 7.0]])
        self.assertEqual(N.customer_classes[0].transition_matrix, [[0.5]])
        self.assertEqual(N.customer_classes[1].arrival_distributions,
                         [['Exponential', 4.0]])
        self.assertEqual(N.customer_classes[1].service_distributions,
                         [['Uniform', 0.4, 1.2]])
        self.assertEqual(N.customer_classes[1].transition_matrix, [[0.0]])
        self.assertEqual(N.customer_classes[0].priority_class, 1)
        self.assertEqual(N.customer_classes[1].priority_class, 0)
        self.assertEqual(N.number_of_priority_classes, 2)
        self.assertEqual(N.priority_class_mapping, {0: 1, 1: 0})

        params = {
            'Arrival_distributions': [['Exponential',
                                       3.0], ['Exponential', 4.0],
                                      ['Exponential', 2.0]],
            'Service_distributions': [['Exponential', 7.0],
                                      ['Uniform', 0.4, 1.2],
                                      ['Deterministic', 5.33]],
            'Number_of_servers': [9, 2, 4],
            'Transition_matrices': [[0.5, 0.0, 0.1], [0.2, 0.1, 0.0],
                                    [0.0, 0.0, 0.0]],
            'Queue_capacities': ['Inf', 'Inf', 'Inf'],
            'Baulking_functions': [None, None, example_baulking_function]
        }
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 3)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.service_centres[1].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[1].number_of_servers, 2)
        self.assertEqual(N.service_centres[1].schedule, None)
        self.assertFalse(N.service_centres[1].preempt)
        self.assertEqual(N.service_centres[2].queueing_capacity, float('Inf'))
        self.assertEqual(N.service_centres[2].number_of_servers, 4)
        self.assertEqual(N.service_centres[2].schedule, None)
        self.assertFalse(N.service_centres[2].preempt)

        self.assertEqual(
            N.customer_classes[0].arrival_distributions,
            [['Exponential', 3.0], ['Exponential', 4.0], ['Exponential', 2.0]])
        self.assertEqual(N.customer_classes[0].service_distributions,
                         [['Exponential', 7.0], ['Uniform', 0.4, 1.2],
                          ['Deterministic', 5.33]])
        self.assertEqual(N.customer_classes[0].transition_matrix,
                         [[0.5, 0.0, 0.1], [0.2, 0.1, 0.0], [0.0, 0.0, 0.0]])
        self.assertEqual(N.customer_classes[0].baulking_functions,
                         [None, None, example_baulking_function])
        self.assertEqual(N.number_of_priority_classes, 1)
Example #3
0
    def test_change_customer_class_method(self):
        ciw.seed(14)
        Q = ciw.Simulation(
            ciw.create_network_from_yml(
                'ciw/tests/testing_parameters/params_change_class.yml'))
        N1 = Q.transitive_nodes[0]
        ind = ciw.Individual(254, 0)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.previous_class, 0)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.previous_class, 0)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.previous_class, 0)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.previous_class, 0)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.previous_class, 1)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.previous_class, 1)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.previous_class, 0)

        # Test for case of having priorities
        ciw.seed(14)
        parameters_dictionary = {
            'arrival_distributions': {
                'Class 0':
                [ciw.dists.Exponential(0.05),
                 ciw.dists.Exponential(0.04)],
                'Class 1':
                [ciw.dists.Exponential(0.04),
                 ciw.dists.Exponential(0.06)]
            },
            'service_distributions': {
                'Class 0':
                [ciw.dists.Deterministic(5),
                 ciw.dists.Deterministic(5)],
                'Class 1':
                [ciw.dists.Deterministic(10),
                 ciw.dists.Deterministic(10)]
            },
            'routing': {
                'Class 0': [[0.8, 0.1], [0.0, 0.0]],
                'Class 1': [[0.8, 0.1], [0.2, 0.0]]
            },
            'number_of_servers': [4, 3],
            'class_change_matrices': {
                'Node 1': [[.5, .5], [.25, .75]],
                'Node 2': [[1, 0], [0, 1]]
            },
            'priority_classes': {
                'Class 0': 0,
                'Class 1': 1
            }
        }
        Q = ciw.Simulation(
            ciw.create_network_from_dictionary(parameters_dictionary))
        N1 = Q.transitive_nodes[0]
        ind = ciw.Individual(254, 0)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.priority_class, 0)
        self.assertEqual(ind.previous_class, 0)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.priority_class, 0)
        self.assertEqual(ind.previous_class, 0)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.priority_class, 0)
        self.assertEqual(ind.previous_class, 0)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.priority_class, 1)
        self.assertEqual(ind.previous_class, 0)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.priority_class, 1)
        self.assertEqual(ind.previous_class, 1)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.priority_class, 1)
        self.assertEqual(ind.previous_class, 1)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.priority_class, 1)
        self.assertEqual(ind.previous_class, 1)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.priority_class, 1)
        self.assertEqual(ind.previous_class, 1)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 1)
        self.assertEqual(ind.priority_class, 1)
        self.assertEqual(ind.previous_class, 1)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.priority_class, 0)
        self.assertEqual(ind.previous_class, 1)
        N1.change_customer_class(ind)
        self.assertEqual(ind.customer_class, 0)
        self.assertEqual(ind.priority_class, 0)
        self.assertEqual(ind.previous_class, 0)
Example #4
0
    def test_create_network_from_dictionary(self):
        params = {
            'arrival_distributions': {
                'Class 0': [ciw.dists.Exponential(3.0)]
            },
            'service_distributions': {
                'Class 0': [ciw.dists.Exponential(7.0)]
            },
            'number_of_servers': [9],
            'routing': {
                'Class 0': [[0.5]]
            },
            'queue_capacities': [float('inf')]
        }
        N = ciw.create_network_from_dictionary(params)

        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].class_change_matrix, None)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].arrival_distributions],
            ['Exponential: 3.0'])
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].service_distributions],
            ['Exponential: 7.0'])
        self.assertEqual(N.customer_classes[0].routing, [[0.5]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0: 0})

        params = {
            'arrival_distributions':
            [ciw.dists.Exponential(3.0),
             ciw.dists.Uniform(0.2, 0.6)],
            'service_distributions':
            [ciw.dists.Exponential(7.0),
             ciw.dists.Deterministic(0.7)],
            'number_of_servers': [[[1, 20], [4, 50]], 3],
            'routing': [[0.5, 0.2], [0.0, 0.0]],
            'queue_capacities': [10, float('inf')]
        }
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 2)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, 10)
        self.assertEqual(N.service_centres[0].number_of_servers, 'schedule')
        self.assertEqual(N.service_centres[0].class_change_matrix, None)
        self.assertEqual(N.service_centres[0].schedule, [[1, 20], [4, 50]])
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.service_centres[1].queueing_capacity, float('inf'))
        self.assertEqual(N.service_centres[1].number_of_servers, 3)
        self.assertEqual(N.service_centres[1].class_change_matrix, None)
        self.assertEqual(N.service_centres[1].schedule, None)
        self.assertFalse(N.service_centres[1].preempt)
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].arrival_distributions],
            ['Exponential: 3.0', 'Uniform: 0.2, 0.6'])
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].service_distributions],
            ['Exponential: 7.0', 'Deterministic: 0.7'])
        self.assertEqual(N.customer_classes[0].routing,
                         [[0.5, 0.2], [0.0, 0.0]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0: 0})

        params = {
            'arrival_distributions': {
                'Class 0': [ciw.dists.Exponential(3.0)],
                'Class 1': [ciw.dists.Exponential(4.0)]
            },
            'service_distributions': {
                'Class 0': [ciw.dists.Exponential(7.0)],
                'Class 1': [ciw.dists.Uniform(0.4, 1.2)]
            },
            'number_of_servers': [9],
            'routing': {
                'Class 0': [[0.5]],
                'Class 1': [[0.0]]
            },
            'queue_capacities': [float('inf')],
            'class_change_matrices': {
                'Node 1': [[0.0, 1.0], [0.2, 0.8]]
            }
        }
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 2)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].class_change_matrix,
                         [[0.0, 1.0], [0.2, 0.8]])
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].arrival_distributions],
            ['Exponential: 3.0'])
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].service_distributions],
            ['Exponential: 7.0'])
        self.assertEqual(N.customer_classes[0].routing, [[0.5]])
        self.assertEqual(
            [str(d) for d in N.customer_classes[1].arrival_distributions],
            ['Exponential: 4.0'])
        self.assertEqual(
            [str(d) for d in N.customer_classes[1].service_distributions],
            ['Uniform: 0.4, 1.2'])
        self.assertEqual(N.customer_classes[1].routing, [[0.0]])
        self.assertEqual(N.number_of_priority_classes, 1)
        self.assertEqual(N.priority_class_mapping, {0: 0, 1: 0})

        params = {
            'arrival_distributions': {
                'Class 0': [ciw.dists.Exponential(3.0)],
                'Class 1': [ciw.dists.Exponential(4.0)]
            },
            'service_distributions': {
                'Class 0': [ciw.dists.Exponential(7.0)],
                'Class 1': [ciw.dists.Uniform(0.4, 1.2)]
            },
            'number_of_servers': [9],
            'routing': {
                'Class 0': [[0.5]],
                'Class 1': [[0.0]]
            },
            'queue_capacities': [float('inf')],
            'priority_classes': {
                'Class 0': 1,
                'Class 1': 0
            }
        }
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 1)
        self.assertEqual(N.number_of_classes, 2)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].arrival_distributions],
            ['Exponential: 3.0'])
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].service_distributions],
            ['Exponential: 7.0'])
        self.assertEqual(N.customer_classes[0].routing, [[0.5]])
        self.assertEqual(
            [str(d) for d in N.customer_classes[1].arrival_distributions],
            ['Exponential: 4.0'])
        self.assertEqual(
            [str(d) for d in N.customer_classes[1].service_distributions],
            ['Uniform: 0.4, 1.2'])
        self.assertEqual(N.customer_classes[1].routing, [[0.0]])
        self.assertEqual(N.customer_classes[0].priority_class, 1)
        self.assertEqual(N.customer_classes[1].priority_class, 0)
        self.assertEqual(N.number_of_priority_classes, 2)
        self.assertEqual(N.priority_class_mapping, {0: 1, 1: 0})

        params = {
            'arrival_distributions': [
                ciw.dists.Exponential(3.0),
                ciw.dists.Exponential(4.0),
                ciw.dists.Exponential(2.0)
            ],
            'service_distributions': [
                ciw.dists.Exponential(7.0),
                ciw.dists.Uniform(0.4, 1.2),
                ciw.dists.Deterministic(5.33)
            ],
            'number_of_servers': [9, 2, 4],
            'routing': [[0.5, 0.0, 0.1], [0.2, 0.1, 0.0], [0.0, 0.0, 0.0]],
            'queue_capacities': [float('inf'),
                                 float('inf'),
                                 float('inf')],
            'baulking_functions': [None, None, example_baulking_function]
        }
        N = ciw.create_network_from_dictionary(params)
        self.assertEqual(N.number_of_nodes, 3)
        self.assertEqual(N.number_of_classes, 1)
        self.assertEqual(N.service_centres[0].queueing_capacity, float('inf'))
        self.assertEqual(N.service_centres[0].number_of_servers, 9)
        self.assertEqual(N.service_centres[0].schedule, None)
        self.assertFalse(N.service_centres[0].preempt)
        self.assertEqual(N.service_centres[1].queueing_capacity, float('inf'))
        self.assertEqual(N.service_centres[1].number_of_servers, 2)
        self.assertEqual(N.service_centres[1].schedule, None)
        self.assertFalse(N.service_centres[1].preempt)
        self.assertEqual(N.service_centres[2].queueing_capacity, float('inf'))
        self.assertEqual(N.service_centres[2].number_of_servers, 4)
        self.assertEqual(N.service_centres[2].schedule, None)
        self.assertFalse(N.service_centres[2].preempt)

        self.assertEqual(
            [str(d) for d in N.customer_classes[0].arrival_distributions],
            ['Exponential: 3.0', 'Exponential: 4.0', 'Exponential: 2.0'])
        self.assertEqual(
            [str(d) for d in N.customer_classes[0].service_distributions],
            ['Exponential: 7.0', 'Uniform: 0.4, 1.2', 'Deterministic: 5.33'])
        self.assertEqual(N.customer_classes[0].routing,
                         [[0.5, 0.0, 0.1], [0.2, 0.1, 0.0], [0.0, 0.0, 0.0]])
        self.assertEqual(N.customer_classes[0].baulking_functions,
                         [None, None, example_baulking_function])
        self.assertEqual(N.number_of_priority_classes, 1)