Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGAL::solve_quadratic_program falls into an infinite loop #8296

Open
qwerty10086 opened this issue Jun 20, 2024 · 0 comments
Open

CGAL::solve_quadratic_program falls into an infinite loop #8296

qwerty10086 opened this issue Jun 20, 2024 · 0 comments

Comments

@qwerty10086
Copy link

qwerty10086 commented Jun 20, 2024

Issue Details

CGAL::solve_quadratic_program falls into an infinite loop when solving a QP, and CGAL::QP_BLAND doesn't help. The code is as follows. If I don't set the bounds of variables, Solution.status() will return unbounded. I'm not sure if this is related to the error.

Source Code

#include <iostream>
#include <CGAL/QP_functions.h>
#include <CGAL/Gmpz.h>

double asDouble(uint64_t vNum)
{
    return *((double*)&vNum);
}

int main()
{
    uint64_t RawMatrixD[3][3] =
    {
        {0x3f7eaa3603f152ce},
        {0xbfc066eaeb06439b,0x4004a227d8c1ebe2},
        {0x3fab5441711b0d76,0xbff05c9bedd40fa2,0x3fda741861e0dba0}
    };
    uint64_t RawVectorC[3] = { 0x3fdd373719889d74,0xc01907af0ffd00a0,0x40073fe9cd265d35 };
    uint64_t RawLower[3] = { 0xc0257ef04e41147c,0xc022cf45ae85fe84,0xc0373b807ab20626 };
    uint64_t RawUpper[3] = { 0xc0239ea83194a030,0xc020eefd91d98a38,0xc0364b5c6c5bcc00 };

    double MatrixD[3][3], VectorC[3], Lower[3], Upper[3];
    for (size_t i = 0; i < 3; ++i)
    {
        for (size_t k = 0; k < 3; ++k)
            MatrixD[i][k] = asDouble(RawMatrixD[i][k]);
        VectorC[i] = asDouble(RawVectorC[i]);
        Lower[i] = asDouble(RawLower[i]);
        Upper[i] = asDouble(RawUpper[i]);
    }

    std::cout << MatrixD[0][0] << std::endl;
    std::cout << MatrixD[1][0] << "  " << MatrixD[1][1] << std::endl;
    std::cout << MatrixD[2][0] << "  " << MatrixD[2][1] << "  " << MatrixD[2][2] << std::endl;
    std::cout << std::endl;
    std::cout << VectorC[0] << "  " << VectorC[1] << "  " << VectorC[2] << std::endl;
    std::cout << std::endl;
    std::cout << Lower[0] << "  " << Lower[1] << "  " << Lower[2] << std::endl;
    std::cout << std::endl;
    std::cout << Upper[0] << "  " << Upper[1] << "  " << Upper[2] << std::endl;
    std::cout << std::endl;

    CGAL::Quadratic_program<double> Qp(CGAL::SMALLER, false, 0.0, false, 0.0);

    Qp.set_d(0, 0, MatrixD[0][0]);
    Qp.set_d(1, 0, MatrixD[1][0]); Qp.set_d(1, 1, MatrixD[1][1]);
    Qp.set_d(2, 0, MatrixD[2][0]); Qp.set_d(2, 1, MatrixD[2][1]); Qp.set_d(2, 2, MatrixD[2][2]);

    Qp.set_c(0, VectorC[0]); Qp.set_c(1, VectorC[1]); Qp.set_c(2, VectorC[2]);

    Qp.set_l(0, true, Lower[0]); Qp.set_l(1, true, Lower[1]); Qp.set_l(2, true, Lower[2]);

    Qp.set_u(0, true, Upper[0]); Qp.set_u(1, true, Upper[1]); Qp.set_u(2, true, Upper[2]);

    CGAL::Quadratic_program_options Options;
    Options.set_verbosity(1);
    Options.set_pricing_strategy(CGAL::QP_BLAND);
    Options.set_auto_validation(true);
    auto Solution = CGAL::solve_quadratic_program(Qp, CGAL::Gmpz(), Options);

    std::cout << Solution;

    return 0;
}

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): Windows 64bits
  • Compiler: MSVC (VS2019)
  • Release or debug mode: both
  • Specific flags used (if any):
  • CGAL version: 5.5.2
  • Boost version: 1.82.0
  • Other libraries versions if used (Eigen, TBB, etc.):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants