Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5de3542
disambiguate spelling 'nd' as 'node'
galenseilis Dec 7, 2025
ff42928
replace nd_x with node_x_records
galenseilis Dec 7, 2025
2fb69d8
"orignal" rather than "origional"
galenseilis Dec 7, 2025
dcc2139
spelling of 'repetition' and 'probability'
galenseilis Dec 7, 2025
db45612
spelling 'distribution'
galenseilis Dec 7, 2025
72ef7a3
spelling 'offers'
galenseilis Dec 7, 2025
975b59c
spelling "repetition"
galenseilis Dec 7, 2025
691a25b
Spelling "repetition"
galenseilis Dec 7, 2025
7761318
fix more spelling mistakes and de-abbreviate
galenseilis Dec 8, 2025
67718e9
fix typo for 'distribution'
galenseilis Dec 8, 2025
f62818b
fix typo for spelling "that" and "which"
galenseilis Dec 8, 2025
19ce2f9
remove plural 's' from 'among'
galenseilis Dec 8, 2025
c0d7597
remove abbreviation for 'node'
galenseilis Dec 8, 2025
bc1e3f8
spelling "prioritises"
galenseilis Dec 8, 2025
49160e5
spelling "detach"
galenseilis Dec 8, 2025
917aeec
spelling "maximum"
galenseilis Dec 8, 2025
86853e7
format doctest script
galenseilis Dec 8, 2025
2022cb6
spelling "function"
galenseilis Dec 8, 2025
461f752
fix spelling and sentence structure for note on creating networks usi…
galenseilis Dec 8, 2025
9f43b52
deabbreviate active_node
galenseilis Dec 8, 2025
f9bc477
spelling conjunction
galenseilis Dec 8, 2025
c6c538a
spelling objects
galenseilis Dec 8, 2025
2966f80
Spelling of observed and deabbreviating individuals
galenseilis Dec 8, 2025
7901e97
snake case instance variable names for mixture distribution
galenseilis Dec 8, 2025
c4dc97f
snake case variable for mixture distribution in test suite
galenseilis Dec 8, 2025
64a2704
fix typo for "expected"
galenseilis Dec 8, 2025
909c76f
deabbreviate nodes
galenseilis Dec 8, 2025
59cdba8
spelling consistent
galenseilis Dec 8, 2025
3aae580
fix spelling mistakes for consistent
galenseilis Dec 8, 2025
fab512f
deabbreviate "transitive node"
galenseilis Dec 8, 2025
ca29541
spelling of detach in deadlock system
galenseilis Dec 8, 2025
f769f9f
deabbreviate index and server
galenseilis Dec 8, 2025
9b3c83f
spelling initial and matrix
galenseilis Dec 8, 2025
e3635e6
deabbreviate node and individual
galenseilis Dec 8, 2025
d3320b2
deabbreviate node
galenseilis Dec 8, 2025
142d006
deabbreviate node
galenseilis Dec 8, 2025
7bbdc48
spelling consistent
galenseilis Dec 8, 2025
b963a0c
spelling function
galenseilis Dec 8, 2025
6eafa2b
Deabbreviated "node" and "customer class".
galenseilis Dec 8, 2025
a06be88
deabbreviate "node""
galenseilis Dec 8, 2025
0f04586
deabbreviate node
galenseilis Dec 8, 2025
bae9cd1
deabbreviate node identifier
galenseilis Dec 8, 2025
24b846c
deabbreviate node
galenseilis Dec 8, 2025
c1004f9
deabbreviate node index
galenseilis Dec 8, 2025
3ea7ae1
deabbreviate node
galenseilis Dec 8, 2025
bde7501
deabbreviate node index
galenseilis Dec 8, 2025
c699cf0
spelling constant
galenseilis Dec 8, 2025
6423bdd
Deabbreviate "node".
galenseilis Dec 8, 2025
b8f73d6
spelling validity
galenseilis Dec 8, 2025
14ad193
spelling discrepancies
galenseilis Dec 8, 2025
1a55172
spelling available
galenseilis Dec 8, 2025
988fb29
spelling discrepancies
galenseilis Dec 8, 2025
aa5830c
deabbreviate nodes
galenseilis Dec 8, 2025
ee60a08
deabbreviate "node" and "customer class"
galenseilis Dec 8, 2025
5037e8a
spelling receiving
galenseilis Dec 8, 2025
bd020c5
deabbreviate node
galenseilis Dec 8, 2025
b88eca2
spelling relevant
galenseilis Dec 8, 2025
e7a89b4
deabbreviate node
galenseilis Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions ciw/arrival_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def __init__(self, simulation):
self.number_accepted_individuals_per_class = {clss: 0 for clss in self.simulation.network.customer_class_names}
self.system_capacity = self.simulation.network.system_capacity
self.event_dates_dict = {
nd + 1: {clss: False for clss in self.simulation.network.customer_class_names
} for nd in range(self.simulation.network.number_of_nodes)
node + 1: {clss: False for clss in self.simulation.network.customer_class_names
} for node in range(self.simulation.network.number_of_nodes)
}

