Player12
An open source football management simulator
Loading...
Searching...
No Matches
lab_report.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <cstdint>
12#include <map>
13#include <nlohmann/json.hpp>
14#include <optional>
15#include <span>
16#include <string>
17#include <string_view>
18#include <vector>
19
20#include "tools/lab_stats.h"
21
27namespace Lab
28{
29enum class Tier : std::uint8_t
30{
31 Gate,
32 Monitor,
33 Info
34};
35
37enum class Scope : std::uint8_t
38{
39 Match,
40 Engine,
41 World,
42 Tactics
43};
44
46enum class Unit : std::uint8_t
47{
48 Number,
50};
51
59{
60 std::string_view id;
61 std::string_view metric;
62 std::string_view label;
63 std::string_view target;
64 std::optional<Band> band;
66 std::string_view source;
69 std::string_view note;
70};
71
73std::span<const TargetSpec> targetTable();
74
77{
78 std::string id;
79 std::string metric;
80 std::string label;
81 std::string target;
82 std::optional<Band> band;
84 std::string source;
86 std::string note;
89
90 bool operator==(const ReportRow&) const = default;
91};
92
95{
96 std::string title;
97 std::vector<std::string> header;
98 std::vector<std::vector<std::string>> rows;
99
100 bool operator==(const TextTable&) const = default;
101};
102
104{
105 int gate_pass = 0;
106 int gate_warn = 0;
107 int gate_fail = 0;
112 double monitorPassRate() const;
113};
114
116namespace ExitCode
117{
118inline constexpr int OK = 0;
119inline constexpr int GATE_FAILED = 1;
120inline constexpr int MONITOR_BELOW_THRESHOLD = 2;
121inline constexpr int INVALID_ARGUMENTS = 3;
122inline constexpr int SIMULATION_ERROR = 4;
123} // namespace ExitCode
124
126inline constexpr double MONITOR_PASS_THRESHOLD = 0.9;
127
129{
130 static constexpr int SCHEMA_VERSION = 1;
131
132 std::string mode;
133 std::uint64_t seed = 0;
135 std::size_t samples = 0;
136 unsigned threads = 1;
137 double wall_seconds = 0.0;
138 double ms_per_match = 0.0;
139 double seconds_per_season = 0.0;
141 std::map<std::string, std::string> parameters;
142 std::vector<ReportRow> rows;
143 std::vector<TextTable> tables;
145 std::vector<std::string> notes;
146
147 Summary summary() const;
148 int exitCode() const;
149 bool operator==(const LabReport&) const = default;
150};
151
157std::vector<ReportRow> evaluateTargets(
158 const std::map<std::string, Estimate>& metrics,
159 std::span<const Scope> scopes);
160
161std::string_view verdictName(Verdict verdict);
162std::string_view tierName(Tier tier);
163
165std::string formatValue(double value, Unit unit);
166
167nlohmann::json toJson(const LabReport& report);
169LabReport reportFromJson(const nlohmann::json& json);
170std::string toMarkdown(const LabReport& report);
171} // namespace Lab
nlohmann::json json
Definition datagenerator.cpp:38
constexpr int INVALID_ARGUMENTS
Definition lab_report.h:121
constexpr int SIMULATION_ERROR
Definition lab_report.h:122
constexpr int OK
Definition lab_report.h:118
constexpr int GATE_FAILED
Definition lab_report.h:119
constexpr int MONITOR_BELOW_THRESHOLD
Definition lab_report.h:120
Definition lab_fixtures.cpp:22
Verdict
Definition lab_stats.h:47
std::string_view verdictName(Verdict verdict)
Definition lab_report.cpp:370
Scope
Definition lab_report.h:38
nlohmann::json toJson(const LabReport &report)
Definition lab_report.cpp:391
Unit
Definition lab_report.h:47
constexpr double MONITOR_PASS_THRESHOLD
Definition lab_report.h:126
std::string toMarkdown(const LabReport &report)
Definition lab_report.cpp:490
Tier
Definition lab_report.h:30
std::string formatValue(double value, Unit unit)
Definition lab_report.cpp:380
std::span< const TargetSpec > targetTable()
Definition lab_report.cpp:292
LabReport reportFromJson(const nlohmann::json &json)
Definition lab_report.cpp:440
std::string_view tierName(Tier tier)
Definition lab_report.cpp:375
std::vector< ReportRow > evaluateTargets(const std::map< std::string, Estimate > &metrics, std::span< const Scope > scopes)
Definition lab_report.cpp:336
Roles, duties, in-possession shapes and their engine profiles. Pure functions; the tactic data itself...
Definition tactics.cpp:166
Definition lab_stats.h:27
Definition lab_report.h:129
bool operator==(const LabReport &) const =default
double seconds_per_season
Definition lab_report.h:139
int exitCode() const
Definition lab_report.cpp:327
static constexpr int SCHEMA_VERSION
Definition lab_report.h:130
double wall_seconds
Definition lab_report.h:137
std::vector< TextTable > tables
Definition lab_report.h:143
std::vector< std::string > notes
Definition lab_report.h:145
std::vector< ReportRow > rows
Definition lab_report.h:142
unsigned threads
Definition lab_report.h:136
std::map< std::string, std::string > parameters
Definition lab_report.h:141
double ms_per_match
Definition lab_report.h:138
Summary summary() const
Definition lab_report.cpp:301
std::string mode
Definition lab_report.h:132
std::size_t samples
Definition lab_report.h:135
std::uint64_t seed
Definition lab_report.h:133
Definition lab_report.h:77
Unit unit
Definition lab_report.h:85
std::string label
Definition lab_report.h:80
Verdict verdict
Definition lab_report.h:88
std::string target
Definition lab_report.h:81
std::string id
Definition lab_report.h:78
bool operator==(const ReportRow &) const =default
Tier tier
Definition lab_report.h:83
std::string metric
Definition lab_report.h:79
std::optional< Band > band
Definition lab_report.h:82
std::string note
Definition lab_report.h:86
Estimate estimate
Definition lab_report.h:87
std::string source
Definition lab_report.h:84
Definition lab_report.h:104
int gate_pass
Definition lab_report.h:105
int monitor_pass
Definition lab_report.h:108
int gate_warn
Definition lab_report.h:106
int monitor_evaluated
Definition lab_report.h:109
int gate_fail
Definition lab_report.h:107
int not_measured
Definition lab_report.h:110
double monitorPassRate() const
Definition lab_report.cpp:294
Definition lab_report.h:59
std::string_view id
Definition lab_report.h:60
std::optional< Band > band
Definition lab_report.h:64
std::string_view metric
Definition lab_report.h:61
Unit unit
Definition lab_report.h:67
std::string_view note
Definition lab_report.h:69
std::string_view source
Definition lab_report.h:66
Tier tier
Definition lab_report.h:65
std::string_view target
Definition lab_report.h:63
std::string_view label
Definition lab_report.h:62
Scope scope
Definition lab_report.h:68
Definition lab_report.h:95
std::vector< std::vector< std::string > > rows
Definition lab_report.h:98
bool operator==(const TextTable &) const =default
std::vector< std::string > header
Definition lab_report.h:97
std::string title
Definition lab_report.h:96