diff --git a/src/Main.java b/src/Main.java index 13853e30c21d98f541a375cdaaf50a2b82ead744..d638b906cb31c5c5cbec5079e9c4d8af37846005 100644 --- a/src/Main.java +++ b/src/Main.java @@ -71,10 +71,19 @@ public class Main { // Print eq.printEq(line); - Simplex spx = new Simplex(4, 6); + // Tableau initiale + Simplex spx = new Simplex(5, 6); spx.createMatEcart(eq); + + // true = phase 1 | false = phase 2 + if (spx.which_phase()) + spx.tabAux(); + else + spx.pivot(); + spx.printSimplex(); + sc.close(); } catch (FileNotFoundException e) { throw new RuntimeException(e); diff --git a/src/Simplex.java b/src/Simplex.java index 1d37d1c0e1aa882757208e5d9ff9dc4f7e796a10..299708937700abcb5bbb24802d84852907639e85 100644 --- a/src/Simplex.java +++ b/src/Simplex.java @@ -59,12 +59,13 @@ public class Simplex { void createMatEcart(Equation eq) { int nbContraintes = eq.getNbContraintes(); // Matrice Amxn - for (int i = 0; i < width; i++){ + for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { - if(j < nbContraintes) + if (j < nbContraintes) { setMatEcartById(eq.getMatAtId(i, j), i, j); - else + } else { setMatEcartById(j - nbContraintes == i ? 1.0 : 0.0, i, j); + } } } @@ -79,4 +80,28 @@ public class Simplex { // overwrite la mat en bas à droite qui est à 1 setMatEcartById(0.0, width - 1, height - 1); } + + /** + * Si b[i] < 0 phase 1 sinon phase 2 + * @return true = phase 1 | false = phase 2 + */ + boolean which_phase(){ + boolean res = true; + for (int i = 0; i < width; i++) { + if(!signe(matEcart[i][height - 1])) + res = false; + } + return res; + } + void tabAux() { + + } + + void pivot() { + + } + + boolean signe(Double x) { + return x >= 0; + } } diff --git a/src/input.txt b/src/input.txt index 0bb445b34ba962d8a539fbc46738355fc040f3f5..4c90baaac063aca87de55daa708b9b47ee004413 100644 --- a/src/input.txt +++ b/src/input.txt @@ -1,4 +1,5 @@ max;8;9; 2;5;<=;12; 50;5;<=;150; -5;50;<=;100; \ No newline at end of file +5;50;<=;100; +-1;-1000;<=;-1; \ No newline at end of file