def initialise(self):
Expand Down Expand Up @@ -66,20 +66,20 @@ def find_next_event_date(self):
minnd = None
minclss = None
mindate = float("Inf")
for nd in self.event_dates_dict:
for clss in self.event_dates_dict[nd]:
if self.event_dates_dict[nd][clss] < mindate:
minnd = nd
for node in self.event_dates_dict:
for clss in self.event_dates_dict[node]:
if self.event_dates_dict[node][clss] < mindate:
minnd = node
minclss = clss
mindate = self.event_dates_dict[nd][clss]
mindate = self.event_dates_dict[node][clss]
self.next_node = minnd
self.next_class = minclss
self.next_event_date = mindate

def have_event(self):
"""
Finds a batch size. Creates that many Individuals and send
them to the relevent node. Then updates the event_dates_dict.
them to the relevant node. Then updates the event_dates_dict.
"""
batch = self.batch_size(self.next_node, self.next_class)
for _ in range(batch):
Expand Down Expand Up @@ -114,25 +114,25 @@ def initialise_event_dates_dict(self):
Initialises the next event dates dictionary
with random times for each node and class.
"""
for nd in self.event_dates_dict:
for clss in self.event_dates_dict[nd]:
if self.simulation.inter_arrival_times[nd][clss] is not None:
self.event_dates_dict[nd][clss] = self.inter_arrival(nd, clss)
for node in self.event_dates_dict:
for clss in self.event_dates_dict[node]:
if self.simulation.inter_arrival_times[node][clss] is not None:
self.event_dates_dict[node][clss] = self.inter_arrival(node, clss)
else:
self.event_dates_dict[nd][clss] = float("inf")
self.event_dates_dict[node][clss] = float("inf")

def inter_arrival(self, nd, clss):
def inter_arrival(self, node, customer_class):
"""
Samples the inter-arrival time for next class and node.
"""
return self.simulation.inter_arrival_times[nd][clss]._sample(t=self.simulation.current_time)
return self.simulation.inter_arrival_times[node][customer_class]._sample(t=self.simulation.current_time)

def batch_size(self, nd, clss):
def batch_size(self, node, customer_class):
"""
Samples the batch size for next class and node.
Raises error if a positive integer is not sampled.
"""
batch = self.simulation.batch_sizes[nd][clss]._sample(t=self.simulation.current_time)
batch = self.simulation.batch_sizes[node][customer_class]._sample(t=self.simulation.current_time)
if isinstance(batch, int) and batch >= 0:
return batch
raise ValueError("Batch sizes must be positive integers.")
Expand Down
2 changes: 1 addition & 1 deletion ciw/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def flatten_list(list_of_lists):

def no_routing(ind):
"""
Process-based routing fucntion that sends the customer straight
Process-based routing function that sends the customer straight
to exit node. It is a placeholder for when NoArrivals is used.
"""
return []
14 changes: 7 additions & 7 deletions ciw/deadlock/deadlock_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def action_at_attach_server(self, node, server, individual):

def action_at_blockage(self, individual, next_node):
"""
The action takn at the 'block_individual' method of the node.
The action taken at the 'block_individual' method of the node.
"""
pass

def action_at_detatch_server(self, server):
def action_at_detach_server(self, server):
"""
The action taken at the 'detatch_server' method of the node.
The action taken at the 'detach_server' method of the node.
"""
pass

Expand Down Expand Up @@ -102,7 +102,7 @@ def action_at_attach_server(self, node, server, individual):
The action taken at the 'attach_server' method of the node:
- If new customer joins server, and they're server is still
blocking a customer, then that edge needs to remain.
However it was removed at the action_at_detatch_server, so
However it was removed at the action_at_detach_server, so
it needs to be added back in.
"""
for blq in node.blocked_queue:
Expand All @@ -122,10 +122,10 @@ def action_at_blockage(self, individual, next_node):
for svr in next_node.servers:
self.statedigraph.add_edge(str(individual.server), str(svr))

