MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / Statistics

Class Statistics

PythonAPI/examples/gamma_crowd.py:630–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

628 self.bike_blueprints = [x for x in self.vehicle_blueprints if int(x.get_attribute('number_of_wheels')) == 2]
629
630class Statistics(object):
631 def __init__(self, log_file):
632 self.start_time = None
633
634 self.total_num_cars = 0
635 self.total_num_bikes = 0
636 self.total_num_pedestrians = 0
637
638 self.stuck_num_cars = 0
639 self.stuck_num_bikes = 0
640 self.stuck_num_pedestrians = 0
641
642 self.avg_speed_cars = 0
643 self.avg_speed_bikes = 0
644 self.avg_speed_pedestrians = 0
645
646 self.log_file = log_file
647
648 def write(self):
649 self.log_file.write('{} {} {} {} {} {} {} {} {} {}\n'.format(
650 time.time() - self.start_time,
651 self.total_num_cars,
652 self.total_num_bikes,
653 self.total_num_pedestrians,
654 self.stuck_num_cars,
655 self.stuck_num_bikes,
656 self.stuck_num_pedestrians,
657 self.avg_speed_cars,
658 self.avg_speed_bikes,
659 self.avg_speed_pedestrians))
660 self.log_file.flush()
661 os.fsync(self.log_file)
662
663
664''' ========== MAIN LOGIC FUNCTIONS ========== '''

Callers 1

gamma_loopFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected