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

dependency checks after recombination #65

Open
pfistfl opened this issue Apr 25, 2021 · 0 comments
Open

dependency checks after recombination #65

pfistfl opened this issue Apr 25, 2021 · 0 comments

Comments

@pfistfl
Copy link
Member

pfistfl commented Apr 25, 2021

Sorry if this is already mentioned somewhere, could not find anything.

I adapted the code from the README slightly to add a dependency.
The code now breaks at private$.primed_ps$assert_dt(values) during recombination because a value should suddenly be NA.

library("bbotk")
library("paradox")
lgr::threshold("warn")

objective <- ObjectiveRFun$new(
  fun = function(xs) {
    if(is.null(xs$y)) xs$y = 2
    z <- exp(-xs$x^2 - xs$y^2) + 2 * exp(-(2 - xs$x)^2 - (2 - xs$y)^2)
    list(Obj = z)
  },
  domain = ps(
    x = p_dbl(-2, 4),
    y = p_dbl(-2, 4, depends = d == 1),
    d = p_int(lower = 0, upper = 1)
  ),
  codomain = ps(Obj = p_dbl(tags = "maximize"))
)
# Get a new OptimInstance
oi <- OptimInstanceSingleCrit$new(objective,
  terminator = trm("evals", n_evals = 100)
)

library("miesmuschel")

# Get operators
op.m <- mut("gauss")
op.r <- rec("xounif", p = .3)
op.parent <- sel("random")
op.survival <- sel("best")

# Create OptimizerMies object
mies <- opt("mies", mutator = op.m, recombinator = op.r,
  parent_selector = op.parent, survival_selector = op.survival,
  mu = 3, lambda = 2)

mies$optimize(oi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants