startCobra: Start COBRA (constraint-based optimization) phase I and/or...

Description Usage Arguments Value See Also Examples

View source: R/startCobra.R

Description

Start COBRA (constraint-based optimization) phase I and/or phase II for object cobra

Usage

1
startCobra(cobra)

Arguments

cobra

initialized COBRA object, i.e. the return value from cobraInit

Value

cobra, an object of class COBRA

See Also

cobraInit, cobraPhaseI, 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
33
34
35
36
37
38
39
40
41
42
43
44
45
## solve G01 problem

## defining the constraint problem: G01
fn<-function(x){
   obj<- sum(5*x[1:4])-(5*sum(x[1:4]*x[1:4]))-(sum(x[5:13]))
   g1<- (2*x[1]+2*x[2]+x[10]+x[11] - 10)
   g2<- (2*x[1]+2*x[3]+x[10]+x[12] - 10)
   g3<- (2*x[2]+2*x[3]+x[11]+x[12] - 10)

   g4<- -8*x[1]+x[10]
   g5<- -8*x[2]+x[11]
   g6<- -8*x[3]+x[12]

   g7<- -2*x[4]-x[5]+x[10]
   g8<- -2*x[6]-x[7]+x[11]
   g9<- -2*x[8]-x[9]+x[12]

   res<-c(obj, g1 ,g2 , g3 
         , g4 , g5 , g6 
         , g7 , g8 , g9)
   return(res)
}
fName="G01"
d=13
lower=rep(0,d)
upper=c(rep(1,9),rep(100,3),1)
set.seed(1)
xStart<-runif(d,min=lower,max=upper)

## Initializing cobra
cobra <- cobraInit(xStart=xStart, fn=fn, fName=fName, lower=lower, upper=upper, 
                   feval=55, seqFeval=400, initDesPoints=3*d, DOSAC=1, cobraSeed=1)
                    
cobra <- startCobra(cobra)
## The true solution is at solu = c(rep(1,9),rep(3,3),1)
## where the optimum is f(solu) = optim = -15
## The solutions from SACOBRA is close to this:
print(getXbest(cobra))
print(getFbest(cobra))

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

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