ALGLIB forum
It is currently Sun Feb 17, 2019 10:45 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.

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: QuadProg(Matlab) vs minqpsetalgodenseaul(ALGLIB)
PostPosted: Tue Dec 12, 2017 11:10 am 

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

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

min 0.5*x'*H*x + f'*x subject to: A*x <= b
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



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
 Post subject: Re: QuadProg(Matlab) vs minqpsetalgodenseaul(ALGLIB)
PostPosted: Tue Dec 12, 2017 4:21 pm 
Site Admin

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.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 5 guests

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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group