0

I've created a simplex method solver, but at the end I need check the final table for negative values and rerun the solver if it returns negatives. I've made a for loop but for some reason it outputs the original array and doesn't even solve that.

The following is my for loop to check for any negative values in the final row:

for (i = 0; i < nColumns; i++) {
        if (table[objectfunct][i] < 0) {
            System.out.println("Need to continue pivoting");
            new Lab_09();
        } else {
            System.out.println("You've solved it");
            System.exit(0);
        }
    }

The output for the array is recursive, but doesn't do anything with the [-1.33...] array. :

Need to continue pivoting
[1.0, 1.0, 1.0, 0.0, 4.0]
[1.0, 3.0, 0.0, 1.0, 6.0]
[-3.0, -5.0, 0.0, 0.0, 0.0]
pivot column: 1
[0.6666666666666667, 0.0, 1.0, -0.3333333333333333, 2.0]
[0.3333333333333333, 1.0, 0.0, 0.3333333333333333, 2.0]
[-1.3333333333333335, 0.0, 0.0, 1.6666666666666665, 10.0]
Need to continue pivoting
[1.0, 1.0, 1.0, 0.0, 4.0]
[1.0, 3.0, 0.0, 1.0, 6.0]
[-3.0, -5.0, 0.0, 0.0, 0.0]
pivot column: 1
[0.6666666666666667, 0.0, 1.0, -0.3333333333333333, 2.0]
[0.3333333333333333, 1.0, 0.0, 0.3333333333333333, 2.0]
[-1.3333333333333335, 0.0, 0.0, 1.6666666666666665, 10.0]

I don't know if the rest of my function is needed. But I can attach it if needed.

  • What is that `new Lab_09()` doing in your `for` loop? – Norsk Apr 15 '16 at 04:03
  • @Norsk It's the function that the for loop is living in. Ideally once the for loop identifies a negative value in the table[objectionfunct][i] it will rerun the entire process with the current table, but instead runs the original table. The following link is the `Lab_09();` function [http://collabedit.com/vv35g]. The for loop lives with this as well. – Silvia Fuen Apr 18 '16 at 03:04

0 Answers0