Re: [R] Quadratic programming

2020-09-24 Thread Abby Spurdle
Before going any further, I have to check, what is: MinQuadProg qp Also, if I'm following the C++ code correctly, H, is an identity matrix. This implies the input to the C++ solver, requires the QP in a different form to the R solver. In which case, the C++ inputs and the R inputs, should be

Re: [R] Quadratic programming

2020-09-24 Thread Maija Sirkjärvi
Thank you for giving me your time! The problem is the quadratic optimization part. Something goes wrong along the way. In C++ loops run from 0 and in R they run from 1, and I've tried to take that into account. Still I'm having hard time figuring out the mistake I make, cause I get a result from

Re: [R] Quadratic programming

2020-09-23 Thread Abby Spurdle
> I'm trying to replicate a C++ code with R. Notes: (1) I'd recommend you make the code more modular. i.e. One function for initial data prep/modelling, one function for setting up and solving the QP, etc. This should be easier to debug. (However, you would probably have to do it to the C++ code

Re: [R] Quadratic programming

2020-09-22 Thread Maija Sirkjärvi
I really appreciate you helping me with this! I just don't seem to figure it out. (1) I don't know why you think bvec should be a matrix. The documentation clearly says it should be a vector (implying not a matrix). - I've written it in a form of a matrix with one row and 2*J-3 columns.

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
I was wondering if you're trying to fit a curve, subject to monotonicity/convexity constraints... If you are, this is a challenging topic, best of luck... On Tue, Sep 22, 2020 at 8:12 AM Abby Spurdle wrote: > > Hi, > > Sorry, for my rushed responses, last night. > (Shouldn't post when I'm about

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
Hi, Sorry, for my rushed responses, last night. (Shouldn't post when I'm about to log out). I haven't used the quadprog package for nearly a decade. And I was hoping that an expert using optimization in finance in economics would reply. Some comments: (1) I don't know why you think bvec should

Re: [R] Quadratic programming

2020-09-21 Thread Maija Sirkjärvi
Thank you for your response! Bvec is supposed to be a matxit. I'm following the solve.QP ( https://www.rdocumentation.org/packages/quadprog/versions/1.5-8/topics/solve.QP ). I'm not sure what would be the best way to solve a quadratic programming problem in R. ma 21. syysk. 2020 klo 13.20 Abby

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
One more thing, is bvec supposed to be a matrix? Note you may need to provide a reproducible example, for better help... On Mon, Sep 21, 2020 at 10:09 PM Abby Spurdle wrote: > > Sorry, ignore the last part. > What I should have said, is the inequality has the opposite sign. > >= bvec (not <=

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
Sorry, ignore the last part. What I should have said, is the inequality has the opposite sign. >= bvec (not <= bvec) On Mon, Sep 21, 2020 at 10:05 PM Abby Spurdle wrote: > > Are you using the quadprog package? > If I can take a random shot in the dark, should bvec be -bvec? > > > On Mon, Sep

Re: [R] Quadratic programming

2020-09-21 Thread Abby Spurdle
Are you using the quadprog package? If I can take a random shot in the dark, should bvec be -bvec? On Mon, Sep 21, 2020 at 9:28 PM Maija Sirkjärvi wrote: > > Hi! > > I was wondering if someone could help me out. I'm minimizing a following > function: > > \begin{equation} >

Re: [R] Quadratic programming

2015-07-19 Thread Duncan Murdoch
On 19/07/2015 4:58 PM, Preetam Pal wrote: Hi, If i have a quadratic objective function with a system of linear constraints for multiple variables, is there any inbuilt function that i can use? Google says the quadprog package should help. Duncan Murdoch

Re: [R] QUADRATIC PROGRAMMING

2012-07-24 Thread Michael Weylandt
We don't do homework on this list: also, this is basic calculus, not quadratic programming. Best, Michael On Jul 24, 2012, at 1:10 PM, Joel Muli joe...@yahoo.com wrote: hi, what code in R would I use to solve the problem below? An apartment complex has 250 apartments to rent.If they rent

Re: [R] quadratic programming-maximization instead of

2012-01-04 Thread Ravi Varadhan
Maximizing f(x) = x'Ax makes sense only when A is negative-definite. Therefore, this is the same as minimizing x'Bx, where B = -A, and B is positive-definite. In other words, you should be able to simply flip the sign of the original matrix . This should yield a positive-definite matrix

Re: [R] quadratic programming-maximization instead of minization

2012-01-03 Thread Tsjerk Wassenaar
Hi Riccardo, Would it be possible to use max(diag(D))*diag(ncol(D)) - D ? That also reverses the order of eigenvalues/-vectors. Cheers, Tsjerk On Jan 2, 2012 4:35 PM, riccardo24 riccardo.giacome...@gmail.com wrote: Hi, I need to maximize a quadratic function under constraints in R. For

Re: [R] quadratic programming-maximization instead of minization

2012-01-03 Thread Tsjerk Wassenaar
Sorry, that should've been sum(diag(D)) or max(eigen(D)$values) in stead of max(diag(D)). Tsjerk On Jan 3, 2012 4:52 PM, Tsjerk Wassenaar tsje...@gmail.com wrote: Hi Riccardo, Would it be possible to use max(diag(D))*diag(ncol(D)) - D ? That also reverses the order of eigenvalues/-vectors.

Re: [R] quadratic programming-maximization instead of minization

2012-01-02 Thread Ken Hutchison
I don't have experience with this in R and I'm not sure I understand the question that well but maybe something like nearPD()? Ken Hutchison On Jan 2, 2012, at 6:36 AM, riccardo24 riccardo.giacome...@gmail.com wrote: Hi, I need to maximize a quadratic function under constraints in R. For

Re: [R] Quadratic programming with semi-definite matrix

2010-12-06 Thread Hans W Borchers
Andreas Jensen bentrevisor at gmail.com writes: Hello. I'm trying to solve a quadratic programming problem of the form min ||Hx - y||^2 s.t. x = 0 and x = t using solve.QP in the quadprog package but I'm having problems with Dmat not being positive definite, which is kinda okay since I

Re: [R] quadratic programming

2009-05-04 Thread Stephan Kolassa
Hi, The CRAN Task View on Optimization may help: http://stat.ethz.ch/CRAN/web/views/Optimization.html HTH, Stephan barbara.r...@uniroma1.it schrieb: Devo risolvere un problema di minimo vincolato con vincoli di uguaglianza e un altro con vincoli di uguaglianza e disuguaglianza. Cosa posso

Re: [R] Quadratic Programming

2008-02-15 Thread Berwin A Turlach
G'day Jorge, On Fri, 15 Feb 2008 17:51:16 -0500 Jorge Aseff [EMAIL PROTECTED] wrote: I am using solve.QP (from quadprog) to solve a standard quadratic programming problem: min_w -0.5*w'Qw st ... I would like solve.QP to do two things: 1) to start the optimization from a user-supplied initial

Re: [R] Quadratic programming

2007-12-05 Thread Berwin A Turlach
G'day Serge, On Wed, 5 Dec 2007 11:25:41 +0100 de Gosson de Varennes Serge (4100) [EMAIL PROTECTED] wrote: I am using the quadprog package and its solve.QP routine to solve and quadratic programming problem with inconsistent constraints, which obviously doesn't work since the constraint