Learn R Programming

SACOBRA (version 1.2)

cobraPhaseII: Improve the feasible solution by searching new infill points

Description

Improve the feasible solution using the SACOBRA optimizer phase II by searching new infill points with the help of RBF surrogate models. May be even called if no feasible solution is found yet, then phase II will try to find feasible solutions. The problem to solve iteratively is: $$ \mbox{Minimize}\quad f(\vec{x}) , \vec{x} \in [\vec{a},\vec{b}] \subset \mathbf{R}^d $$ $$ \mbox{subject to}\quad g_i(\vec{x}) \le 0, i=1,\ldots,m $$ $$ \mbox{~~~~~~~~~~}\quad\quad h_j(\vec{x}) = 0, j=1,\ldots,r. $$ In this phase the main optimization steps are repeated in a loop as long as the budget is not exhausted. In every iteration the surrogate models are updated and an optimization on the surrogates is done in order to find a better feasible solution.

Usage

cobraPhaseII(cobra)

Arguments

cobra

an object of class COBRA, this is a (long) list containing all settings from cobraInit

Value

cobra, an object of class COBRA from cobraInit, enhanced here by the following elements (among others):

fn

function accepting a d-dimensional vector \(\vec{x}\) and returning an (1+m+r)-vector c(\(f,g_1,\ldots,g_m,h_1,\ldots,h_r\)). This function may be a rescaled and plog-transformed version of the original fn passed into cobraInit. The original fn is stored in cobra$originalFn.

df

data frame with summary of the optimization run (see below)

df2

data frame with additional summary information (see below)

dftr

data frame with additional summary information for TR (see below)

A

(feval x d)-matrix containing all evaluated points in input space. If rescale==TRUE, all points are in rescaled input space.

Fres

a vector of the objective values of all evaluated points

Gres

a (feval x m)-matrix of the constraint values of all evaluated points

predC

a (feval x m)-matrix with the prediction of cobra$constraintSurrogates at all evaluated points

fbest

the best feasible objective value found

xbest

the point in input space yielding the best feasible objective value

ibest

the corresponding iteration number (row of cobra$df, of cobra$A)

PLOG

If TRUE, then the objective surrogate model is trained on the plog-transformed objective function.

Note that cobra$Fres, cobra$fbest, cobra$fbestArray and similar contain always the objective values of the orignial function cobra$fn[1]. (The surrogate models may be trained on a plog-transformed version of this function.) feval = cobra$feval is the maximum number of function evaluations. The data frame cobra$df contains one row per iteration with columns
iter
iteration index
y
true objective value Fres
predY
surrogate objective value. Note: The surrogate may be trained on plog-transformed training data, but predY is transformed back to the original objective range. NA for the initial design points.
predSolu
surrogate objective value at best-known solution cobra$solu, if given. If cobra$solu is NULL, take the current point instead. Note: The surrogate may be trained on plog-transformed training data, but predSolu is transformed back to the original objective range. NA for the initial design points.
feasible
boolean indicating the feasibiltiy of infill point
feasPred
boolean indicating if each infill point is feasible for cobra$constraintSurrogates
nViolations
number of violated constraints
maxViolation
maximum constraint violation.
FEval
number of function evaluations in sequential optimizer. NA if it was a repair step
Best
ever-best feasible objective value fbest. As long as there is no feasible point, take among those with minimum number of violated constraints the one with minimum Fres.
optimizer
e.g. "COBYLA"
optimizationTime
in sec
conv
optimizer convergence code
dist
distance of the current point (row of cobra$A) to the true solution cobra$solu in rescaled space. If there is more than one solution, take the one which has the minimum distance element (since this is the solution to which the current run converges).
distOrig
same as dist, but in original space
XI
the DRC element used in the current iteration
seed
the used seed in every run

The data frame cobra$df2 contains one row per phase-II-iteration with columns

iter
iteration index
predY
surrogate objective value. Note: The surrogate may be trained on plog-transformed training data, but predY is transformed back to the original objective range. NA for the initial design points.
predVal
surrogate objective value + penalty
predSolu
surrogate objective value at true solution (see cobra$df$predSolu)
predSoluPenal
surrogate objective value + penalty at true solution (only diagnostics)
sigmaD
the sigmaD element used in the current iteration (see cobraInit)
penaF
penalty factor used in the current iteration (see cobraInit)
XI
the DRC element used in the current iteration
EPS
the current used margin for constraint function modeling (see epsilonInit in cobraInit )

See Also

cobraPhaseI, cobraInit

Examples

Run this code
# NOT RUN {
## Initialize cobra. The problem to solve is the unconstrained sphere function sum(x^2).   
 
## In version 1.1 and higher there is no need for defining a dummy 
## constraint function for the unconstrained problems
d=2
fName="sphere"
cobra <- cobraInit(xStart=rep(5,d), fName=fName,
                   fn=function(x){c(obj=sum(x^2))},  
                   lower=rep(-10,d), upper=rep(10,d), feval=40)
                   
## Run cobra optimizer
cobra <- cobraPhaseII(cobra)

## The true solution is at solu = c(0,0)
## where the true optimum is fn(solu)[1] = optim = 0
## The solution found by SACOBRA:
print(getXbest(cobra))
print(getFbest(cobra))

## Plot the resulting error (best-so-far feasible optimizer result - true optimum)
## on a logarithmic scale:
optim = 0
plot(cobra$df$Best-optim,log="y",type="l",ylab="error",xlab="iteration",main=fName)

# }

Run the code above in your browser using DataLab