Skip to content

Commit

Permalink
Add reconstruct_objs feature
Browse files Browse the repository at this point in the history
A new feature is added to the iterative process of the optimization algorithm. Users can customize a function and assign it to the Algorithm through kwsargs, call the function in each iteration in run() and update the objs to implement the dynamic objective function in the iteration.
  • Loading branch information
waterfall-xi authored Mar 8, 2024
1 parent f3f4b83 commit 9f12609
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pymoo/core/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def setup(self, problem, **kwargs):

def run(self):
while self.has_next():
if 'reconstruct_objs_func' in self.__dict__:
new_objs = self.reconstruct_objs_func()
self.problem.objs = new_objs
self.next()
return self.result()

Expand Down

0 comments on commit 9f12609

Please sign in to comment.