Questions tagged [quadprog]

quadprog is a library for solving quadratic programming optimization problems. Implementations exist in several languages, including R and MATLAB.

A quadratic program is a type of numerical optimization problem. In a quadratic program, the task is to minimize a quadratic function subject to a series of linear constraints. Famous applications of quadratic programming include portfolio optimization and computing the support vector machine classifier.

Efficient methods for solving quadratic programs have been known for many years (for example, the Goldfarb-Idnani technique). There are excellent open source implementations of quadratic programming solvers in several languages. Popular quadprog libraries including R quadprog, MATLAB quadprog and C++ quadprog++ which are specialized for solving quadratic programs. Some general numerical optimization frameworks (e.g. CVXOPT) also include methods for solving quadratic programs.

The quadprog tag should be used for questions related to solving quadratic programs using a library with the name quadprog. For other libraries and more general questions about quadratic programming, the quadratic-programming tag may be more appropriate.

90 questions
1
vote
2 answers

dependency 'quadprog' is not available for installing package 'bfast'

i am trying to install the package "bfast" in R studio running R 3.5.3 and it throws up dependency error Warning in install.packages : dependency ‘quadprog’ is not available i tried installing it using install.packages("bfast") and when i received…
Rehan
  • 371
  • 1
  • 6
  • 29
1
vote
1 answer

Octave: quadprog index issue?

I am trying to run several files of code for an assignment. I am trying to solve an optimization problem using the "quadprog" function from the "optim" package. quadprog is supposed to solve the optimization problem in a certain format and takes…
Merry
  • 215
  • 2
  • 7
1
vote
1 answer

ROI package doesn't give a solution (qpoases solver) for an unconstrained QP

I'm setting up a simple QP to test the ROI R package. However, the package isn't able to give a wrong solution to a simple toy problem when it is unconstrained. Example, # Maximize -1/2 x^2 + x, no constraints > x <- OP(Q_objective(as.matrix(-1),…
1
vote
0 answers

weights constraints in minimum variance optimization

I should minimize the variance wƩw, subject to 3 constraints. I want no short selling (w_i >= 0), and I want an equally weighted portfolio (w_i=w_j). min wƩw w s.t. w_i >= 0 for all i sum(w) = 1 w_i= 1/n # where n is the number of assets…
Rfun2018
  • 57
  • 4
1
vote
0 answers

How to stop quadprog when Hessian is not symmetric?

I am trying to solve a quadratic optimization problem using the MATLAB's function quadprog. Actually I am trying to solve many (not one) quadratic optimization problems in series utilizing a for loop, where each qp depends on the results of the…
ASK22
  • 43
  • 5
1
vote
0 answers

Quadprog violating constraint

Hello I am trying to solve a quadratic constrained optimization problem using Quadprog package in R. However the non negativity constraint is getting violated library(quadprog) options(scipen=999) A=c(0,0,0,0) Amat=cbind(diag(1, length(A)), rep(1,…
1
vote
1 answer

Portfolio optimization with quadprog for specific returns results in "constraints are inconsistent, no solution"

I read some posts about portfolio optimization with quadprog and i learned many tricks from this platform. Now i am trying to optimize a portfolio of 03 stocks with quadprog under the constrains i.e.,. Weights must sum to 1 No short…
1
vote
1 answer

How to allow for weights between -1 and 1 using constraints in Aeq x <= beq

I am using quadprog to find a portfolio of optimal weights. So far, I have managed to implement long-only and short-only constraints as follows: FirstDegree = zeros(NumAssets,1); SecondDegree = Covariance; Long only Aeq …
WJA
  • 6,676
  • 16
  • 85
  • 152
1
vote
1 answer

How to define a negative constraint only in Aeq * X <= Beq

I am using quadprog link to find a portfolio of optimal weights. So far, I have managed to implement a long only constraint (i.e. weights cannot be smaller than zero w >= 0 and w1 + w2 + ... wN = 1) as follows: FirstDegree =…
WJA
  • 6,676
  • 16
  • 85
  • 152
1
vote
0 answers

Constrained Profit Maximization with Volume-dependent Production Cost

I am trying to maximize hourly profits from a power generation asset. As far as I understood from my research, I might use quadprog::solve.QP. I did most of the required data preparation already giving me a 96 x 5 data frame. The columns include…
T. Wolf
  • 111
  • 1
  • 6
1
vote
1 answer

R - solve.QP.compact - Constraints are Inconsistent

I'm trying to use solve.QP.compact to solve my quadratic problem under linear constraint. The function to minimize can be written as Beta Dmat Beta with Beta representing convex coefficients that should be positive (Beta > 0 and sum of the beta =…
user1595929
  • 1,284
  • 3
  • 13
  • 23
1
vote
1 answer

SCIP Mixed Integer Quadratic Programming using

I want to use SCIP included in my source code (C++) to solve a MIQP and did not find how to do it besides this FAQ entry: Nonlinear objective functions are not supported by SCIP and must be modeled as constraint function. Note, that the support for…
herculanodavi
  • 228
  • 2
  • 12
1
vote
1 answer

r solve.QP: constraints are inconsistent, no solution

I am trying to find the global minimum of this problem and I cannot figure out why I am getting the error above. I am trying to set 5 of the assets equal to the exact weights and optimize the other 5 within a range of values. I would prefer not to…
user3390169
  • 1,015
  • 1
  • 11
  • 34
1
vote
1 answer

How to solve a portfolio optimization with a generalised objective function?

I have a portfolio of 5 stocks for which I want to find an optimal mix of minimizing portfolio variance and maximizing expected future dividends. The latter is from analysts forecasts. My problem is that I know how to solve an minimum variance…
fuji2015
  • 331
  • 1
  • 6
  • 15
1
vote
2 answers

Solve Constrained Quadratic Programming with R

I really love R but from time to time it really gives me a headache... I have the following simple quadratic minimization problem which can be formulated and solved within no time in Excel (click on picture to enlarge): and The problem itself is…
vonjd
  • 4,202
  • 3
  • 44
  • 68