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

Help wanted: solution to very simple problem? #73

Closed
TheMEGuy opened this issue Nov 24, 2020 · 1 comment
Closed

Help wanted: solution to very simple problem? #73

TheMEGuy opened this issue Nov 24, 2020 · 1 comment

Comments

@TheMEGuy
Copy link

Hi,

thanks for the cool package.

I recently started to do some research within the field of Evolutionary Strategies.

I have a question regarding a very simple problem:

indiv = [0.0,0.0]
lowerbound = [0.0,0.0]
upperbound = [20.0,20.0]

function fit(x)
    if(sum(x) == 4.0)
        return -1
    else
        return +1
    end
end

Evolutionary.optimize(fit,lowerbound,upperbound,indiv,CMAES(),Evolutionary.Options(iterations = 1000))

>Status = success
>Candidate solution
> Minimzer = [6.216071822584697,2.911369416556109]
> Minimum = 1.0
> Iterations = 12

>Found with
> Algorihm: (15,30)-CMA-ES

I do not understand why the Algorithm yields infeasible solutions, returns the status "success" and always stops after 12 Iterations.

Another question:

Is there a way to mutate the genotype, so that the mutation is a multiple of a certain step/number?
The Mutations should do something like this:
step = 0.25 :[1.495763498,1.23478634] --> [1.75,1.23478634]. Is there such an Algorithm in this package?

I really hope I was able to explain my problems understandably.

Thanks

@TheMEGuy TheMEGuy changed the title Problematic solution to very simple problem Help wanted: solution to very simple problem Nov 25, 2020
@TheMEGuy TheMEGuy changed the title Help wanted: solution to very simple problem Help wanted: solution to very simple problem? Nov 27, 2020
@wildart
Copy link
Owner

wildart commented Nov 30, 2020

The fitness function is ill-defined. There is no variation in the resulting value it always +1 (the chance of getting -1 is close to 0 in the real domain).

So after the couple iterations the difference between previous and current fitness values is 0 which is less then the tolerance threshold, so the algorithm going to stop. There are additional 10 iterations of the optimization on successful tolerance condition, controlled by successive_f_tol option.

You may want to try the following fitness function fit(x) = abs(4.0 - sum(x))

julia> fit(x) = abs(4.0 - sum(x))
fit (generic function with 1 method)

julia> Evolutionary.optimize(fit,lowerbound,upperbound,indiv,CMAES(),Evolutionary.Options(iterations = 1000))

 * Status: success

 * Candidate solution
    Minimizer:  [2.2801910167618544, 1.719808983238146]
    Minimum:    0.0
    Iterations: 478

 * Found with
    Algorithm: (15,30)-CMA-ES

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

2 participants