| 181 | self.opt = None |
| 182 | |
| 183 | def infill(self) -> Population | None: |
| 184 | if self.problem is None: |
| 185 | raise Exception("Please call `setup(problem)` before calling next().") |
| 186 | |
| 187 | # the first time next is called simply initial the algorithm - makes the interface cleaner |
| 188 | if not self.is_initialized: |
| 189 | # hook mostly used by the class to happen before even to initialize |
| 190 | self._initialize() |
| 191 | |
| 192 | # execute the initialization infill of the algorithm |
| 193 | infills = self._initialize_infill() |
| 194 | |
| 195 | else: |
| 196 | # request the infill solutions if the algorithm has implemented it |
| 197 | infills = self._infill() |
| 198 | |
| 199 | # set the current generation to the offsprings |
| 200 | if infills is not None: |
| 201 | infills.set("n_gen", self.n_iter) |
| 202 | infills.set("n_iter", self.n_iter) |
| 203 | |
| 204 | return infills |
| 205 | |
| 206 | def advance( |
| 207 | self, infills: Population | None = None, **kwargs |