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
2
votes
3 answers

How to properly install qpsolvers for Python on Windows?

I am trying to install qpsolvers using pip. The installation goes without errors, and the module imports properly afterwards. However, qpsolvers has no available solvers for it to use : import qpsolvers print(qpsolvers.available_solvers) returns…
2
votes
1 answer

CVXPY returns Infeasible/Inaccurate on Quadratic Programming Optimization Problem

I am trying to use CVXPY to solve a nonnegative least squares problem (with the additional constraint that the sum of entries in the solution vector must equal 1). However, when I run CVXPY on this simple quadratic program using the SCS solver, I…
2
votes
0 answers

Quadratic programming maximization -- matrix not positive definite

I am trying to optimize the following simple objective function using the quadprog program in R: max_{x} x'Ax Most optimization problems I see use minimization, but if I simply use -A instead of A, I get an error that A is no longer positive…
2
votes
0 answers

Trying to simulate data while keeping correlation matrix the same and keeping time dependency

I have an asset class return stream that is incomplete. What I have done in Frontline Solver is to generate a return distribution that matches the correlations of the asset class in question to other asset classes for the maximum amount of data that…
McNewFL
  • 21
  • 3
2
votes
3 answers

Portfolio Optimisation under weight constraints

With a lot of help from contributors to StackOverflow I have managed to put together a function to derive the weights of a 2-asset portfolio which maximises the Sharpe ratio. No short sales are allowed and the sum of weights add to 1. What I would…
user3690243
  • 113
  • 1
  • 11
2
votes
0 answers

error while installing quadprog package in R for MAC

I'm trying to install the quadprog package in R in mac but it keeps showing this massage: installing source package ‘quadprog’ ... ** package ‘quadprog’ successfully unpacked and MD5 sums checked ** libs gfortran-4.8 -fPIC -g -O2 -c aind.f -o…
2
votes
2 answers

Minimizing quadratic function subject to norm inequality constraint

I am trying to solve the following inequality constraint: Given time-series data for N stocks, I am trying to construct a portfolio weight vector to minimize the variance of the returns. the objective function: min w^{T}\sum w s.t.…
2
votes
1 answer

MATLAB's quadprog is exteremely slow on my strong local machine vs another remote machine

I am using MATLAB's quadprog and it runs extremely slow on my local machine. When I run the exact code on a remote machine, it completes within 10 minutes. When I run it on my local machine, it doesn't terminates even after 24 hours (I kill it at…
Yuval Atzmon
  • 5,645
  • 3
  • 41
  • 74
2
votes
1 answer

Constrained quadratic optimization with the quadProg library

I have a vector A of length N. Also I have N*N matrix C. I want to maximize following equation : minimize (- (w_transpose * A) + p * w_transpose * C * w) Where w is a vector of length N, with constraints that each w is non-negative and sum of all w…
exAres
  • 4,806
  • 16
  • 53
  • 95
2
votes
1 answer

Mixed Integer Quadratic Programming using Opti Toolbox in MATLAB

I wish to solve a mixed integer quadratic program with linear constraints using OPTI toolbox in MATLAB. I want some of my decision variables to be continuous and some decision variables to be binary. How do I specify this?
S_S
  • 1,276
  • 4
  • 24
  • 47
2
votes
1 answer

Incompatible types in quadprog R

I am new to R and am trying to solve a QP problem using R. I keep getting the following error : Amat and dvec are incompatible. here my code: d <- 4 Fr <- as.vector(Fr) ; Aeq <- matrix(data=1, nrow=1, ncol=d) %*% U Amat <- rbind(Aeq,U); bv <-…
user1102886
  • 57
  • 2
  • 10
1
vote
0 answers

Installing/using quadprog in Python

Has anyone used quadprog in Python before? I tried installing and importing it, and it was succesful, but when I try to use it I get this message: 'module' object is not callable Installed with: pip install quadprog import quadprog
jros112
  • 151
  • 1
  • 5
1
vote
0 answers

How do I correct this Value Error due to Buffer having the wrong dimensions in a quadprog SVM implementation?

I'm using the quadprog module to set up an SVM for speech recognition. I took a QP implementation from here: https://github.com/stephane-caron/qpsolvers/blob/master/qpsolvers/quadprog_.py Here is their implementation: def quadprog_solve_qp(P, q,…
1
vote
1 answer

R minimum variance portfolio: solve non invertible matrix

I want to solve an optimization problem regarding a minimum variance portfolio using R as shortly described on this website: http://enricoschumann.net/R/minvar.htm The problem is: the matrix I want to use has more columns (=assets) than rows…
1
vote
0 answers

Mpmath : quadprog or lsei equivalent?

I want to solve a quadratic program with mpmath precision. The problem can be stated as a least square with linear equality and inequality constraints, or as quadratic program with linear equality and inequality constraints. I am aware of the LSEI…
lrnv
  • 1,038
  • 8
  • 19