package com.imsl.test.example.math; import com.imsl.math.*; /** *
* Solves a linear programming problem in a nonstandard form. *
* This examples solves the same problem as example {@link LinearProgrammingEx2} * expressed in a nonstandard form. The linear programming problem $${\rm {min}} * \,\, f(x) = -x_1 - 3x_2$$ ** subject to:
*\(0.5 \le x_1 + x_2 \le 1.5\)
* \(0 \le x_1 \le 1.0\)
* \(0 \le x_2 \le 1.0\)
* is solved.
* * @see Code * @see Output * * @deprecatedLinearProgramming
class has been deprecated.
*/
public class LinearProgrammingEx2 {
public static void main(String args[]) throws Exception {
int[] constraintType = {3};
double[] upperBound = {1.0, 1.0};
double[][] a = {{1.0, 1.0}};
double[] b = {0.5};
double[] upperLimit = {1.5};
double[] c = {-1.0, -3.0};
LinearProgramming zf = new LinearProgramming(a, b, c);
zf.setUpperLimit(upperLimit);
zf.setConstraintType(constraintType);
zf.setUpperBound(upperBound);
zf.solve();
new PrintMatrix("Solution").print(zf.getPrimalSolution());
new PrintMatrix("Dual Solution").print(zf.getDualSolution());
System.out.println("Optimal Value = " + zf.getOptimalValue());
}
}