def action_at_detatch_server(self, server):
def action_at_detach_server(self, server):
"""
The action taken at the 'detatch_server' method of the node:
- Remove any edges of servers who have been detatched.
The action taken at the 'detach_server' method of the node:
- Remove any edges of servers who have been detached.
"""
self.statedigraph.remove_edges_from(
list(self.statedigraph.in_edges(str(server)))
Expand Down
16 changes: 8 additions & 8 deletions ciw/dists/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class Distribution(object):
"""
A general distribution from which all other distirbutions will inherit.
A general distribution from which all other distributions will inherit.
"""
def __repr__(self):
return "Distribution"
Expand All @@ -34,7 +34,7 @@ def sample(self, t=None, ind=None):

def _sample(self, t=None, ind=None):
"""
Performs vaildity checks before sampling.
Performs validity checks before sampling.
"""
s = self.sample(t=t, ind=ind)
if (isinstance(s, float) or isinstance(s, int)) and s >= 0:
Expand Down Expand Up @@ -176,7 +176,7 @@ def __init__(self, lower, upper):
raise ValueError("Uniform distribution must sample positive numbers only.")
if upper < lower:
raise ValueError(
"Uniform distirbution upper bound should be >= lower bound."
"Uniform distribution upper bound should be >= lower bound."
)
self.lower = lower
self.upper = upper
Expand Down Expand Up @@ -692,9 +692,9 @@ class PhaseType(Distribution):
A distribution defined by an initial vector and an absorbing Markov chain

Takes:
- `initial_state` the intial probabilities of being in each state
- `absorbing_matrix` the martix representation of the absorbing Markov
chain, with the final state the absorbing state
- `initial_state` the initial probabilities of being in each state.
- `absorbing_matrix` the matrix representation of the absorbing Markov
chain, with the final state the absorbing state.
"""

def __init__(self, initial_state, absorbing_matrix):
Expand Down Expand Up @@ -910,7 +910,7 @@ def variance(self):

class Coxian(PhaseType):
"""
A shortcut for the Coxian distribuion, using the PhaseType distribution
A shortcut for the Coxian distribution, using the PhaseType distribution

Takes:
- `rates` a vector of rates for each phase
Expand Down Expand Up @@ -1141,7 +1141,7 @@ def __init__(self, n, prob):
)
if not isinstance(n, int) or n <= 0:
raise ValueError(
"The number of trials of the Binomial distirbution must be a positive integer."
"The number of trials of the Binomial distribution must be a positive integer."
)
self.n = n
self.prob = prob
Expand Down
10 changes: 5 additions & 5 deletions ciw/exactnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ExactNode(Node):

This class inherits from the Node class, and
implements a more precise version of addition to
fix discrepencies with floating point numbers.
fix discrepancies with floating point numbers.
"""

@property
Expand Down Expand Up @@ -42,26 +42,26 @@ class ExactArrivalNode(ArrivalNode):
"""Node with exact numerical time precision.

Inherits from the ArrivalNode class, implements a
more precise version of addition to fix discrepencies
more precise version of addition to fix discrepancies
with floating point numbers.
"""

def increment_time(self, original, increment) -> Decimal:
"""Increment the original time by the increment."""
return Decimal(str(original)) + Decimal(str(increment))

def inter_arrival(self, nd, clss) -> Decimal:
def inter_arrival(self, node, clss) -> Decimal:
"""Samples the inter-arrival time for next class and node.

