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

Custom complexities of operators, variables, and constants #105

Merged
merged 11 commits into from
May 16, 2022

Conversation

MilesCranmer
Copy link
Owner

@MilesCranmer MilesCranmer commented May 16, 2022

This change allows you to declare the complexity of operators, variables, and constants, to your liking. No more will all complexities be fixed as simply the number of nodes in a tree–now you can state that exp is more complex than + by passing the argument:

square(x) = x^2

options = Options(
    binary_operators=(+, *),
    unary_operators=(exp, square),
    complexity_of_operators=[exp => 5, (+) => 1, square => 1]  # Default is 1, if undefined
)

This will be factored into the search, and the most accurate expression at each complexity will be returned.

Todo's:

  • Right now it seems there's a bug where the initial expression generated can be larger than your maxsize, and this gives a bounds error (since it's trying to store the expression in the hall of fame, but there's no corresponding bin).
  • Document this.
  • Enable this for PySR (optional)

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.

1 participant