-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Check termination befor the first iteration #137
Comments
I guess you are right. Would you do a PR? And before talk a bit here how we do that? |
Certainly true. It's basically just this lines if (getOptStateTermination(opt.state) > 0L) break in |
What I mean is let the user write his own stopping conditions which may depend on the opt.path entries and in particualar the extras stuff in the opt.path. |
@jakobbossek Also the generic solution should depend on the currently fitted model(s). |
I would pass the |
yup |
I also do like Jakobs idea. But as Bernd mentioned, I think we should talk about it first. In the best case Jakob will explain his interface and we simply agree with him. |
Agreed, lets write down the API here. And simple common things will always be settable in a simple manner. |
We could do: setMBOControlTermination(budget = 100, y = 0.2) # stop after 100 fevals or when y is <= 0.2 and setMBOControlTermination(fun = function(OptState)) where the user can programm his own stopping function for bugdet, y, etc That seems goof and general? |
Bascially there would be a kind of generator for each stopping condition, e.g., The user can pass an arbitrary number of stopping conditions, e.g., setMBOControlTermination(
makeMBOBudgetTermination(budget = 100),
makeMBOIterTermination(max.iter = 10)
) We could also offer a shortcut helper of the following form for the most common stopping conditions: setMBOControlTermination(budget = 100, y = 0.2, ...) |
My first idea was to use a separate termination object (makeMBOTerminator) and to detach the termination stuff from the control-object.The termination-object itself is simply a function(opt.state) that returns TRUE or FALSE and a termination message. The terminator has some simple parameters like budget, time.budget, ... and the general fun-argument, as you proposed. The advantage would be the better differentiation between termination-parameters and control-parameters. The disadvantage would be an additional parameter for the main mbo. |
@danielhorn: This is in general exactly what I described. |
Ok, it is not exactly what I described, but similar. I discribed multiple terminator objects, i.e., one terminator object for each stopping condition and a convenient helper which generates the terminator objects internally for the user for the most important stopping conditions. |
I thought about the interface once again. The best way would be to allow custom termination objects. Hence, we should provide a function Moreover, there should be a fn = makeSphereFunction(2L)
...
makeMyTerminator = function(target.value, eps = 1e-4) {
force(target.value)
myTerminator = function(opt.state) {
# do stuff on opt.path or opt.state
}
makeMBOTerminator(myTerminator, stop.message = "Found global opt")
}
...
ctrl = makeMBOControl(...)
ctrl = setMBOControlTermination(iters = 100, makeMyTerminator(0))
res = mbo(fn, ctrl) There would be MBOTerminator objects for max iters and time budget as well, which are generated automatically by What do you think? |
Ok. We talked about that. The current interface is: fn = makeSphereFunction(2L)
myTerminator = function(opt.state) {
# do stuff on opt.path or opt.state
return(list(
stop.message = "Found global optimum",
cond = TRUE/FALSE
))
}
ctrl = makeMBOControl(...)
ctrl = setMBOControlTermination(iters = 100, myTerminator)
res = mbo(fn, ctrl) |
We decided, that custom stopping conditions should be given by a simple function with a list return value. What if the stopping condition depends on a user defined value, e.g., myTerminator = function(target.fun.value) {
assertNumber(target.fun.value, na.ok = FALSE)
force(target.fun.value)
makeMBOTerminator(
fn = function(opt.state) { getOptStateBestValue(opt.state) <= target.fun.value) },
message = sprintf("Target fun value %f reached.", target.fun.value)
)
} |
ping |
I do need to write down the answer..... I dont get why you dont see that your constructor / force still works?
|
Ok. Thats clear. But without the constructor it is not possible? |
just called you, real talking maybe easier? |
Done. |
At the moment: Termination is checked for the first time after iteration one.
What if the initial design itself fullfills the termination criterion? In this case, we make one iteration. But we don't have to. We should also check the termination before iteration one - and end with a warning(?) in this case.
(I know - if the initial design is enough to terminate, something has to be wrongly specified. That's exactly what I've done a minute ago. But we don't have to do this one iteration here, so we should not.)
The text was updated successfully, but these errors were encountered: