I am new to stackoverflow and searched a lot, but could not find the answer to my question. I am trying to minimize the problem with the rsolnp optimization package. Although the solver gives me a solution, every time I run the code, the following warning message appears:
Warning messages: 1: In cbind (temp, funv): the number of lines of the result is not a multiple of the vector length (arg 1)
In addition, the solution is completely different from the solutions that I get with ipop and solve. QP. Their solutions are almost the same (0.2480, 0.0000, 0.0121, 0.7400). I tried many different formulations of the problem, but could not understand what I did wrong. I am grateful for all the help and information!
library(Rsolnp)
x0 <- c(0.25,0,0.01,0.75)
fn <- function(x){
d <- c(0.0308, 0.0269, 0.0145, 0.0130)
d <- -d
D <- cbind(c(0.1486, 0.0778, -0.0240, -0.0154),
c(0.0778, 0.1170, 0.0066, 0.0029),
c(-0.0240, 0.0066, 0.0444, 0.0193),
c(-0.0154, 0.0029, 0.0193, 0.0148))
out <- t(d) %*% x + 0.5 * (t(x) %*% D %*% x)
out
}
lx <- rep(0,4)
ux <- rep(1,4)
sol <- solnp(pars = x0,
fun = fn,
eqfun = sum,
eqB = 1,
ineqLB = lx,
ineqUB = ux)
sol$pars