Learn R Programming

SACOBRA (version 1.2)

multiCOBRA: Perform multiple COBRA runs

Description

Perform multiple COBRA runs. Each run starts with a different seed so that a different start point, a different initial design and different random restarts are choosen.

Usage

multiCOBRA(
  fn,
  lower,
  upper,
  nrun = 10,
  feval = 200,
  funcName = "GXX",
  fName = paste0("mult-", funcName, ".Rdata"),
  path = NULL,
  cobra = NULL,
  optim = NULL,
  target = 0.05,
  saveRdata = FALSE,
  ylim = c(1e-05, 10000),
  plotPDF = FALSE,
  startSeed = 41
)

Arguments

fn

objective function that is to be minimized, should return a vector of the objective function value and the constraint values

lower

lower bound of search space

upper

upper bound of search space

nrun

[10] number of runs

feval

[200] function evaluations per run

funcName

["GXX"] name of the problem

fName

the results (dfAll and others) are saved to <fname>.Rdata (only if saveRdata==TRUE)

path

[NULL] optional path

cobra

[NULL] list with COBRA settings. If NULL, initialize cobra with a suitable call to cobraInit.

optim

[NULL] the true optimum (or best known value) of the problem (only for diagnostics)

target

[0.05] a single run meets the target, if the final error is smaller than target

saveRdata

[FALSE] if TRUE, save results (dfAll,optim,target,fName,funcName) on <fName>.Rdata

ylim

the y limits

plotPDF

[FALSE] if TRUE, plot not only to current graphics device but to <fName>.pdf as well

startSeed

[41] after each run the seed is incremented by 1, starting with startSeed

Value

mres, a list containing

cobra

the settings and results from last run

dfAll

a data frame with a result summary for all runs (see below)

z

a vector containing for each run the ever-best feasible objective value

z2

a data frame containing for each run the minimum error (if optim is available)

The data frame dfAll contains one row per iteration with columns (among others)

ffc
fitness function calls (i.e. the iterations cobra$iter)
fitVal
true fitness function value
fitSur
surrogate fitness function value
feas
is current iterate feasible on the true constraints?
feval
number of evaluations of the internal optimizer on the surrogate functions (NA if it is a repairInfeasible-step)
XI
the DRC element used in the current iteration
everBestFeas
the ever-best feasible fitness function value
run
the number of the current run
X1,X2,...
the solution in (original) input space

Details

Side effect: An error plot showing each run and the mean and median of all runs (see multiRunPlot). The results (dfAll and others) are saved to <fName>.Rdata.

See Also

multiRunPlot, cobraPhaseII

Examples

Run this code
# NOT RUN {
## solve G11 problem nrun times  and plot the results of all nrun runs
nrun=4
feval=25

## Defining the constrained problem (G11)
fn <- function(x) {
  y<-x[1]*x[1]+((x[2]-1)^2)
  y<-as.numeric(y)
  
  g1 <- as.numeric(+(x[2] - x[1]^2))
  
  return(c(objective=y, g1=g1))
}
funcName="G11"
lower<-c(-1,-1) 
upper<-c(+1,+1) 

## Initializing and running cobra
cobra <- cobraInit(xStart=c(0,0), fn=fn, fName=funcName, lower=lower, upper=upper,
                   feval=feval, initDesPoints=3*2, DOSAC=1, cobraSeed=1)

mres <- multiCOBRA(fn,lower,upper,nrun=nrun,feval=feval,optim=0.75
                  ,cobra=cobra,funcName=funcName
                  ,ylim=c(1e-12,1e-0),plotPDF=FALSE,startSeed=42)

## There are two true solutions at 
## solu1 = c(-sqrt(0.5),0.5) and solu2 = c(+sqrt(0.5),0.5)
## where the true optimum is f(solu1) = f(solu2) = -0.75
## The solution from SACOBRA is close to one of the true solutions:
print(getXbest(mres$cobra))
print(getFbest(mres$cobra))
print(mres$z2)


# }

Run the code above in your browser using DataLab