Description Usage Arguments Details Value Author(s) See Also Examples
In this phase the important parameters are set and the initial design population are evaluated on the real function. The problem to solve 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}) ≤ 0, i=1,…,m
\mbox{~~~~~~~~~~}\quad\quad h_j(\vec{x}) = 0, j=1,…,r.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | cobraInit(
xStart,
fn,
fName,
lower,
upper,
feval,
initDesign = "LHS",
initDesPoints = 2 * length(xStart) + 1,
initDesOptP = NULL,
initBias = 0.005,
skipPhaseI = TRUE,
seqOptimizer = "COBYLA",
seqFeval = 1000,
seqTol = 1e-06,
ptail = TRUE,
squares = TRUE,
conTol = 0,
DOSAC = 1,
sac = defaultSAC(DOSAC),
repairInfeas = FALSE,
ri = defaultRI(),
RBFmodel = "cubic",
RBFwidth = -1,
GaussRule = "One",
widthFactor = 1,
RBFrho = 0,
MS = defaultMS(),
equHandle = defaultEquMu(),
rescale = TRUE,
newlower = -1,
newupper = 1,
XI = DRCL,
TrustRegion = FALSE,
TRlist = defaultTR(),
conditioningAnalysis = defaultCA(),
penaF = c(3, 1.7, 3e+05),
sigmaD = c(3, 2, 100),
constraintHandling = "DEFAULT",
verbose = 1,
verboseIter = 10,
DEBUG_RBF = defaultDebugRBF(),
DEBUG_TR = FALSE,
DEBUG_TRU = FALSE,
DEBUG_RS = FALSE,
DEBUG_XI = FALSE,
trueFuncForSurrogates = FALSE,
saveIntermediate = FALSE,
saveSurrogates = FALSE,
epsilonInit = NULL,
epsilonMax = NULL,
solu = NULL,
cobraSeed = 42
)
|
xStart |
a vector of dimension |
fn |
objective and constraint functions: |
fName |
the results of |
lower |
lower bound \vec{a} of search space, same dimension as |
upper |
upper bound \vec{b} of search space, same dimension as |
feval |
maximum number of function evaluations |
initDesign |
["LHS"] one out of ["RANDOM","LHS","BIASED","OPTIMIZED","OPTBIASED"] |
initDesPoints |
[ |
initDesOptP |
[NULL] only for initDesign=="OPTBIASED": number of points for the "OPT" phase. If NULL, take initDesPoints. |
initBias |
[0.005] bias for normal distribution in "OPTBIASED" and "BIASED" |
skipPhaseI |
[TRUE] if TRUE, then skip |
seqOptimizer |
["COBYLA"] string defining the optimization method for COBRA phases I and II, one out of ["COBYLA","ISRES","HJKB","NMKB","ISRESCOBY"] |
seqFeval |
[1000] maximum number of function evaluations on the surrogate model |
seqTol |
[1e-6] convergence tolerance for sequential optimizer, see param |
ptail |
[TRUE] TRUE: with, FALSE: without polynomial tail in |
squares |
[TRUE] set to TRUE for including the second order polynomials in building the fitness and constraint surrogates in |
conTol |
[0.0] constraint violation tolerance |
DOSAC |
[1] set one out of [0|1|2]. |
sac |
[ |
repairInfeas |
[FALSE] if TRUE, trigger the repair of appropriate infeasible solutions |
ri |
[ |
RBFmodel |
["cubic"] a string for the type of the RBF model, "cubic", "Gaussian" or "MQ" |
RBFwidth |
[-1] only relevant for Gaussian RBF model. Determines the width σ.
For more details see parameter |
GaussRule |
["One"] only relevant for Gaussian RBF model, see |
widthFactor |
[1.0] only relevant for Gaussian RBF model. Additional constant factor applied to each width σ |
RBFrho |
[0.0] experimental: 0: interpolating, > 0, approximating (spline-like) Gaussian RBFs |
MS |
[ |
equHandle |
[ |
rescale |
[TRUE] if TRUE, transform the input space from |
newlower |
[-1] lower bound of each rescaled input space dimension, if |
newupper |
[+1] upper bound of each rescaled input space dimension, if |
XI |
[DRCL] magic parameters for the distance requirement cycle (DRC) |
TrustRegion |
[FALSE] if TRUE, perform trust region algorithm |
TRlist |
[ |
conditioningAnalysis |
[ |
penaF |
[c(3,1.7,3e5)] parameters for dynamic penalty factor (fct subProb in
|
sigmaD |
[c(3,2.0,100)] parameters for dynamic distance factor (fct subProb in
|
constraintHandling |
["DEFAULT"] (other choices: "JOINESHOUCK", "SMITHTATE", "COIT", "BAECKKHURI";
experimental, only relevant |
verbose |
[1] set one out of [0|1|2], how much output to print |
verboseIter |
[10] an interegr value. Printing the summarized results after each |
DEBUG_RBF |
[ |
DEBUG_TR |
[FALSE] prints information about trust region status and visualisation for |
DEBUG_TRU |
[FALSE] visualize trust-region RBF (only for dimension==2) |
DEBUG_RS |
[FALSE] prints the RS probability in each iteration in the console |
DEBUG_XI |
[FALSE] if TRUE, then print in |
trueFuncForSurrogates |
[FALSE] if TRUE, use the true (constraint & fitness) functions instead of surrogates (only for debug analysis) |
saveIntermediate |
[FALSE] if TRUE, then |
saveSurrogates |
[FALSE] if TRUE, then |
epsilonInit |
[NULL] initial constant added to each constraint to maintain a certain margin to boundary |
epsilonMax |
[NULL] maximum for constant added to each constraint |
solu |
[NULL] the best-known solution (only for diagnostics). This is normally a
vector of length d. If there are multiple solutions, it is a matrix with d
columns (each row is a solution). If NULL, then the current best point
will be used in |
cobraSeed |
[42] seed for random number generator |
If epsilonInit
or epsilonMax
are NULL on input, then cobra$epsilonInit
and cobra$epsilonMax
, resp., are set to 0.005*l
where l
is the smallest
side of the search box.
Note that the parameters penaF
, sigmaD
, constraintHandling
are only
relevant for penalty-based internal optimizers nmkb
or HJKB. They are NOT relevant
for default optimizer cobyla
.
Although the software was originally designed to handle only constrained optimization problems, it can also address unconstrained optimization problems
How to code which constraint is equality constraint? - Function fn
should return
an (1+m+r)-dimensional vector with named elements. The first element is the objective, the
other elements are the constraints. All equality constraints should carry the name equ
.
(Yes, it is possible that multiple elements of a vector have the same name.)
cobra
, an object of class COBRA, this is a (long) list containing most
of the argument settings (see above) and in addition (among others):
|
(feval x dim)-matrix containing the initial design points in input . space. If rescale==TRUE, all points are in rescaled input space. |
|
a vector of the objective values of the initial design points |
|
a matrix of the constraint values of the initial design points |
|
the total number m+r of constraints |
|
the threshhold parameter for the number of consecutive iterations that yield feasible solutions before margin epsilon is reduced |
|
the threshhold parameter for the number of consecutive iterations that yield infeasible solutions before margin epsilon is increased |
|
number of constraint violations |
|
maximum constraint violation |
|
maximum constraint violation |
|
A vector of all refined solutions generated by trust region algorithm (see |
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.)
Wolfgang Konen, Samineh Bagheri, Patrick Koch, Cologne University of Applied Sciences
startCobra
, cobraPhaseI
, cobraPhaseII
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Initialize cobra. The problem to solve is the sphere function sum(x^2)
## with the equality constraint that the solution is on a circle with
## radius 2 and center at c(1,0).
d=2
fName="onCircle"
cobra <- cobraInit(xStart=rep(5,d), fName=fName,
fn=function(x){c(obj=sum(x^2),equ=(x[1]-1)^2+(x[2]-0)^2-4)},
lower=rep(-10,d), upper=rep(10,d), feval=40)
## Run sacobra optimizer
cobra <- cobraPhaseII(cobra)
## The true solution is at solu = c(-1,0) (the point on the circle closest
## to the origin) where the true optimum is fn(solu)[1] = optim = 1
## 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 = 1
plot(abs(cobra$df$Best-optim),log="y",type="l",ylab="error",xlab="iteration",main=fName)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.