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

ga fails to minimize functions with negative range #30

Open
fredcallaway opened this issue Feb 3, 2019 · 5 comments
Open

ga fails to minimize functions with negative range #30

fredcallaway opened this issue Feb 3, 2019 · 5 comments

Comments

@fredcallaway
Copy link

Example:

best, = ga(x->-sum(x), 
          5,
          initPopulation=n->rand(Bool, n),
          iterations=10000,
          mutationRate = 0.2,
          selection = roulette
          )

I think this is because you maximize the inverse of the provided objective function. Is there a reason to do this rather than just directly minimizing the function? (Or I guess, maximizing the negation of the function)

@fredcallaway
Copy link
Author

Looking at the code more, lots of stuff won't make sense with negative objective values. Is this just a standard assumption for genetic algorithms? (I'm no expert!)

@apeano
Copy link

apeano commented Feb 22, 2019

I guess it is because the selection methods need to sort the population basing on the fitness. So the ga method should take in input a max/min parameter to drive the sorting phases.
Maybe this is a limitation of this first version.

@phelipe
Copy link

phelipe commented Feb 22, 2019

You need to rewrite your problem to fit the package.

@wildart
Copy link
Owner

wildart commented Feb 24, 2019

This package performs an objective function minimization by maximizing its inverse. Shape your problem to fit the package behavior.

@fredcallaway
Copy link
Author

fredcallaway commented Feb 25, 2019

OK sure that's fine. But I think it would be good to include the constraint that the objective function be positive in the documentation.

Also, it's worth noting that taking the inverse has scaling effects that may be undesirable. In particular, for values near 0, very small differences in the objective function will lead to large differences in the inverse objective function, which could reduce population diversity if using selection functions such as roulette or SUS.

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

No branches or pull requests

4 participants