multiCOBRA: Perform multiple COBRA runs

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/multiCOBRA.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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

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.

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

Author(s)

Wolfgang Konen, Samineh Bagheri, Cologne University of Applied Sciences

See Also

multiRunPlot, cobraPhaseII

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## 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)

SACOBRA documentation built on March 26, 2020, 7:15 p.m.