CGAL Quadratic Programming Solver, how to enter "x^4" in objective function? and in the constraints?

StackOverflow https://stackoverflow.com/questions/13517203

  •  01-12-2021
  •  | 
  •  

Question

I am trying to minimize a function like the following:

a*x^4+b*y

and constraints like:

x^2 <= a

in CGAL::Quadratic_program.

To input "x^2" in the objective function I can do the following:

qp.set_d(X, X, 2);

but what about "x^4" ?

To add a constraint like "x<=a":

hp.set_a(X, 0, 1);
hp.set_b(0, a);

but what about "x^2 <= a" ?

Was it helpful?

Solution

The solution to solve this

enter image description here

kind of problems is to modify the objective function and constraints, in this case by setting z^2 = z.

        //>=
        Program hp(CGAL::LARGER, false, 0, false, 0);
        //x+y >= -4
        hp.set_a(X, 0, 1); hp.set_a(Y, 0, 1);
        hp.set_b(0, -4);
        //4x+2y+z^2 >= -a*b
        //z^2 = z
        hp.set_a(X, 1, 4); hp.set_a(Y, 1, 2); hp.set_a(Z, 1, 1);
        hp.set_b(1, -a * b);
        //-x + y >= −1
        hp.set_a(X, 2, -1); hp.set_a(Y, 2, 1);
        hp.set_b(2, -1);
        //x <= 0
        hp.set_a(X,3,1);
        hp.set_b(3,0);
        hp.set_r(3,CGAL::SMALLER);
        //y <= 0
        hp.set_a(Y,4,1);
        hp.set_b(4,0);
        hp.set_r(4,CGAL::SMALLER);
        //objective function
        //min a*x^2 + b*y + z^4
        //z^2 = z
        //min a*x^2 + b*y + z^2
        hp.set_d(X, X, 2 * a); //2D
        hp.set_c(Y, b);
        hp.set_d(Z, Z, 2); //2D

        // solve the program
        Solution s = CGAL::solve_quadratic_program(hp, ET());
        assert(s.solves_quadratic_program(hp));

OTHER TIPS

From the given link:

This package lets you solve convex quadratic programs of the general form ...

Why did you decide you can use quadratic solver to solve your power-of-four polynomial? Quadratic doesn't stand for "quadra" as a "four", it stands for a square as a "quadragon" and means power-of-two.

In short: you cannot use this tool to solve your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top