Parameters
----------
nd (Node): Next node.
node (Node): Next node.
clss (Individual): Individual class to be selected next.

"""
return Decimal(
str(
self.simulation.inter_arrival_times[nd][clss]._sample(
self.simulation.inter_arrival_times[node][clss]._sample(
self.simulation.current_time
)
)
Expand Down
38 changes: 19 additions & 19 deletions ciw/import_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ def create_network_from_dictionary(params_input):
class_change_time_distributions[clss1][clss2] = params['class_change_time_distributions'][clss1][clss2]

nodes, classes = [], {}
for nd in range(number_of_nodes):
for node_index in range(number_of_nodes):
nodes.append(
ServiceCentre(
params['number_of_servers'][nd],
params["queue_capacities"][nd],
class_change_matrices[nd],
preempt_priorities[nd],
params["ps_thresholds"][nd],
params["server_priority_functions"][nd],
params["service_disciplines"][nd],
params['number_of_servers'][node_index],
params["queue_capacities"][node_index],
class_change_matrices[node_index],
preempt_priorities[node_index],
params["ps_thresholds"][node_index],
params["server_priority_functions"][node_index],
params["service_disciplines"][node_index],
)
)
for clss_name in params['customer_class_names']:
Expand Down Expand Up @@ -195,17 +195,17 @@ def validify_dictionary(params):
Raises errors if there is something wrong with the
parameters dictionary.
"""
consistant_num_classes = (
consistent_num_classes = (
params["number_of_classes"]
== len(params["arrival_distributions"])
== len(params["service_distributions"])
== len(params["routing"])
== len(params["batching_distributions"])
== len(params["reneging_time_distributions"])
)
if not consistant_num_classes:
raise ValueError("Ensure consistant number of classes is used throughout.")
consistant_class_names = (
if not consistent_num_classes:
raise ValueError("Ensure consistent number of classes is used throughout.")
consistent_class_names = (
set(params["arrival_distributions"])
== set(params["service_distributions"])
== set(params["routing"])
Expand All @@ -217,8 +217,8 @@ def validify_dictionary(params):
== len(params["batching_distributions"])
== len(params["reneging_time_distributions"])
)
if not consistant_class_names:
raise ValueError("Ensure consistant names for customer classes.")
if not consistent_class_names:
raise ValueError("Ensure consistent names for customer classes.")
num_nodes_count = (
[params["number_of_nodes"]]
+ [len(obs) for obs in params["arrival_distributions"].values()]
Expand All @@ -230,7 +230,7 @@ def validify_dictionary(params):
+ [len(params["queue_capacities"])]
)
if len(set(num_nodes_count)) != 1:
raise ValueError("Ensure consistant number of nodes is used throughout.")
raise ValueError("Ensure consistent number of nodes is used throughout.")
neg_numservers = any(
[(isinstance(obs, int) and obs < 0) for obs in params["number_of_servers"]]
)
Expand All @@ -254,13 +254,13 @@ def validify_dictionary(params):
num_nodes = len(params["class_change_matrices"]) == params["number_of_nodes"]
if not num_nodes:
raise ValueError("Ensure correct nodes used in class_change_matrices.")
for nd in params["class_change_matrices"]:
for row in nd.values():
for node in params["class_change_matrices"]:
for row in node.values():
if sum(row.values()) > 1.0 or min(row.values()) < 0.0 or max(row.values()) > 1.0:
raise ValueError("Ensure that class change matrix is valid.")
class_change_names = set([k for matrix in params['class_change_matrices'] for k in matrix.keys()])
if not class_change_names.issubset(set(params['arrival_distributions'])):
raise ValueError("Ensure consistant names for customer classes.")
raise ValueError("Ensure consistent names for customer classes.")

if "class_change_time_distributions" in params:
class_change_from_names = set(list(params['class_change_time_distributions'].keys()))
Expand All @@ -273,7 +273,7 @@ def validify_dictionary(params):
)
if wrong_class_names:
raise ValueError(
"Ensure consistant customer classes used in class_change_time_distributions."
"Ensure consistent customer classes used in class_change_time_distributions."
)

if not isinstance(params['system_capacity'], int) and params['system_capacity'] != float('inf'):
Expand Down
4 changes: 2 additions & 2 deletions ciw/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def __init__(self, service_centres, customer_classes):
set([clss.priority_class for clss in customer_classes.values()])
)
self.priority_class_mapping = {clss: customer_classes[clss].priority_class for clss in customer_classes.keys()}
for nd_id, node in enumerate(self.service_centres):
if all(clss.reneging_time_distributions[nd_id] == None for clss in self.customer_classes.values()):
for node_identifier, node in enumerate(self.service_centres):
if all(clss.reneging_time_distributions[node_identifier] == None for clss in self.customer_classes.values()):
node.reneging = False
else:
node.reneging = True
Expand Down
24 changes: 12 additions & 12 deletions ciw/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ def decide_preempt(self, individual):
)
self.preempt(individual_to_preempt, individual)

