LotSizingDataModel.Instance 2.0.1
Lot-sizing instance representation, descriptors and problem characterization.
Loading...
Searching...
No Matches
BenchmarkRunProvenance.cs
Go to the documentation of this file.
2
3/// <summary>
4/// Reproducibility metadata for one benchmark run.
5/// </summary>
6public sealed class BenchmarkRunProvenance
7{
9 string formulationId,
10 string methodId,
11 string methodVersion,
12 string backendId,
13 string backendVersion,
14 bool isStochastic,
15 ulong? seed,
16 IReadOnlyDictionary<string, string>? parameters = null)
17 {
19 NormalizeRequired(
20 formulationId,
21 nameof(formulationId));
22
23 MethodId =
24 NormalizeRequired(
25 methodId,
26 nameof(methodId));
27
29 NormalizeRequired(
30 methodVersion,
31 nameof(methodVersion));
32
33 BackendId =
34 NormalizeRequired(
35 backendId,
36 nameof(backendId));
37
39 NormalizeRequired(
40 backendVersion,
41 nameof(backendVersion));
42
44 isStochastic;
45
46 Seed =
47 seed;
48
49 var normalizedParameters =
50 new SortedDictionary<string, string>(
51 StringComparer.Ordinal);
52
53 if (parameters is not null)
54 {
55 foreach (KeyValuePair<string, string> pair
56 in parameters)
57 {
58 string key =
59 NormalizeRequired(
60 pair.Key,
61 nameof(parameters));
62
63 normalizedParameters.Add(
64 key,
65 pair.Value?.Trim() ??
66 string.Empty);
67 }
68 }
69
71 normalizedParameters;
72
74 }
75
76 public string FormulationId
77 {
78 get;
79 }
80
81 public string MethodId
82 {
83 get;
84 }
85
86 public string MethodVersion
87 {
88 get;
89 }
90
91 public string BackendId
92 {
93 get;
94 }
95
96 public string BackendVersion
97 {
98 get;
99 }
100
101 public bool IsStochastic
102 {
103 get;
104 }
105
106 public ulong? Seed
107 {
108 get;
109 }
110
111 public IReadOnlyDictionary<string, string> Parameters
112 {
113 get;
114 }
115
116 public void EnsureValid()
117 {
118 if (IsStochastic &&
119 !Seed.HasValue)
120 {
121 throw new InvalidOperationException(
122 "A stochastic benchmark run requires an explicit seed.");
123 }
124 }
125
126 private static string NormalizeRequired(
127 string? value,
128 string parameterName)
129 {
130 string normalized =
131 value?.Trim() ??
132 string.Empty;
133
134 if (normalized.Length == 0)
135 {
136 throw new ArgumentException(
137 "A non-empty benchmark provenance value is required.",
138 parameterName);
139 }
140
141 return normalized;
142 }
143}
BenchmarkRunProvenance(string formulationId, string methodId, string methodVersion, string backendId, string backendVersion, bool isStochastic, ulong? seed, IReadOnlyDictionary< string, string >? parameters=null)