You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
I would expect the original x array to remain unchanged.
Actual behavior
The limit_repair function alters the input x array and returns it.
System configuration
OS: Kubuntu 20.10
Python version: 3.8.6
I believe this is undesirable behavior. Looking at limit_repair's signature (accepts an input array and returns the repaired array) it makes sense that a copy of the input array would be altered and returned, and the input array would remain unchanged.
I have found that if you use a custom function as the tasks frepair, a function that does not alter the input array, then the MTS algorithm and the HDE algorithms that use MTS search functions break (Returned best does not equal the global best stored in the task object).
Example:
fromNiaPy.taskimportStoppingTaskfromNiaPy.algorithms.otherimportMultipleTrajectorySearchfromNiaPy.benchmarksimportSphereimportnumpyasnpdefcustom_frepair(x, l, u):
returnnp.clip(x, l, u)
task=StoppingTask(D=10, nGEN=40, benchmark=Sphere(), frepair=custom_frepair)
algo=MultipleTrajectorySearch()
best_x, best_f=algo.run(task)
print(best_f, task.x_f) # task.x_f will be smaller
This seems to only be an issue with MTS and related algorithms. @kb2623 Can you take a look at the MTS code? I can't figure out where exactly the issue is.
The text was updated successfully, but these errors were encountered:
Steps to reproduce
Expected behavior
I would expect the original x array to remain unchanged.
Actual behavior
The limit_repair function alters the input
x
array and returns it.System configuration
I believe this is undesirable behavior. Looking at
limit_repair
's signature (accepts an input array and returns the repaired array) it makes sense that a copy of the input array would be altered and returned, and the input array would remain unchanged.I have found that if you use a custom function as the tasks frepair, a function that does not alter the input array, then the MTS algorithm and the HDE algorithms that use MTS search functions break (Returned best does not equal the global best stored in the task object).
Example:
This seems to only be an issue with MTS and related algorithms. @kb2623 Can you take a look at the MTS code? I can't figure out where exactly the issue is.
The text was updated successfully, but these errors were encountered: