The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
This package makes accessible the the Stochastic Quasi-Gradient Differential Evolution Optimization algorithm first published by Sala, Baldanzini, and Pierini (2018). This optimization algorithm fuses the robustness of the population-based global optimization algorithm “Differential Evolution” with the efficiency of gradient-based optimization. The derivative-free algorithm uses population members to build stochastic gradient estimates, without any additional objective function evaluations. Sala, Baldanzini, and Pierini argue this algorithm is useful for ‘difficult optimization problems under a tight function evaluation budget.’ This package can run SQG-DE in parallel and sequentially.
# install.packages("devtools")
::install_github("bmgaldo/graDiEnt") devtools
This is a basic application of the package to a toy optimization problem.
library(graDiEnt)
set.seed(123)
##############
# Maximum Likelihood Example
##############
# simulate from model
=matrix(rnorm(100,c(-1,1,0,1),c(1,1,1,1)),ncol=4,byrow = TRUE)
dataExample
# list parameter names
=c("mu_1","mu_2","mu_3","mu_4")
param_names_example
# negative log likelihood
=function(x,data,param_names){
ExampleObjFun=0
out
names(x) <- param_names
# log likelihoods
=out+sum(dnorm(data[,1],x["mu_1"],sd=1,log=TRUE))
out=out+sum(dnorm(data[,2],x["mu_2"],sd=1,log=TRUE))
out=out+sum(dnorm(data[,3],x["mu_3"],sd=1,log=TRUE))
out=out+sum(dnorm(data[,4],x["mu_4"],sd=1,log=TRUE))
out
return(out*-1)
}
########################
# run optimization
<- optim_SQGDE(ObjFun = ExampleObjFun,
out control_params = GetAlgoParams(n_params=length(param_names_example),
n_iter = 200,
n_particles = 12,
n_diff = 2,
return_trace = TRUE),
data = dataExample,
param_names = param_names_example)
#> [1] "initalizing population..."
#> [1] "1 / 12"
#> [1] "2 / 12"
#> [1] "3 / 12"
#> [1] "4 / 12"
#> [1] "5 / 12"
#> [1] "6 / 12"
#> [1] "7 / 12"
#> [1] "8 / 12"
#> [1] "9 / 12"
#> [1] "10 / 12"
#> [1] "11 / 12"
#> [1] "12 / 12"
#> [1] "population initialization complete :)"
#> [1] "running SQG-DE..."
#> [1] "iter 100/200"
#> [1] "Convergence criterion met. Stopping optimization early"
#> [1] "run complete!"
#SQG DE solution
$solution
out#> [1] -0.9623938 1.1032798 0.1835086 1.0376028
#analytic solution
apply(dataExample, 2, mean)
#> [1] -0.9625315 1.1031771 0.1835243 1.0374537
library(graDiEnt)
set.seed(123)
##############
# Maximum Likelihood Example
##############
# simulate from model
=matrix(rnorm(100,c(-1,1,0,1),c(1,1,1,1)),ncol=4,byrow = TRUE)
dataExample
# list parameter names
=c("mu_1","mu_2","mu_3","mu_4")
param_names_example
# negative log likelihood
=function(x,data,param_names){
ExampleObjFun=0
out
names(x) <- param_names
# log likelihoods
=out+sum(dnorm(data[,1],x["mu_1"],sd=1,log=TRUE))
out=out+sum(dnorm(data[,2],x["mu_2"],sd=1,log=TRUE))
out=out+sum(dnorm(data[,3],x["mu_3"],sd=1,log=TRUE))
out=out+sum(dnorm(data[,4],x["mu_4"],sd=1,log=TRUE))
out
return(out*-1)
}
########################
# run optimization
<- optim_SQGDE(ObjFun = ExampleObjFun,
out control_params = GetAlgoParams(n_params=length(param_names_example),
n_iter = 200,
n_particles = 12,
n_diff = 2,
return_trace = TRUE,
n_cores_use = 4,
parallel_type = 'FORK'),
data = dataExample,
param_names = param_names_example)
#> [1] "initalizing population..."
#> [1] "1 / 12"
#> [1] "2 / 12"
#> [1] "3 / 12"
#> [1] "4 / 12"
#> [1] "5 / 12"
#> [1] "6 / 12"
#> [1] "7 / 12"
#> [1] "8 / 12"
#> [1] "9 / 12"
#> [1] "10 / 12"
#> [1] "11 / 12"
#> [1] "12 / 12"
#> [1] "population initialization complete :)"
#> [1] "initalizing FORK cluser with 4 cores"
#> [1] "running SQG-DE..."
#> [1] "iter 100/200"
#> [1] "Convergence criterion met. Stopping optimization early"
#> [1] "run complete!"
#SQG DE solution
$solution
out#> [1] -0.9623173 1.1034912 0.1838107 1.0369257
#analytic solution
apply(dataExample, 2, mean)
#> [1] -0.9625315 1.1031771 0.1835243 1.0374537
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.