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

Weird behaviour of GenSA() when return value is -inf #50

Open
KevCaz opened this issue Jan 15, 2020 · 0 comments
Open

Weird behaviour of GenSA() when return value is -inf #50

KevCaz opened this issue Jan 15, 2020 · 0 comments
Labels
note Something to keep in mind

Comments

@KevCaz
Copy link
Member

KevCaz commented Jan 15, 2020

When the function to be monimized in in GenSA keeps returning -inf the random generation of parameters is always the same, even when set.seed() takes different values. I don't know if this is actually desired but this is problematic for fitMC().

A workaround is to replace -inf by a very large negative value but this has some limits.

Reprex:

Rastrigin <- function(x) {
                 print(x[1])
                 sum(x^2 - 10 * cos(2 * pi  * x)) + 10 * length(x)
                 log(0)
             }

set.seed(1234)
             dimension <- 2
             global.min <- 0
             tol <- 1e-13
             lower <- rep(-5.12, dimension)
             upper <- rep(5.12, dimension)
             out <- GenSA(lower = lower, upper = upper, fn = Rastrigin,
                     control=list(maxit = 10, threshold.stop=global.min+tol,verbose=TRUE))
             out[c("value","par","counts")]

set.seed(789)
             dimension <- 2
             global.min <- 0
             tol <- 1e-13
             lower <- rep(-5.12, dimension)
             upper <- rep(5.12, dimension)
             out <- GenSA(lower = lower, upper = upper, fn = Rastrigin,
                     control=list(maxit = 10, threshold.stop=global.min+tol,verbose=TRUE))
             out[c("value","par","counts")]

and check the values printed in both case.

@KevCaz KevCaz added the note Something to keep in mind label Jan 15, 2020
KevCaz pushed a commit that referenced this issue Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
note Something to keep in mind
Projects
None yet
Development

No branches or pull requests

1 participant