def detatch_server(self, server, individual):
def detach_server(self, server, individual):
"""
Detaches a server from an individual, and vice versa.
"""
self.simulation.deadlock_detector.action_at_detatch_server(server)
self.simulation.deadlock_detector.action_at_detach_server(server)
server.cust = False
server.busy = False
individual.server = False
Expand Down Expand Up @@ -515,16 +515,16 @@ def increment_time(self, original, increment):
"""
return original + increment

def kill_server(self, srvr):
def kill_server(self, server):
"""
Kills a server when they go off duty.
"""
srvr.total_time = self.increment_time(self.next_event_date, -srvr.start_date)
self.overtime.append(self.increment_time(self.next_event_date, -srvr.shift_end))
self.all_servers_busy.append(srvr.busy_time)
self.all_servers_total.append(srvr.total_time)
indx = self.servers.index(srvr)
del self.servers[indx]
server.total_time = self.increment_time(self.next_event_date, -server.start_date)
self.overtime.append(self.increment_time(self.next_event_date, -server.shift_end))
self.all_servers_busy.append(server.busy_time)
self.all_servers_total.append(server.total_time)
index = self.servers.index(server)
del self.servers[index]

def next_node(self, ind):
"""
Expand Down Expand Up @@ -558,7 +558,7 @@ def preempt(self, individual_to_preempt, next_individual):
individual_to_preempt.time_left = individual_to_preempt.service_end_date - self.now
individual_to_preempt.service_time = self.priority_preempt
individual_to_preempt.service_end_date = False
self.detatch_server(server, individual_to_preempt)
self.detach_server(server, individual_to_preempt)
self.decide_class_change(individual_to_preempt)
self.attach_server(server, next_individual)
next_individual.service_start_date = self.now
Expand All @@ -573,7 +573,7 @@ def release(self, next_individual, next_node, reroute=False):
- find the individual to release
- remove from queue
- record relevant information to data record
- detatch individual from server
- detach individual from server
- write record
- update state tracker
- begin service of any waiting customers
Expand All @@ -590,7 +590,7 @@ def release(self, next_individual, next_node, reroute=False):
newly_free_server = None
if not isinf(self.c) and not self.slotted:
newly_free_server = next_individual.server
self.detatch_server(newly_free_server, next_individual)
self.detach_server(newly_free_server, next_individual)
if self.slotted:
next_individual.server = False
self.reset_individual_attributes(next_individual)
Expand Down
4 changes: 2 additions & 2 deletions ciw/processor_sharing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def __init__(self, id_, simulation):

def update_all_service_end_dates(self):
"""
For each individual reveiving service, calculates the projected end
service dates if the system state remains contant.
For each individual receiving service, calculates the projected end
service dates if the system state remains constant.
"""
next_occupancy = min(self.number_of_individuals, self.ps_capacity)
inds_in_service = [ind for ind in self.all_individuals if ind.with_server]
Expand Down
Loading
Loading