在C ++中有一个二次编程库吗? [英] Is there a quadratic programming library in C++?

查看:127
本文介绍了在C ++中有一个二次编程库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现的唯一的Google搜索结果是QuadProg ++,但它不能解决矩阵不适用于Cholesky分解的二次规划问题。

The only Google search result I found is QuadProg++ but it can not solve the quadratic programming problem whose matrix is not applicable for Cholesky decomposition.

任何人都可以给我一些建议对其他图书馆?感谢。

So can anyone give me some suggestion on other library? Thanks.

推荐答案

CGAL 看起来非常适合二次规划。甚至还有手册

CGAL looks great for quadratic programming. There is even a manual.

  // by default, we have a nonnegative QP with Ax <= b
  Program qp (CGAL::SMALLER, true, 0, false, 0); 

  // now set the non-default entries: 
  const int X = 0; 
  const int Y = 1;
  qp.set_a(X, 0,  1); qp.set_a(Y, 0, 1); qp.set_b(0, 7);  //  x + y  <= 7
  qp.set_a(X, 1, -1); qp.set_a(Y, 1, 2); qp.set_b(1, 4);  // -x + 2y <= 4
  qp.set_u(Y, true, 4);                                   //       y <= 4
  qp.set_d(X, X, 2); qp.set_d (Y, Y, 8); // !!specify 2D!!    x^2 + 4 y^2
  qp.set_c(Y, -32);                                       // -32y
  qp.set_c0(64);                                          // +64

  // solve the program, using ET as the exact type
  Solution s = CGAL::solve_quadratic_program(qp, ET());
  assert (s.solves_quadratic_program(qp));

第一个例子

这篇关于在C ++中有一个二次编程库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