Commit 75c4f41b authored by Ahmad Reza Cheraghi's avatar Ahmad Reza Cheraghi
Browse files

Replace csv_generator.py

parent da317ed0
......@@ -19,12 +19,17 @@ class CsvParticleFile:
csv_file = open(directory + '/particle.csv', 'w', newline='')
self.writer_particle = csv.writer(csv_file)
self.writer_particle.writerow(['Particle ID',
'Location Created', 'Location Deleted', 'Location Read', 'Location Write',
'Memory Read', 'Memory Write',
'Particles Created', 'Particles Deleted', 'Particles Dropped',
'Particle Read', 'Particle Steps', 'Particles Taken', 'Particle Write',
'Tiles Created', 'Tiles Deleted', 'Tiles Dropped',
'Tile Read', 'Tiles Taken', 'Tile Write'
'Location Created', 'Location Deleted',
'Location Read', 'Location Write',
'Memory Read', 'Memory Write',
'Particles Created', 'Particles Deleted',
'Particles Dropped',
'Particle Read', 'Particle Steps',
'Particles Taken', 'Particle Write',
'Tiles Created', 'Tiles Deleted',
'Tiles Dropped',
'Tile Read', 'Tiles Taken',
'Tile Write'
])
......@@ -33,7 +38,6 @@ class CsvParticleData:
self.id = particle_id
self.writer = writer
self.steps = 0
self.round_success=0
self.particle_created=0
self.particle_deleted=0
self.particles_dropped = 0
......@@ -136,6 +140,8 @@ class CsvRoundData:
self.location_deleted_sum = 0
self.memory_read_sum = 0
self.memory_write_sum = 0
self.success_round = None
self.success_counter = 0
self.tiles_taken = 0
self.tiles_dropped = 0
self.tiles_taken_sum = 0
......@@ -144,22 +150,31 @@ class CsvRoundData:
self.file_name = directory + '/rounds.csv'
self.csv_file = open(self.file_name, 'w', newline='')
self.writer_round = csv.writer(self.csv_file)
self.writer_round.writerow(['','Round Number', 'Round Success', 'Seed','Solution','Task',
self.writer_round.writerow(['',
'Round Number', 'Seed','Scenario',
'Location Counter',
'Location Created', 'Location Created Sum',
'Location Deleted', 'Location Deleted Sum','Location Read', 'Location Read Sum',
'Location Deleted', 'Location Deleted Sum',
'Location Read', 'Location Read Sum',
'Location Write', 'Location Write Sum',
'Memory Read', 'Memory Read Sum', 'Memory Write', 'Memory Write Sum',
'Memory Read', 'Memory Read Sum',
'Memory Write', 'Memory Write Sum',
'Particle Counter',
'Particles Created', 'Particles Created Sum',
'Particles Deleted', 'Particles Deleted Sum',
'Particles Dropped', 'Particles Dropped Sum',
'Particle Read', 'Particle Read Sum', 'Particle Steps', 'Particle Steps Sum',
'Particles Taken', 'Particles Taken Sum', 'Particle Write', 'Particle Write Sum',
'Particle Read', 'Particle Read Sum',
'Particle Steps', 'Particle Steps Sum',
'Particles Taken', 'Particles Taken Sum',
'Particle Write', 'Particle Write Sum',
'Success Counter', 'Success Round',
'Tile Counter',
'Tiles Created', 'Tiles Created Sum', 'Tiles Deleted', 'Tiles Deleted Sum',
'Tiles Dropped', 'Tiles Dropped Sum', 'Tile Read', 'Tile Read Sum',
'Tiles Taken', 'Tiles Taken Sum', 'Tile Write', 'Tile Write Sum',
'Tiles Created', 'Tiles Created Sum',
'Tiles Deleted', 'Tiles Deleted Sum',
'Tiles Dropped', 'Tiles Dropped Sum',
'Tile Read', 'Tile Read Sum',
'Tiles Taken', 'Tiles Taken Sum',
'Tile Write', 'Tile Write Sum',
])
def update_particle_num (self, particle):
......@@ -171,8 +186,9 @@ class CsvRoundData:
def update_locations_num(self, act_locations_num):
self.locations_num = act_locations_num
def round_success(self):
self.round_success=1
def success(self, actual_round):
self.success_round=actual_round
self.success_counter=self.success_counter+1
def update_metrics(self, rounds, steps = 0,
particle_read = 0, tile_read = 0, location_read = 0, memory_read = 0,
......@@ -245,7 +261,7 @@ class CsvRoundData:
logging.debug("CSV: Ending writing_rounds")
def next_line(self, round):
csv_iterator = ['',round, self.round_success, self.seed, self.solution, self.task,
csv_iterator = ['',round, self.seed, self.solution,
self.locations_num, self.location_created, self.location_created_sum,
self.location_deleted, self.location_deleted_sum,
self.location_read, self.location_read_sum,
......@@ -258,6 +274,7 @@ class CsvRoundData:
self.steps, self.steps_sum,
self.particles_taken, self.particles_taken_sum,
self.particle_write, self.particle_write_sum,
self.success_counter, self.success_round,
self.tile_num, self.tile_created, self.tile_created_sum,
self.tile_deleted, self.tile_deleted_sum, self.tiles_dropped, self.tiles_dropped_sum,
self.tile_read, self.tile_read_sum, self.tiles_taken, self.tiles_taken_sum,
......@@ -281,17 +298,19 @@ class CsvRoundData:
self.location_deleted = 0
self.tiles_dropped = 0
self.tiles_taken = 0
self.round_success = 0
self.success_round = None
self.success_counter = 0
self.particles_taken = 0
self.particles_dropped = 0
def aggregate_metrics(self):
self.csv_file.close()
data = pd.DataFrame.from_csv(self.file_name)
data = pd.read_csv(self.file_name)
file_name = self.directory+"/aggregate_rounds.csv"
csv_file = open(file_name, 'w', newline='')
writer_round = csv.writer(csv_file)
writer_round.writerow(['Seed', 'Rounds Total', 'Solution', 'Task',
writer_round.writerow(['Seed', 'Rounds Total',
'Scenario',
'Location Counter',
'Location Created Sum', 'Location Created Avg',
'Location Created Min', 'Location Created Max',
......@@ -314,6 +333,8 @@ class CsvRoundData:
'Particle Write Sum', 'Particle Write Avg', 'Particle Write Min', 'Particle Write Max',
'Memory Read Sum', 'Memory Read Avg', 'Memory Read Min', 'Memory Read Max',
'Memory Write Sum', 'Memory Write Avg', 'Memory Write Min', 'Memory Write Max',
'Success Rate Sum', 'Success Rate Avg', 'Success Rate Min', 'Success Rate Max',
'Success Round Min', 'Success Round Max',
'Tile Counter',
'Tiles Created Sum', 'Tiles Created Avg', 'Tiles Created Min', 'Tiles Created Max',
'Tiles Deleted Sum', 'Tiles Deleted Avg', 'Tiles Deleted Min', 'Tiles Deleted Max',
......@@ -322,7 +343,9 @@ class CsvRoundData:
'Tiles Taken Sum', 'Tiles Taken Avg', 'Tiles Taken Min', 'Tiles Taken Max',
'Tile Write Sum', 'Tile Write Avg', 'Tile Write Min', 'Tile Write Max'])
csv_interator = [self.seed, data['Round Number'].count(), self.solution, self.task,
csv_interator = [self.seed, data['Round Number'].count(),
self.solution,
self.locations_num,
data['Location Created'].sum(), data['Location Created'].mean(),
......@@ -365,6 +388,12 @@ class CsvRoundData:
data['Memory Write'].sum(), data['Memory Write'].mean(), data['Memory Write'].min(),
data['Memory Write'].max(),
data['Success Counter'].sum(), data['Success Counter'].mean(), data['Success Counter'].min(),
data['Success Counter'].max(),
data['Success Round'].min() ,
data['Success Round'].max(),
self.tile_num,
data['Tiles Created'].sum(), data['Tiles Created'].mean(), data['Tiles Created'].min(),
data['Tiles Created'].max(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment