package com.imsl.test.example.math; import com.imsl.math.*; /** *

* Solves a quadratic programming problem with equality constraints.

* *

* The quadratic programming problem is to minimize

*

* $$x_0^2 + x_1^2 + x_2^2$$

*

* subject to

*

* $$x_0 + 2x_1 - x_2 = 4$$

*

* $$x_0 - x_1 + x_2 = -2$$

* * * @see Code * @see Output */ public class QuadraticProgrammingEx2 { public static void main(String args[]) throws Exception { double h[][] = { {2, 0, 0}, {0, 2, 0}, {0, 0, 2} }; double aeq[][] = {{1, 2, -1}, {1, -1, 1}}; double beq[] = {4, -2}; double g[] = {0, 0, 0}; QuadraticProgramming qp = new QuadraticProgramming(h, g, aeq, beq, null, null); // Print the solution and its dual new PrintMatrix("x").print(qp.getSolution()); new PrintMatrix("dual").print(qp.getDual()); } }