迭代器异常

时间:2016-08-26 20:12:01

标签: c++ cgal

我需要通过迭代器指定问题来使用CGAL解决一些二次程序。下面是一个运行良好的虚拟示例(问题是不可行的)。问题是当我将约束更改为“> =”时:

std::array<CGAL::Comparison_result, numAConstraints> relationships 
              = { CGAL::LARGER,CGAL::LARGER,CGAL::LARGER,CGAL::LARGER, };

然后我得到: “基础 - 反向检查:失败(行= 0 | col = 1)”,来自qp_solver_imp.h第1155行。

这是在没有崩溃的情况下运行的示例代码,所有约束都是“&lt; =”:

#include "stdafx.h"
#include <array>
#include <iterator>
#include <vector>
#include <CGAL/basic.h>
#include <CGAL/QP_models.h>
#include <CGAL/QP_functions.h>
#include <CGAL/MP_Float.h>
typedef double ET;

int main(){
    const int numAConstraints = 4;
    const int numVariables = 3;
    typedef CGAL::Quadratic_program_from_iterators
    <double**,  // for A
     double*, // for b
    std::array<CGAL::Comparison_result, numAConstraints>::const_iterator, // for r
    bool*,    // for fl
    double*,   // for l
    bool*,    // for fu
    double*,   // for u
    double**,  // for D
    double*>  // for c 
    Program;
typedef CGAL::Quadratic_program_solution<ET> Solution;

    double  Ax[] = { 1, -1, -1, 1 };      // column for x
    double  Ay[] = { -2, -2, 2, -1 };  
    double  Az[] = { 1, 0.0, -5, 5 };   
    double*  A[] = { Ax, Ay, Az };        // A comes columnwise
    double   b[] = { -2.4, -6, -2, 1.0 };  // right-hand side
    std::array<CGAL::Comparison_result, numAConstraints> relationships 
              = { CGAL::SMALLER,CGAL::SMALLER,CGAL::SMALLER, CGAL::SMALLER }; 
    bool fl[] = { true, true, true };    // both x, y are lower-bounded
    double   l[] = { 0, 0, 0 };
    bool fu[] = { false, false, false };    // only y is upper-bounded
    double   u[] = { 0, 0, 0 };            // x's u-entry is ignored
    double  D1[] = { 1 };                // 2D_{1,1}
    double  D2[] = { 0, 0.1 }; 
    double  D3[] = { 10, 0.0, 100.0 };   
    double*  D[] = { D1, D2, D3 };        // D-entries on/below diagonal ROWISE
    double   c[] = { -200, -5, -25 };
    double  c0 = 64;                

    Program qp(numVariables, numAConstraints, A, b, relationships.begin(), fl, l, fu, u, D, c, c0);
    // solve the program, using ET as the exact type
    Solution s = CGAL::solve_quadratic_program(qp, ET());
    std::cout << s;
    return 0;
}

0 个答案:

没有答案