A simple penalty barrier function is formed which is then evaluated at randomly
sampled points based on the upper and lower parameter bounds
(when eval.type
= 2), else the objective function directly for values not
violating any inequality constraints (when eval.type
= 1). The sampled
points can be generated from the uniform, normal or truncated normal
distributions.
startpars(
pars = NULL,
fixed = NULL,
fun,
eqfun = NULL,
eqB = NULL,
ineqfun = NULL,
ineqLB = NULL,
ineqUB = NULL,
LB = NULL,
UB = NULL,
distr = rep(1, length(LB)),
distr.opt = list(),
n.sim = 20000,
cluster = NULL,
rseed = NULL,
bestN = 15,
eval.type = 1,
trace = FALSE,
...
)
A matrix of dimension bestN x (no.parameters + 1). The last column is the evaluated function value.
The starting parameter vector. This is not required unless the fixed option is also used.
The numeric index which indicates those parameters which should stay fixed instead of being randomly generated.
The main function which takes as first argument the parameter vector and returns a single value.
(Optional) The equality constraint function returning the vector of evaluated equality constraints.
(Optional) The equality constraints.
(Optional) The inequality constraint function returning the vector of evaluated inequality constraints.
(Optional) The lower bound of the inequality constraints.
(Optional) The upper bound of the inequality constraints.
The lower bound on the parameters. This is not optional in this function.
The upper bound on the parameters. This is not optional in this function.
A numeric vector of length equal to the number of parameters, indicating the choice of distribution to use for the random parameter generation. Choices are uniform (1), truncated normal (2), and normal (3).
If any choice in distr
was anything other than uniform (1), this is a
list equal to the length of the parameters with sub-components for the mean and
sd, which are required in the truncated normal and normal distributions.
The number of random parameter sets to generate.
If you want to make use of parallel functionality, initialize and pass a cluster object from the parallel package (see details), and remember to terminate it!
(Optional) A seed to initiate the random number generator, else system time will be used.
The best N (less than or equal to n.sim) set of parameters to return.
Either 1 (default) for the direction evaluation of the function (excluding inequality constraint violations) or 2 for the penalty barrier method.
(logical) Whether to display the progress of the function evaluation.
(Optional) Additional parameters passed to the main, equality or inequality functions
Alexios Galanos and Stefan Theussl
Given a set of lower and upper bounds, the function generates, for those
parameters not set as fixed, random values from one of the 3 chosen
distributions. For simple functions with only inequality constraints, the direct
method (eval.type
= 1) might work better. For more complex setups with
both equality and inequality constraints the penalty barrier method
(eval.type
= 2)might be a better choice.
if (FALSE) {
library(Rsolnp)
library(parallel)
# Windows
cl = makePSOCKcluster(2)
# Linux:
# makeForkCluster(nnodes = getOption("mc.cores", 2L), ...)
gofn = function(dat, n)
{
x = dat[1:n]
y = dat[(n+1):(2*n)]
z = dat[(2*n+1):(3*n)]
ii = matrix(1:n, ncol = n, nrow = n, byrow = TRUE)
jj = matrix(1:n, ncol = n, nrow = n)
ij = which(ii
Run the code above in your browser using DataLab