This R package implements alternating optimization, which is an iterative procedure for optimizing some function jointly over all parameters by alternating restricted optimization over individual parameter subsets.
For more details see the help vignette:
vignette("ao", package = "ao")
You can install the released version from CRAN with:
install.packages("ao")
And the development version from GitHub with:
# install.packages("devtools")
::install_github("loelschlaeger/ao") devtools
The following lines perform alternating optimization of the Himmelblau’s
function, separately for and
, with the parameter restrictions
:
library("ao")
#> Lade nötiges Paket: optimizeR
<- function(x) (x[1]^2 + x[2] - 11)^2 + (x[1] + x[2]^2 - 7)^2
himmelblau ao(
f = himmelblau, p = c(0,0), partition = list(1, 2),
optimizer = set_optimizer_optim(lower = -5, upper = 5, method = "L-BFGS-B")
)#> $optimum
#> [1] 1.940035e-12
#>
#> $estimate
#> [1] 3.584428 -1.848126
#>
#> $sequence
#> iteration partition time p1 p2
#> 1 0 0 0.0000000000 0.000000 0.000000
#> 2 1 1 0.0314528942 3.395691 0.000000
#> 3 1 2 0.0003468990 3.395691 -1.803183
#> 4 2 1 0.0002689362 3.581412 -1.803183
#> 5 2 2 0.0002470016 3.581412 -1.847412
#> 6 3 1 0.0003299713 3.584381 -1.847412
#> 7 3 2 0.0002009869 3.584381 -1.848115
#> 8 4 1 0.0002000332 3.584427 -1.848115
#> 9 4 2 0.0001769066 3.584427 -1.848126
#> 10 5 1 0.0001850128 3.584428 -1.848126
#> 11 5 2 0.0001809597 3.584428 -1.848126
#>
#> $time
#> Time difference of 0.03914905 secs