# forum.alglib.net

ALGLIB forum
 It is currently Sun Feb 17, 2019 9:41 pm

 All times are UTC

### Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: QuadProg(Matlab) vs minqpsetalgodenseaul(ALGLIB)Posted: Tue Dec 12, 2017 11:10 am

Joined: Tue Dec 12, 2017 10:20 am
Posts: 1
Hi,
I am trying to use ALGLIB to replciate the QUADPROG functionality of MATLAB

X = quadprog(H,f,A,b) attempts to solve the quadratic programming
problem:

min 0.5*x'*H*x + f'*x subject to: A*x <= b
x
I tried to use DENSE AUL from ALGLIB solver to solve the same, but my results are way different.
Can someone please guide me as to where I might be going wrong?
I have attached following with the thread.
Matrix_A.txt The Quadratic Cost Function Data
Matrix_Constraints.txt The Constraints Matrix
main.cpp My code for The Same.

Matlab Output
0.63322,0.6999,0.76339,0.81933,0.86562,0.89764,0.91573,0.92111,0.91655,0.90413,0.88902,0.86974,0.85041,0.66259,0.73242,0.79896,0.85804,0.90604,0.9383,0.95464,0.95837,0.94988,0.93513,0.9144,0.89375,0.87154,0.68458,0.75677,0.82455,0.88545,0.9338,0.96761,0.98107,0.98419,0.97207,0.95564,0.93261,0.91005,0.88649,0.69814,0.76992,0.83835,0.89921,0.94662,0.97896,0.99621,1,0.9857,0.96377,0.94314,0.92005,0.89584,0.70335,0.773,0.83931,0.89679,0.94175,0.97553,0.98846,0.99143,0.98253,0.96533,0.94487,0.922,0.89855,0.701,0.76644,0.82871,0.88434,0.92761,0.95953,0.97384,0.97731,0.96962,0.95694,0.93693,0.91856,0.89525,0.69119,0.75288,0.81022,0.86168,0.90172,0.93079,0.94828,0.95335,0.95119,0.9394,0.92465,0.9069,0.88789,0.67827,0.73418,0.78699,0.83303,0.87095,0.90009,0.91722,0.92581,0.92378,0.91782,0.90519,0.89119,0.87501,0.6606,0.71298,0.76059,0.80342,0.83743,0.86469,0.88292,0.89307,0.89471,0.89205,0.88381,0.87271,0.86026,-5.0308e-05,-0.00011987,-0.0013769

ALGLIB Output

[-0.326426,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,-0.002436,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000505,0.003153,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000125,0.267527,1.000000,0.003153,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.018603,0.071664,0.000505,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,-0.058014,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,0.000098,-0.000009,-0.000006,0.000101]

 Attachments: File comment: MATRIX Constraints Matrix_Constraints.txt [28.47 KiB] Downloaded 171 times File comment: MATRIX A Matrix_A.txt [32.74 KiB] Downloaded 146 times File comment: CPP FILE main_ALGLIB.cpp [2.7 KiB] Downloaded 191 times
Top

 Post subject: Re: QuadProg(Matlab) vs minqpsetalgodenseaul(ALGLIB)Posted: Tue Dec 12, 2017 4:21 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 839
Hi! I looked at your problem, have two points to tell:

1. You incorrectly specified scale of the variables, it is "1, 1, ..., 1, 1, 0.01, 0.01, 0.01" instead of "1, 1, ..., 1, 1, 100, 100, 100". Incorrect scaling makes things even more difficult, although everything is already bad (see point 2 below).

2. Your problem is non-convex, i.e. it has multiple local minima. Up to 2^120 minima in the worst case, although you may hope that actual situation is somewhat better than that...

Before variable scaling, condition number of your matrix is 1E15 (degenerate), rightmost eigenvalue is 3.0E+8, leftmost one is -1.0E-4 (note that minus sign). After you apply correct scaling to the variables, you will get condition number 1E11 (ill conditioned, but not degenerate), rightmost eigenvalue 3.0E+4, leftmost eigenvalue -1.0E-4. Clearly non-convex.

I tried to solve this problem with development version of ALGLIB 3.13 (which has somewhat better QP solver than 3.12, but it does not change situation as whole) and got following result:

F=+0.000052910 - target function value at MATLAB solution

F=+0.027752449 - QP-DENSE-AUL solution with wrong scaling and rho=1.0e4
F=+0.000008414 - QP-DENSE-AUL solution with wrong scaling and rho=1.0e2
F=-0.944659861 - QP-DENSE-AUL solution with right scaling and rho=1.0e4 - winner!
F=-0.944659861 - QP-DENSE-AUL solution with right scaling and rho=1.0e2

F=+0.000000425 - QP-BLEIC solution with wrong scaling
F=-0.000006132 - QP-BLEIC solution with right scaling

You may see that depending on solver settings, different solutions are returned, some of them worse than that of MATLAB, some of them better. Does it mean that MATLAB is broken, or ALGLIB is broken? No. The task is "broken" :)

You may also see that correct scaling of variables seem to result in finding better solutions. But frankly speaking, it means nothing - with such task you can not be 100% sure that you found best solution possible.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot] and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ALGLIB forum    ALGLIB-discuss
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group