22from random import random
33import os
44from csv import writer
5+ from math import isinf
56
67import networkx as nx
78
@@ -121,7 +122,7 @@ def begin_service_if_possible_accept(self,
121122 next_individual .service_start_date = self .get_now (current_time )
122123 next_individual .service_end_date = self .increment_time (
123124 current_time , next_individual .service_time )
124- if self .c < float ( 'Inf' ):
125+ if not isinf ( self .c ):
125126 self .attach_server (self .find_free_server (),
126127 next_individual )
127128
@@ -159,7 +160,7 @@ def begin_service_if_possible_release(self, current_time):
159160 Begins the service of the next individual, giving
160161 that customer a service time, end date and node.
161162 """
162- if self .free_server () and self .c != float ( 'Inf' ):
163+ if self .free_server () and ( not isinf ( self .c ) ):
163164 srvr = self .find_free_server ()
164165 if len (self .interrupted_individuals ) > 0 :
165166 self .begin_interrupted_individuals_service (current_time , srvr )
@@ -252,7 +253,7 @@ def free_server(self):
252253 """
253254 Returns True if a server is available, False otherwise
254255 """
255- if self .c == float ( 'Inf' ):
256+ if isinf ( self .c ):
256257 return True
257258 return len ([svr for svr in self .servers if not svr .busy ]) > 0
258259
@@ -280,7 +281,7 @@ def find_server_utilisation(self):
280281 """
281282 Finds the overall server utilisation for the node
282283 """
283- if self .c == float ( 'Inf' ) or self .c == 0 :
284+ if isinf ( self .c ) or self .c == 0 :
284285 self .server_utilisation = None
285286 else :
286287 for server in self .servers :
@@ -296,7 +297,7 @@ def finish_service(self):
296297 self .change_customer_class (next_individual )
297298 next_node = self .next_node (next_individual .customer_class )
298299 next_individual .destination = next_node .id_number
299- if self .c < float ( 'Inf' ):
300+ if not isinf ( self .c ):
300301 next_individual .server .next_end_service_date = float ('Inf' )
301302 if next_node .number_of_individuals < next_node .node_capacity :
302303 self .release (next_individual_index , next_node ,
@@ -354,7 +355,7 @@ def release(self, next_individual_index, next_node, current_time):
354355 self .number_of_individuals -= 1
355356 next_individual .queue_size_at_departure = self .number_of_individuals
356357 next_individual .exit_date = current_time
357- if self .c < float ( 'Inf' ):
358+ if not isinf ( self .c ):
358359 self .detatch_server (next_individual .server , next_individual )
359360 self .write_individual_record (next_individual )
360361 self .simulation .statetracker .change_state_release (self .id_number ,
@@ -419,7 +420,7 @@ def update_next_event_date(self, current_time):
419420 """
420421 Finds the time of the next event at this node
421422 """
422- if self .c != float ( 'Inf' ):
423+ if not isinf ( self .c ):
423424 next_end_service = min ([s .next_end_service_date
424425 for s in self .servers ] + [float ("Inf" )])
425426 else :
@@ -439,7 +440,7 @@ def wrap_up_servers(self, current_time):
439440 Updates the servers' total_time and busy_time
440441 as the end of the simulation run.
441442 """
442- if self .c != float ( 'Inf' ):
443+ if not isinf ( self .c ):
443444 for srvr in self .servers :
444445 srvr .total_time = self .increment_time (current_time , - srvr .start_date )
445446 if srvr .busy :
0 commit comments