Exemple #1
0
 public static void test(double[][] A, double[] b, double[] c) {
   Simplex lp = new Simplex(A, b, c);
   System.out.println("value = " + lp.value());
   double[] x = lp.primal();
   for (int i = 0; i < x.length; i++) System.out.println("x[" + i + "] = " + x[i]);
   double[] y = lp.dual();
   for (int j = 0; j < y.length; j++) System.out.println("y[" + j + "] = " + y[j]);
 }
Exemple #2
0
  // test client
  public static void main(String[] args) {

    try {
      test1();
    } catch (ArithmeticException e) {
      e.printStackTrace();
    }
    System.out.println("--------------------------------");

    try {
      test2();
    } catch (ArithmeticException e) {
      e.printStackTrace();
    }
    System.out.println("--------------------------------");

    try {
      test3();
    } catch (ArithmeticException e) {
      e.printStackTrace();
    }
    System.out.println("--------------------------------");

    try {
      test4();
    } catch (ArithmeticException e) {
      e.printStackTrace();
    }
    System.out.println("--------------------------------");

    int M = Integer.parseInt(args[0]);
    int N = Integer.parseInt(args[1]);
    double[] c = new double[N];
    double[] b = new double[M];
    double[][] A = new double[M][N];
    for (int j = 0; j < N; j++) c[j] = Math.random() * 1000;
    for (int i = 0; i < M; i++) b[i] = Math.random() * 1000;
    for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) A[i][j] = Math.random() * 1000;
    Simplex lp = new Simplex(A, b, c);
    System.out.println(lp.value());
  }