Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] CGAL QP solver versus Matlab quadprog()

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] CGAL QP solver versus Matlab quadprog()


Chronological Thread 
  • From: DaniCamps <>
  • To:
  • Subject: Re: [cgal-discuss] CGAL QP solver versus Matlab quadprog()
  • Date: Sun, 30 Sep 2018 09:07:35 -0500 (CDT)
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=SoftFail ; spf=Pass
  • Ironport-phdr: 9a23:7Jt7zRbd9YLbQ2hlaKK/Wkb/LSx+4OfEezUN459isYplN5qZoM29bnLW6fgltlLVR4KTs6sC17KJ9fi4EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCa/bL9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPCTQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjmk8qxlSgLniD0fOjA38G/ZlM9+g6BVoBy8qBNw34HabZqJNPd8Yq/RYc8WSXZfUstXSidPApm8b4wKD+cZM+hXtY/9p1oQoBSkAAmsHPjvwSJPi3Drx6I61eUhHh3c0wwlB9IOq3fZoMjuOacdVOC61qjIzTHZY/xK3jf97ZHFfxY8qv+CWrJwdNDeyUgpFw7diFWfs5fqMCiR1usTqWSU8+1gVeephmU6qA9xuiCiytooh4TNnI4YxFPJ+T96zYs0P9G1SU92bNi5G5VKrS6aLZF5QsY6TmFopik6zroGtIa9fCUF0pgnwQTQZOecfIiM/B3vTvqeITB9hH59ebK/gQi98VS4x+HhUsS51ExGoyRGn9XWtX0A1gbf58mGR/dl+0euwzeP1wTd6uFeJkA0kLLWJIM7zb42l5ocrV7MHirumEXtj6Kaa14p+uet6+v9Y7XmooWQOJNzigH7KqgugNCwAfwkMggSWGiW4fiz1LL58k39WblFk/w2krLFv5DHPsQbvbW0AxRV04Ym8xawFS2q0NUenXkdLVJKYgiLj4bzOwKGHPetBvi2hxGgkSxg2uvdFrznGJTEaHbZw5n7erMox0daySE6yMhEr8ZYA7cAK/v2QlSh7fTXCxY4N0q/xOOxW4Y17Z8XRW/aWvzRC6jVq1Ldvrt+cdnJX5ccvXPGE9Zg4vfviXEjnlpEJPum2JIWbDazGfE0eBzFM0qpuc8IFCIxhiR7VPbj0QTQXjtaZnL0VKU5tGliVdCWSLzbT4Xou4SvmSe2GpoPOzJAVhaKGH3ic4jCUPAJOnuf

Hi,

After some tweaking I get now the following result:

status: OPTIMAL
objective value: -1.27827e-26/2.71051e-24
variable values:
0: 0/1
1: 6e-05/0.0001
2: 1.35525e-20/1.35525e-20
3: 4e-05/0.0001

It turns out that the objective value is correct (the same I get through
Matlab), i.e. -0.00471, but the variable values are wrong. In fact if you
evaluate the objective function (x'*D*x + c'*x) at the x = (0; 6e-9; 1;
4e-9) you get a value of -0.0024, not corresponding to the optimal one.
Instead the solution delivered by Matlab quadprog() does correspond to the
optimal value of the cost function.

Any help is appreciated.

BR

Daniel

PS: I post here my program

// example: construct a quadratic program from data
// the QP below is the first quadratic program example in the user manual
#include <iostream>
#include <cassert>
#include <CGAL/basic.h>
#include <CGAL/QP_models.h>
#include <CGAL/QP_functions.h>

// choose exact integral type
#ifdef CGAL_USE_GMP
#include <CGAL/Gmpzf.h>
typedef CGAL::Gmpzf ET;
#else
#include <CGAL/MP_Float.h>
typedef CGAL::MP_Float ET;
#endif

// program and solution types
typedef CGAL::Quadratic_program<double> Program;
typedef CGAL::Quadratic_program_solution<ET> Solution;

int main() {
// by default, we have a nonnegative QP with Ax <= b
Program qp (CGAL::EQUAL, true, 0, true, 0);

//Setting matrix A
qp.set_a(0,0,1);
qp.set_a(1,0,0);
qp.set_a(2,0,1);
qp.set_a(3,0,0);
qp.set_a(0,1,0);
qp.set_a(1,1,1);
qp.set_a(2,1,0);
qp.set_a(3,1,1);

//Setting constraints vector b
qp.set_b(0,1);
qp.set_b(1,1);

// Setting matrix D
qp.set_d(0,0,0.00005);
qp.set_d(1,0,0.00005);
qp.set_d(1,1,0.00005);
qp.set_d(2,0,0);
qp.set_d(2,1,0);
qp.set_d(2,2,0.00005);
qp.set_d(3,0,0);
qp.set_d(3,1,0);
qp.set_d(3,2,0.00005);
qp.set_d(3,3,0.00005);

//Setting vector c
qp.set_c(0,-0.002359);
qp.set_c(1,-0.002359);
qp.set_c(2,-0.002399);
qp.set_c(3,-0.002399);

//Setting upper bounds
qp.set_u(0, true, 0.914808);
qp.set_u(1, true, 0.933087);
qp.set_u(2, true, 1.061726);
qp.set_u(3, true, 1.028364);

//Setting lower bounds
qp.set_l(0, true, 0);
qp.set_l(1, true, 0);
qp.set_l(2, true, 0);
qp.set_l(3, true, 0);

//Setting euality constraints
qp.set_r(0, CGAL::EQUAL);
qp.set_r(1, CGAL::EQUAL);


Solution s = CGAL::solve_quadratic_program(qp, ET());
assert (s.solves_quadratic_program(qp));

// output solution
std::cout << s;
return 0;
}




--
Sent from: http://cgal-discuss.949826.n4.nabble.com/



Archive powered by MHonArc 2.6.18.

Top of Page