constrOptim() can do linear and quadratic programming problems! See the following example from the help document. ## Solves linear and quadratic programming problems ## but needs a feasible starting value # # from example(solve.QP) in 'quadprog' # no derivative fQP <- function(b) {-sum(c(0,5,0)*b)+0.5*sum(b*b)} Amat <- matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3) bvec <- c(-8,2,0) constrOptim(c(2,-1,-1), fQP, NULL, ui=t(Amat),ci=bvec) # derivative gQP <- function(b) {-c(0,5,0)+b} constrOptim(c(2,-1,-1), fQP, gQP, ui=t(Amat), ci=bvec) ## Now with maximisation instead of minimisation hQP <- function(b) {sum(c(0,5,0)*b)-0.5*sum(b*b)} constrOptim(c(2,-1,-1), hQP, NULL, ui=t(Amat), ci=bvec, control=list(fnscale=-1))
-- View this message in context: http://r.789695.n4.nabble.com/constrained-optimization-which-package-tp2717677p2718136.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list 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.