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

Method result

pymoo/core/algorithm.py:253–297  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

251 return ret
252
253 def result(self) -> Result:
254 res = Result()
255
256 # store the time when the algorithm as finished
257 res.start_time = self.start_time
258 res.end_time = time.time()
259 res.exec_time = res.end_time - res.start_time # type: ignore
260
261 res.pop = self.pop
262 res.archive = self.archive
263 res.data = self.data
264
265 # get the optimal solution found
266 opt = self.opt
267 if opt is None or len(opt) == 0: # type: ignore
268 opt = None
269
270 # if no feasible solution has been found
271 elif not np.any(opt.get("FEAS")):
272 if self.return_least_infeasible:
273 opt = filter_optimum(opt, least_infeasible=True)
274 else:
275 opt = None
276 res.opt = opt
277
278 # if optimum is set to none to not report anything
279 if res.opt is None:
280 X, F, CV, G, H = None, None, None, None, None
281
282 # otherwise get the values from the population
283 else:
284 X, F, CV, G, H = self.opt.get("X", "F", "CV", "G", "H") # type: ignore
285
286 # if single-objective problem and only one solution was found - create a 1d array
287 if self.problem.n_obj == 1 and len(X) == 1: # type: ignore
288 X, F, CV, G, H = X[0], F[0], CV[0], G[0], H[0]
289
290 # set all the individual values
291 res.X, res.F, res.CV, res.G, res.H = X, F, CV, G, H
292
293 # create the result object
294 res.problem = self.problem
295 res.history = self.history
296
297 return res
298
299 def ask(self) -> Population | None:
300 return self.infill()

Callers 7

runMethod · 0.95
advanceMethod · 0.95
__call__Method · 0.80
run_notebooksFunction · 0.80
loop.pyFile · 0.80
nrbo.pyFile · 0.80

Calls 4

ResultClass · 0.90
filter_optimumFunction · 0.90
timeMethod · 0.45
getMethod · 0.45

Tested by 1