Skip to content

Commit

Permalink
feat(csv output): add throughput
Browse files Browse the repository at this point in the history
  • Loading branch information
HarukiMoriarty committed Nov 6, 2024
1 parent c3dd035 commit 52ec840
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion calmapf/include/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ struct Log {
void make_step_log(const Instance& ins, const std::string& output_name, const double comp_time_ms, const std::string& map_name, const int seed, const bool log_short = false);
void make_life_long_log(const Instance& ins, std::string visual_name);
void make_throughput_log(uint index, uint* start_cnt, uint make_span);
void make_csv_log(double cache_hit_rate, uint make_span, std::vector<uint>* step_percentiles, bool failure);
void make_csv_log(double cache_hit_rate, uint make_span, std::vector<uint>* step_percentiles, uint ngoals, bool failure);
};
4 changes: 2 additions & 2 deletions calmapf/src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ void Log::make_throughput_log(uint index, uint* start_cnt, uint make_span)
}
}

void Log::make_csv_log(double cache_hit_rate, uint make_span, std::vector<uint>* step_percentiles, bool failure)
void Log::make_csv_log(double cache_hit_rate, uint make_span, std::vector<uint>* step_percentiles, uint ngoals, bool failure)
{
if (!failure) {
csv_output_handler << cache_hit_rate << "," << make_span << "," << (*step_percentiles)[0] << "," << (*step_percentiles)[2] << "," << (*step_percentiles)[6] << std::endl;
csv_output_handler << cache_hit_rate << "," << make_span << "," << (double)ngoals / (double)make_span << "," << (*step_percentiles)[0] << "," << (*step_percentiles)[2] << "," << (*step_percentiles)[6] << std::endl;
}
else {
csv_output_handler << "fail to solve" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int main(int argc, char* argv[])

// Failure
if (solution.empty()) {
log.make_csv_log(.0, 0, nullptr, true);
log.make_csv_log(.0, 0, nullptr, parser.num_goals, true);
console->error("failed to solve");
return 1;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ int main(int argc, char* argv[])
}

log.make_life_long_log(ins, parser.output_visual_file);
log.make_csv_log(total_cache_rate, makespan, &step_percentiles, false);
log.make_csv_log(total_cache_rate, makespan, &step_percentiles, parser.num_goals, false);

return 0;
}
2 changes: 1 addition & 1 deletion tools/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def check_and_create_csv(output_csv_path: str):
csv_path.parent.mkdir(parents=True, exist_ok=True)
# Create the file and write the header
with open(csv_path, 'w') as csv_file:
csv_file.write("map_name,cache,look_ahead,delay_deadline,goal_generation_type,ngoals,nagents,seed,verbose,time_limit_sec,goals_m,goals_k,cache_hit_rate,makespan,p0_steps,p50_steps,p99steps\n")
csv_file.write("map_name,cache,look_ahead,delay_deadline,goal_generation_type,ngoals,nagents,seed,verbose,time_limit_sec,goals_m,goals_k,cache_hit_rate,makespan,throughput,p0_steps,p50_steps,p99steps\n")

def check_and_create_throughput(output_throughput_path: str):
# Convert string path to Path object for easier handling
Expand Down

0 comments on commit 52ec840

Please sign in to comment.