package com.imsl.test.example.math; import com.imsl.math.*; /** *
* Solves a linear programming problem. *
* ** The linear programming problem is given as: * * $${\rm {min}} \,\, f(x) = -x_1 - 3x_2$$ *
** subject to: *
* *
* \(x_1 + x_2 + x_3 = 1.5\)
* \(x_1 + x_2 - x_4 = 0.5\)
* \(x_1 + x_5 = 1.0\)
* \(x_2 + x_6 = 1.0\)
* \(x_i \ge 0, \,\,\,\, {\rm {for}} \,\,\, i = 1, \ldots , 6\)
* is solved.
* * @see Code * @see Output * * @deprecatedLinearProgramming
class has been deprecated.
*/
public class LinearProgrammingEx1 {
public static void main(String args[]) throws Exception {
double[][] a = {
{1.0, 1.0, 1.0, 0.0, 0.0, 0.0},
{1.0, 1.0, 0.0, -1.0, 0.0, 0.0},
{1.0, 0.0, 0.0, 0.0, 1.0, 0.0},
{0.0, 1.0, 0.0, 0.0, 0.0, 1.0}
};
double[] b = {1.5, 0.5, 1.0, 1.0};
double[] c = {-1.0, -3.0, 0.0, 0.0, 0.0, 0.0};
LinearProgramming zf = new LinearProgramming(a, b, c);
zf.solve();
new PrintMatrix("Solution").print(zf.getPrimalSolution());
}
}