MCPcopy Create free account
hub / github.com/anyoptimization/pymoo / advance

Method advance

pymoo/core/algorithm.py:206–251  ·  view source on GitHub ↗
(
        self, infills: Population | None = None, **kwargs
    )

Source from the content-addressed store, hash-verified

204 return infills
205
206 def advance(
207 self, infills: Population | None = None, **kwargs
208 ) -> Population | Result:
209
210 # if infills have been provided set them as offsprings and feed them into advance
211 self.off = infills
212
213 # if the algorithm has not been already initialized
214 if not self.is_initialized:
215 # set the generation counter to 1
216 self.n_iter = 1
217
218 # assign the population to the algorithm
219 self.pop = infills
220
221 # do what is necessary after the initialization
222 self._initialize_advance(infills=infills, **kwargs)
223
224 # set this algorithm to be initialized
225 self.is_initialized = True
226
227 # always advance to the next iteration after initialization
228 self._post_advance()
229
230 else:
231 # call the implementation of the advance method - if the infill is not None
232 val = self._advance(infills=infills, **kwargs)
233
234 # always advance to the next iteration - except if the algorithm returns False
235 if val is None or val:
236 self._post_advance()
237
238 # if the algorithm has terminated, then do the finalization steps and return the result
239 if self.termination.has_terminated(): # type: ignore
240 self.finalize()
241 ret = self.result()
242
243 # otherwise just increase the iteration counter for the next step and return the current optimum
244 else:
245 ret = self.opt # type: ignore
246
247 # add the infill solutions to an archive
248 if self.archive is not None and infills is not None:
249 self.archive = self.archive.add(infills)
250
251 return ret
252
253 def result(self) -> Result:
254 res = Result()

Callers 3

nextMethod · 0.95
tellMethod · 0.95

Calls 7

_initialize_advanceMethod · 0.95
_post_advanceMethod · 0.95
_advanceMethod · 0.95
finalizeMethod · 0.95
resultMethod · 0.95
has_terminatedMethod · 0.80
addMethod · 0.45

Tested by 1