@File : _base_generator.py @Time : 2026/03/25 11:22:20 @Author : Alejandro Marrero (amarrerd@ull.edu.es) @Version : 1.0 @Contact : amarrerd@ull.edu.es @License : (C)Copyright 2026, Alejandro Marrero @Desc : None
BaseGenerator
Bases: ABC
Abstract base class for all Quality-Diversity generators.
BaseGenerator factors out the logic that is common to every concrete
Quality-Diversity (QD) instance generator in Digneapy, so that subclasses
only need to implement the specific evolutionary loop in __call__.
Handles:
- Common evaluation pipeline: running a portfolio of solvers over a
population of generated instances and aggregating their scores.
- Descriptor computation: delegated to a configurable
DescriptorPipeline used to characterise instances for diversity
purposes.
- Result formatting: concrete generators are expected to package their
output as a :class:GenerationResult.
- Statistics tracking: via the internal Logbook, which records the
generator's progress across generations.
Subclasses must implement :meth:__call__, which performs the actual
generation process and returns a :class:GenerationResult.
Source code in digneapy/generators/_base_generator.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
descriptor_pipeline
property
Return the descriptor pipeline used to characterise instances.
The pipeline is responsible for computing the descriptors used to assess diversity between instances (e.g. feature-based descriptors).
| Returns: |
|
|---|
log
property
Return the Logbook tracking this generator's evolutionary history.
| Returns: |
|
|---|
__call__(verbose=False)
abstractmethod
Run the generator and produce a new set of instances.
This is the main entry point of any concrete generator and must be
implemented by subclasses. Implementations are expected to drive the
evolutionary process for self._generations generations, evaluate
candidate instances via :meth:_evaluate_population, update
self._logbook with progress information, and package the final
result as a :class:GenerationResult.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in digneapy/generators/_base_generator.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
__init__(domain, portfolio, pop_size, performance_function=maximise_perf_gap_easy, descriptor_pipe=DescriptorPipeline('features'), generations=np.uint32(1000), repetitions=np.uint16(1), seed=None)
Creates an instance of BaseGenerator with common attributes for generators
| Parameters: |
|
|---|
| Raises: |
|
|---|
Source code in digneapy/generators/_base_generator.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
__repr__()
Return a developer-friendly representation of the generator.
Reuses :meth:__str__ but swaps the surrounding parentheses for angle
brackets, following the convention used elsewhere in the framework.
| Returns: |
|
|---|
Source code in digneapy/generators/_base_generator.py
212 213 214 215 216 217 218 219 220 221 | |
__str__()
Return a human-readable summary of the generator's configuration.
Includes the population size, number of generations, domain name, and the names of the solvers in the portfolio.
| Returns: |
|
|---|
Source code in digneapy/generators/_base_generator.py
199 200 201 202 203 204 205 206 207 208 209 210 | |
GenerationResult
dataclass
Container for the outputs produced by a single run of a generator.
This dataclass bundles together everything needed to inspect or reproduce a generation run: the solvers involved, the resulting instances, the evolutionary history, and a set of computed descriptive metrics.
Metrics are computed automatically in :meth:__post_init__ whenever the
instances collection is non-empty, so callers do not need to invoke
Statistics manually after constructing this object.
| Attributes: |
|
|---|
Source code in digneapy/generators/_base_generator.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
__post_init__()
Compute descriptive statistics for the generated instances.
If instances contains at least one element, metrics is
populated by running Statistics() over the instances and
requesting a pl.DataFrame representation. If instances is
empty, metrics is left untouched and an empty pl.Series is
assigned to self._metrics instead (note: this does not overwrite
the public metrics field).
Source code in digneapy/generators/_base_generator.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |