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

Random local search over a set of permissible values #374

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HenrikMettler
Copy link
Contributor

Addresses #373. This is based on an implementation I used in a project with hal-cgp, thus the default values for permissible-values. There is two open questions, marked as todo in the code comments.

For convenience i put a short example at the end. I can extend this to a full example before merging or remove it.

@HenrikMettler HenrikMettler self-assigned this Nov 21, 2022
@HenrikMettler
Copy link
Contributor Author

(CI-check fail seems like an unrelated mypy issue)

Copy link
Member

@jakobj jakobj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great stuff, thanks for working on this! 🚀

I left a few comments, please address them before we merge this

objective: Callable,
seed: int,
n_steps: int = 10, # todo: should this be dependent on the number of parameters?
permissible_values: np.ndarray = np.logspace(start=0, stop=7, num=8, base=2, dtype=int),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the current implementation, is it, for example, possible to say "parameters should be uniformly sampled in the interval [0, 1]"? if not, I think it would be a good idea to make the generation of permissible values modular to support such use cases

cgp/local_search/random_search.py Show resolved Hide resolved
cgp/local_search/random_search.py Show resolved Hide resolved
params=params_sampled, params_names=params_names
)
# evaluate fitness
self.objective(new_ind)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, the local-search objective should not modify individuals but return a fitness value

cgp/local_search/random_search.py Show resolved Hide resolved
cgp/local_search/random_search.py Show resolved Hide resolved
ind.fitness = new_ind.fitness


if __name__ == "__main__":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rest should be moved into a test I guess ;)

@jakobj jakobj added this to the 0.4.0 milestone Dec 6, 2022
@jakobj jakobj linked an issue Dec 6, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local search randomly over a set of values
2 participants