Nothing
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
## ----setup--------------------------------------------------------------------
library(optimflex)
## ----basic_usage--------------------------------------------------------------
# Define a simple objective function
quad_func <- function(x) {
(x[1] - 5)^2 + (x[2] + 3)^2
}
# Run optimization
res <- bfgs(
start = c(0, 0),
objective = quad_func,
control = list(
use_grad = TRUE,
tol_grad = 1e-6,
use_rel_x = TRUE
)
)
# Inspect results
res$par
res$converged
## ----comparison---------------------------------------------------------------
rosenbrock <- function(x) {
100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2
}
start_val <- c(-1.2, 1.0)
# Compare Double Dogleg
res_dd <- double_dogleg(start_val, rosenbrock, control = list(initial_delta = 2.0))
cat("Double Dogleg Iterations:", res_dd$iter, "\n")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.