Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional parameters to complete the objective function #1

Open
dangngohai opened this issue Oct 22, 2019 · 4 comments
Open

Additional parameters to complete the objective function #1

dangngohai opened this issue Oct 22, 2019 · 4 comments
Assignees

Comments

@dangngohai
Copy link

Hello,
Is it possible to add more inputs that are fixed parameters needed to completely specify the objective function (different to parameter need to estimate)?
Thank you very much for sharing your library. It helps me so much.

@xKuZz xKuZz self-assigned this Oct 23, 2019
xKuZz added a commit that referenced this issue Oct 23, 2019
Added an optional parameter in all algorithms called opts, that allows the user to specify as many optional fixed parameters as he/she wants.
This parameter can be changed within executions of the same or a different algorithm.

TODO: Docs & PyPi upgrade
@dangngohai
Copy link
Author

dangngohai commented Oct 23, 2019

In my opinion, you should define your library under classes. I just have look at L-shade method only. I think it would be easier to pass global variables to different methods and give more flexibility by creating possibility of adjusting inputs rather than using only your default parameters.
For adding extra fixed parameters, I think you should add more extra arbitrary positional inputs (e.g *arg) to pyade.commons.apply_fitness and to optimisation functions in methods (for L-SHADE it is apply function).

@dangngohai
Copy link
Author

dangngohai commented Oct 23, 2019

Another question about DE: Why do you compare the population of current generation to 4 (for example:
in current_to_pbest_mutation: if len(population) < 4: return population
or in L-SHADE: # Adapt population size new_population_size = round((4 - init_size) / max_evals * num_evals + init_size)
Where does '4' stand for? I understand it should be the smallest possible size of current generation? but why it is 4?

@xKuZz
Copy link
Owner

xKuZz commented Oct 23, 2019

Currently I don't have enought time to change the entire library to use classes.

Now you can use a new parameter called 'opts' that will be passed to the fitness function in which you can include whatever you. See the simple example at the end of README.md

You can change all of the parameters that the function apply gets by modifying the params dict. There may be some parameters fixed in the code by default to the values used by the author of each algorithm. If that's the case and you need access to some of them, open a new issue and I will work on that when possible.

4 is not the mimimum size of the current generation but the minimum size of a generation during the algorithm (reached at the end). That's because the current-to-pbest mutation, requires at least 4 individuals to work. See Eq. 10 on L-SHADE paper

Thanks for your feedback.

@Kaeryv
Copy link

Kaeryv commented Nov 30, 2023

For those who would need to do such a thing: don't forget python's functools.

from functools import partial
def objective_function(x, param1, param2, param3):
    pass

objective_function_cmplt = partial(objective_function, param1=..., param2=..., param3=...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants