Coverage for moptipy / api / logging.py: 100%
87 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-29 10:36 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-29 10:36 +0000
1"""Shared constants and functions for dealing with logs."""
3from typing import Final
5#: the file suffix to be used for log files
6FILE_SUFFIX: Final[str] = ".txt"
8#: the key for the exception type
9KEY_EXCEPTION_TYPE: Final[str] = "exceptionType"
10#: the key for the exception value
11KEY_EXCEPTION_VALUE: Final[str] = "exceptionValue"
12#: the key for the exception stack trace
13KEY_EXCEPTION_STACK_TRACE: Final[str] = "exceptionStackTrace"
15#: the key for algorithms
16KEY_ALGORITHM: Final[str] = "algorithm"
17#: the key for the instance
18KEY_INSTANCE: Final[str] = "instance"
20#: the common name prefix of all error sections
21ERROR_SECTION_PREFIX: Final[str] = "ERROR_"
22#: the section indicating an error during the algorithm run
23SECTION_ERROR_IN_RUN: Final[str] = f"{ERROR_SECTION_PREFIX}IN_RUN"
24#: the section indicating an error that occurred in the context of the
25#: process. this may be an error in the algorithm or, more likely, in the
26#: processing of the result.
27SECTION_ERROR_IN_CONTEXT: Final[str] = f"{ERROR_SECTION_PREFIX}IN_CONTEXT"
28#: the section indicating an invalid candidate solution
29SECTION_ERROR_INVALID_Y: Final[str] = f"{ERROR_SECTION_PREFIX}INVALID_Y"
30#: the section indicating a mismatch of the computed and registered best f
31SECTION_ERROR_BEST_F: Final[str] = f"{ERROR_SECTION_PREFIX}BEST_F_MISMATCH"
32#: the section indicating an invalid point in the search space
33SECTION_ERROR_INVALID_X: Final[str] = f"{ERROR_SECTION_PREFIX}INVALID_X"
34#: the section indicating that the time measurement has an error
35SECTION_ERROR_TIMING: Final[str] = f"{ERROR_SECTION_PREFIX}TIMING"
36#: the section indicating an error caught during log writing
37SECTION_ERROR_IN_LOG: Final[str] = f"{ERROR_SECTION_PREFIX}IN_LOG"
39#: the progress csv section
40SECTION_PROGRESS: Final[str] = "PROGRESS"
41#: the FEs column for the progress CSV
42PROGRESS_FES: Final[str] = "fes"
43#: the time millis column for the progress CSV
44PROGRESS_TIME_MILLIS: Final[str] = "timeMS"
45#: the current objective value column for the progress CSV
46PROGRESS_CURRENT_F: Final[str] = "f"
48#: the end state
49SECTION_FINAL_STATE: Final[str] = "STATE"
50#: the total number of consumed FEs
51KEY_TOTAL_FES: Final[str] = "totalFEs"
52#: the total number of consumed milliseconds
53KEY_TOTAL_TIME_MILLIS: Final[str] = "totalTimeMillis"
54#: the best encountered objective value
55KEY_BEST_F: Final[str] = "bestF"
56#: the vector of objective values of the best solution
57KEY_BEST_FS: Final[str] = "bestFs"
58#: the number of archived non-dominated solutions
59KEY_ARCHIVE_SIZE: Final[str] = "archiveSize"
60#: the FE when the best objective value was reached
61KEY_LAST_IMPROVEMENT_FE: Final[str] = "lastImprovementFE"
62#: the time in milliseconds when the best objective value was reached
63KEY_LAST_IMPROVEMENT_TIME_MILLIS: Final[str] = "lastImprovementTimeMillis"
64#: the current objective value
65KEY_CURRENT_F: Final[str] = "currentF"
66#: the current objective value vector
67KEY_CURRENT_FS: Final[str] = "currentFs"
69#: the archive section prefix
70PREFIX_SECTION_ARCHIVE: Final[str] = "ARCHIVE_"
71#: the archive quality section suffix
72SECTION_ARCHIVE_QUALITY: Final[str] = f"{PREFIX_SECTION_ARCHIVE}QUALITIES"
73#: the scalarized objective value column of the archive if without numeric
74#: suffix, the result of the ith objective function if with numeric suffix
75KEY_ARCHIVE_F: Final[str] = PROGRESS_CURRENT_F
77#: the archive X section suffix
78SUFFIX_SECTION_ARCHIVE_X: Final[str] = "_X"
79#: the archive Y section suffix
80SUFFIX_SECTION_ARCHIVE_Y: Final[str] = "_Y"
82#: the setup section
83SECTION_SETUP: Final[str] = "SETUP"
84#: the default log key for names of objects
85KEY_NAME: Final[str] = "name"
86#: the class of an object
87KEY_CLASS: Final[str] = "class"
88#: the inner class of an object
89KEY_INNER_CLASS: Final[str] = "innerClass"
90#: the default log key for the lower bound of objective function values
91KEY_F_LOWER_BOUND: Final[str] = "lowerBound"
92#: the default log key for the upper bound of objective function values
93KEY_F_UPPER_BOUND: Final[str] = "upperBound"
94#: the maximum FEs of a black-box process
95KEY_MAX_FES: Final[str] = "maxFEs"
96#: the maximum runtime in milliseconds of a black-box process
97KEY_MAX_TIME_MILLIS: Final[str] = "maxTimeMillis"
98#: the goal objective value of a black-box process
99KEY_GOAL_F: Final[str] = "goalF"
100#: the random seed
101KEY_RAND_SEED: Final[str] = "randSeed"
102#: the random generator type
103KEY_RAND_GENERATOR_TYPE: Final[str] = "randGenType"
104#: the type of the bit generator used by the random generator
105KEY_RAND_BIT_GENERATOR_TYPE: Final[str] = "randBitGenType"
106#: the number of decision variables
107KEY_SPACE_NUM_VARS: Final[str] = "nvars"
108#: the maximum archive size (after pruning)
109KEY_ARCHIVE_MAX_SIZE: Final[str] = "archiveMaxSize"
110#: the pruning limit of the archive size
111KEY_ARCHIVE_PRUNE_LIMIT: Final[str] = "archivePruneLimit"
113#: the scope of the process parameters
114SCOPE_PROCESS: Final[str] = "p"
115#: the scope of the solution space
116SCOPE_SOLUTION_SPACE: Final[str] = "y"
117#: the scope of the search space
118SCOPE_SEARCH_SPACE: Final[str] = "x"
119#: the scope of the objective function
120SCOPE_OBJECTIVE_FUNCTION: Final[str] = "f"
121#: the scope of the encoding
122SCOPE_ENCODING: Final[str] = "g"
123#: the scope of the optimization algorithm
124SCOPE_ALGORITHM: Final[str] = "a"
125#: the scope of the multi-objective archive pruner
126SCOPE_PRUNER: Final[str] = "ap"
127#: the scope of the nullary search operator
128SCOPE_OP0: Final[str] = "op0"
129#: the scope of the unary search operator
130SCOPE_OP1: Final[str] = "op1"
131#: the scope of the binary search operator
132SCOPE_OP2: Final[str] = "op2"
134#: the automatically generated system info section
135SECTION_SYS_INFO: Final[str] = "SYS_INFO"
136#: information about the current session
137SCOPE_SESSION: Final[str] = "session"
138#: the time when the session was started
139KEY_SESSION_START: Final[str] = "start"
140#: the node on which the session is running
141KEY_NODE_NAME: Final[str] = "node"
142#: the affinity of the process to logical CPUs
143KEY_CPU_AFFINITY: Final[str] = "cpuAffinity"
144#: the pid of the process
145KEY_PROCESS_ID: Final[str] = "processId"
146#: the command line of the process
147KEY_COMMAND_LINE: Final[str] = "commandLine"
148#: the working directory of the process
149KEY_WORKING_DIRECTORY: Final[str] = "workingDirectory"
150#: the ip address of the node on which the session is running
151KEY_NODE_IP: Final[str] = "ipAddress"
152#: the versions scope in the sys-info section
153SCOPE_VERSIONS: Final[str] = "version"
154#: the hardware scope in the sys-info section
155SCOPE_HARDWARE: Final[str] = "hardware"
156#: the number of physical CPUs
157KEY_HW_N_PHYSICAL_CPUS: Final[str] = "nPhysicalCpus"
158#: the number of logical CPUs
159KEY_HW_N_LOGICAL_CPUS: Final[str] = "nLogicalCpus"
160#: the clock speed of the CPUs
161KEY_HW_CPU_MHZ: Final[str] = "cpuMhz"
162#: the key for the byte order
163KEY_HW_BYTE_ORDER: Final[str] = "byteOrder"
164#: the key for the machine
165KEY_HW_MACHINE: Final[str] = "machine"
166#: the key for the cpu name
167KEY_HW_CPU_NAME: Final[str] = "cpu"
168#: the key for the memory size
169KEY_HW_MEM_SIZE: Final[str] = "memSize"
170#: the operating system in the sys-info section
171SCOPE_OS: Final[str] = "os"
172#: the operating system name
173KEY_OS_NAME: Final[str] = "name"
174#: the operating system version
175KEY_OS_VERSION: Final[str] = "version"
176#: the operating system release
177KEY_OS_RELEASE: Final[str] = "release"
178#: the python scope in the sys-info section
179SCOPE_PYTHON: Final[str] = "python"
180#: the python version
181KEY_PYTHON_VERSION: Final[str] = "version"
182#: the python implementation
183KEY_PYTHON_IMPLEMENTATION: Final[str] = "implementation"
185#: the resulting point in the solution space
186SECTION_RESULT_Y: Final[str] = "RESULT_Y"
187#: the resulting point in the search space
188SECTION_RESULT_X: Final[str] = "RESULT_X"
190#: all the section titles combined in one set
191# noinspection PyDefaultArgument
192# pylint: disable=[C3002]
193_ALL_SECTIONS: Final[set[str]] = (lambda g=globals(): { # type: ignore # noqa
194 g[k] for k in g if k.startswith("SECTION_")})() # type: ignore