Closed Mosquito00 closed 8 years ago
Dear all,
I am trying to do a simple optimization in R and I am confused at the moment, because of the following error.
Error: solnp-->error: objective function returns value of length greater than 1!
x1 <- runif(100, 5.0, 7.5) x2 <- runif(100, 5.0, 7.5)
lb = c(0,0) ub = c(1,1)
dim_r = 2 w_e <- rep(1,dim_r)/dim_r
library(Rsolnp) fun_min_rse <- function(w) { (w_x1-(1-w)_x2)^2; return(c(w))} equals1 <- function(w) { z1 <- sum(w); return(c(z1)) }
w_min <- solnp(pars=w_e, fun=fun_min_rse, eqfun=equals1, eqB=c(1), ineqfun=NULL, ineqLB=NULL, ineqUB=NULL, LB=lb, UB=ub, control=list(tol=1e-12, trace=0))
Do you have an idea what might be wrong with the code?
Thank you.
This is a forum for asking questions about the caretEnsemble package.
stackoverflow or cross-validated are better venues for this question.
Dear all,
I am trying to do a simple optimization in R and I am confused at the moment, because of the following error.
Error: solnp-->error: objective function returns value of length greater than 1!
x1 <- runif(100, 5.0, 7.5) x2 <- runif(100, 5.0, 7.5)
lb = c(0,0) ub = c(1,1)
dim_r = 2 w_e <- rep(1,dim_r)/dim_r
library(Rsolnp) fun_min_rse <- function(w) { (w_x1-(1-w)_x2)^2; return(c(w))} equals1 <- function(w) { z1 <- sum(w); return(c(z1)) }
w_min <- solnp(pars=w_e, fun=fun_min_rse, eqfun=equals1, eqB=c(1), ineqfun=NULL, ineqLB=NULL, ineqUB=NULL, LB=lb, UB=ub, control=list(tol=1e-12, trace=0))
Do you have an idea what might be wrong with the code?
Thank you.