0

The function of quadprog looks like that: solve.QP(Dmat, dvec, Amat, bvec, meq=0, factorized=FALSE)

My objective function is:

And my two constraints are:

Now my aim is to determine the single arguments.

1) First argument Dmat:

In the generel notation is:

Calculation matrix D which is Dmat:

And because D is symmetric, the solution is

2) Second argument dvec: The linear part of the objective function

3) Third argument Amat: This is the left-hand-side of the constraints

4) Forth argument bvec: This is the right-hand-side of the constraints

5) Fifth argument meq is zero because of only inequality constraints

6) Sixth argument factorized: see question

And now I have to put these six arguments in the function solve.QP(). But here I'm sure that there's a need of further "transformation"...

  • When you look at the package description the quadratic part is multiplied by 0.5 and the linear part is negativ

  • Also the constraints are differently defined - >= sign

Questions:

  1. How must I "transform" the first four arguments of solve.QP()
  2. What does the last argument factorized affect
  3. How can I maximize the function solve.QP()

Many thanks in advance!

Edit: I have done now my "transformation" like suggested in the link from G. Grothendieck - I hope I have done everything right?!

enter image description here

And when I change the argument factorized=TRUE then I get my expected solution with x1=2 and x2=4.

enter image description here

In the help a R^-1 is mentioned. But sadly I have no clue what that means... Any hints appreciated.

enter image description here

tueftla
  • 369
  • 1
  • 3
  • 16
  • 2
    There is an example at the bottom of the ?solve.QP page. There are also some examples here http://www.fsb.miamioh.edu/lij14/400_slide_qp.pdf and there are other quadratic optimization functions in R packages listed here https://cran.r-project.org/web/views/Optimization.html – G. Grothendieck Jun 09 '21 at 22:44
  • @G.Grothendieck: I added an edit to my post. Is it possible to check it?! That would be awesome... and I think maximize a QP isn't possible at all?! And can you also please give me a hint to the argument `factorized`? Tahnks a lot! – tueftla Jun 10 '21 at 08:06
  • @G. Grothendieck: An additionally question: How is it possible to restrict the range of an variable and add that to the matrix Amat? I mean something like `2<=x1<=12`. Is it possible with `quadprog::solve.QP`? – tueftla Jun 10 '21 at 12:16
  • If the documentation I have already pointed to is insufficient, and it does look ambiguous to me, just don't use solve.QP and use a different one from the Optimization Task View. – G. Grothendieck Jun 10 '21 at 12:39
  • @G.Grothendieck: And which solver can you suggest? – tueftla Jun 10 '21 at 13:02
  • @G.Grothendieck: And when the convex problem becomes larger? – tueftla Jun 10 '21 at 13:11

0 Answers0