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

Exclude certain terms in fomulae #302

Open
timomit opened this issue Apr 19, 2021 · 2 comments
Open

Exclude certain terms in fomulae #302

timomit opened this issue Apr 19, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@timomit
Copy link

timomit commented Apr 19, 2021

Is it possible to tell CGP to exclude certain terms/operations in the formulae, for instance avoid to high exponents?

@HenrikMettler
Copy link
Contributor

Atm the easiest way to deal with this is probably within the objective function, ie by penalizing such terms with a fitness penalty eg:

def objective(individual):

    f = individual.to_numpy()
    f_sympy = individual.to_sympy()

# your normal evaluation
    individual.fitness = evaluate(f)
# penalize high exponents
    if exponent_too_high(f_sympy)
        individual.fitness -= penalty
   
    return individual

Where exponent_to_high is a function that evaluates your sympy expression, according to your criteria (my guess is that for the high exponents you would have to use sympy log, however this obviously depends on the exact problem)

Another way, if expression in general get "too complex" is to reduce the length of the genome (n_rows and n_columns).

Currently we don't have a built-in feature for measuring expression complexity yet, however this for sure is on the list for future extensions.

@jakobj jakobj added the enhancement New feature or request label Apr 19, 2021
@jakobj jakobj added this to the #thefuture milestone Apr 19, 2021
@jakobj
Copy link
Member

jakobj commented Apr 21, 2021

it would certainly make for an interesting example to show how one can add a penalty term in the objective which is, for example, exponential in the largest exponent of the expression. anyone up for this? happy to review the corresponding PR ;)

@HenrikMettler HenrikMettler self-assigned this Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants