ask_dY {templr} | R Documentation |
ask&tell component function to 'ask' objective function gradient evaluation using finite difference.
Description
ask&tell component function to 'ask' objective function gradient evaluation using finite difference.
Usage
ask_dY(
x,
dX = 0.001,
id = 0,
dX.tmp = "dX.todo",
dY.tmp = "dY.done",
tmp_path = file.path(tempdir(), "..", "asktell.tmp"),
sleep_step = 0.1,
sleep_init = 0,
timeout = 360000,
trace = function(...) cat(paste0(..., "\n")),
clean = TRUE,
force_cleanup = FALSE
)
Arguments
x |
input values of objective function gradient to compute |
dX |
finite difference applied to input values to compute gradient |
id |
unique identifier for this asktell loop (default: "0") |
dX.tmp |
temporary "X" values file (default: "dX.todo") |
dY.tmp |
temporary "Y" values file (default: "dY.done") |
tmp_path |
temporary directory to store X.tmp & Y.tmp (default: 'tempdir()/../asktell.tmp') |
sleep_step |
delay between checking X.tmp and Y.tmp (default: 0.1 sec.) |
sleep_init |
initial delay before checking X.tmp and Y.tmp (default: 0 sec.) |
timeout |
maximum delay before breaking loop if X.tmp or Y.tmp doesn't appear (default: 36000 sec. = 10 min.) . |
trace |
function to display asktell loop status (default : 'cat') |
clean |
should we cleanup temporary files after reading ? (default: TRUE) |
force_cleanup |
should we cleanup temporary files before writing (possible conflicting asktell calls) ? (default: FALSE) |
Details
'ask&tell' injection loop to call an external objective function within an inline algorithm (like optim(...)) Main idea: pass 'ask_Y' as objectve function argument of algorithm, which will wait until you call 'tell_Y' in another R process. In this secondary process, you can read what X is called using 'ask_X', and when you know what values returns from the external objective, just call 'tell_Y' to give it.
Value
output value of objective function gradient, as given by tell_dY() call in parallel session
Author(s)
Y. Richet, discussions with D. Sinoquet. Async IO principle was defined by G. Pujol.
Examples
## Not run: ### Assumes you can use two independent R sessions
## In main R session
ask_dY(x=123)
## In another R session
ask_dX() # returns 123
tell_dY(y=456)
## Then ask_dY in main R session returns with value '456'
## End(Not run)