Skip to content

Commit

Permalink
reconstruct_objs according algorithm self
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. reconstruct_objs_func() is required to  include the arguement algo and can be used to complete the objs reconstruction using the information in algo.
  • Loading branch information
waterfall-xi authored Mar 21, 2024
1 parent 6db6bf9 commit 1dfe498
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pymoo/core/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ 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.problem.objs = self.reconstruct_objs_func(algo=self)
self.next()
return self.result()

Expand Down

0 comments on commit 1dfe498

Please sign in to comment.