feat(libmeanfield): centrifugal + pressure
This commit is contained in:
65
experiments/experiment_results.cppm
Normal file
65
experiments/experiment_results.cppm
Normal file
@@ -0,0 +1,65 @@
|
||||
module;
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
export module experiment;
|
||||
|
||||
export namespace experiment {
|
||||
struct ExperimentResult {
|
||||
std::string experiment_name;
|
||||
std::string case_name;
|
||||
std::map<std::string, std::string> parameters;
|
||||
std::map<std::string, double> metrics;
|
||||
};
|
||||
|
||||
class ExperimentRegistry {
|
||||
public:
|
||||
static ExperimentRegistry& instance() {
|
||||
static ExperimentRegistry registry;
|
||||
return registry;
|
||||
}
|
||||
|
||||
void add_result(ExperimentResult result) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_results.push_back(std::move(result));
|
||||
}
|
||||
|
||||
[[nodiscard]] std::vector<ExperimentResult> results() const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
return m_results;
|
||||
}
|
||||
|
||||
void set_output_path(std::string output_path) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_output_path = std::move(output_path);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string output_path() const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
return m_output_path;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::mutex m_mutex;
|
||||
std::vector<ExperimentResult> m_results;
|
||||
std::string m_output_path{"accuracy_budget.csv"};
|
||||
};
|
||||
|
||||
inline void record_experiment_result(
|
||||
const std::string& experiment_name,
|
||||
const std::string& case_name,
|
||||
std::map<std::string, std::string> parameters,
|
||||
std::map<std::string, double> metrics
|
||||
) {
|
||||
ExperimentRegistry::instance().add_result({
|
||||
.experiment_name = experiment_name,
|
||||
.case_name = case_name,
|
||||
.parameters = std::move(parameters),
|
||||
.metrics = std::move(metrics)
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user