Hello Folks,

I am using "nloptr" optimizer in my program as below.

my.data.var <- c(10,0.25,0.25,0.25,0.25,0.25,
                 10,0.25,0.25,0.25,0.25,0.25,
                 10,0.25,0.25,0.25,0.25,0.25,
                 10,0.25,0.25,0.25,0.25,0.25)

#Option for non-linear optimization algorithm NLOPTR
opts = list("algorithm"="NLOPT_LN_COBYLA",
            "xtol_rel"=1.0e-6, "maxeval"= 10000)
lb = vector("numeric",length= length(my.data.var))

#NLOPT_LN_COBYLA

result <- nloptr(my.data.var,eval_f = Error.func,lb=lb,
                 ub =
c(Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1),eval_g_ineq=constraint.func,
                 opts = opts)

As you can see, I have to explicitly define the "upper bound: ub" as a
long vector in this scenario.

In another case, the number of variables "my.data.var" (24 in the
above example) can go up to 100 and hence. the "upper bound" needs to
be modified. I would like to avoid writing that explicilty in the
"ub".

How can I dynamically do it ?  I am out of ideas here.

Thanks for the help.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to