diff --git a/src/Main.java b/src/Main.java index 0c406da51d9f15fd9f0d4c633107376a1aafb6ee..676675f434e1139b21f2f6f090d645dcd7c2cc83 100644 --- a/src/Main.java +++ b/src/Main.java @@ -44,7 +44,7 @@ public class Main { System.out.println("Entrez le nom du fichier à tester, il doit se situer dans le dossier src."); //String nameFile = readFile.nextLine(); String nameFile = "network1.txt"; - //String nameFile = "inputNonAdmissible.txt"; + //String nameFile = "input.txt"; File f = new File("src/" + nameFile); Scanner sc = new Scanner(f); String[] elements; diff --git a/src/Simplex.java b/src/Simplex.java index 600371f5331844eb546013d82b38188dfe1b980f..df821435900a8fc2d36f2a499a16cff3a1eb0d59 100644 --- a/src/Simplex.java +++ b/src/Simplex.java @@ -67,13 +67,15 @@ public class Simplex { } void tabAux(int line) { + System.out.println(""); double[] tabRes = new double[this.y + this.nbSousCondition + 1]; Arrays.fill(tabRes, 1.0); - for (int i = 0; i < this.x; i++) { - for (int j = 0; j < this.y; j++) { - double data = this.matEcart.getData(this.x, j); - if (data < 0) { - System.out.println(data); + for (int i = 0; i < this.y; i++) { + for (int j = 0; j < this.x; j++) { + if (this.matEcart.getData(j, this.y - 1) < 0) { + if (this.matEcart.getData(j, i) != 0) { + this.matEcart.setData(j, i, -this.matEcart.getData(j, i)); + } } } } @@ -85,7 +87,6 @@ public class Simplex { tabRes[j] = tmpSum; } - // -2 car => tabRes[(tabRes.length-1) - (this.nbSousCondition - 1)]; tabRes[tabRes.length - 1] = tabRes[tabRes.length - this.nbSousCondition - 2]; tabRes[tabRes.length - this.nbSousCondition - 2] = 0; @@ -100,10 +101,9 @@ public class Simplex { this.tabAux.setData(i, j, this.matEcart.getData(i, j - this.matEcart.getX())); } } - System.out.println(); } this.tabAux.printTabAux("Tableau auxiliaire", this.nbContraintes, this.nbSousCondition, this.tabAux.getY() - this.matEcart.getY() - 1); - //pivot(this.tabAux); + pivot(this.tabAux); double solutionOptimale = this.tabAux.getData(this.tabAux.getX() - 1, this.tabAux.getY() - 1); if (solutionOptimale > 0 + EPSILON) { System.out.println("Il n'y a pas de solutions admissibles pour ce problème."); @@ -115,7 +115,7 @@ public class Simplex { res.matrixFill(res.getX(), res.getY(), tabAux.getDatas()); res.matrixPrint("Petit tableau", 2); nbPivot = 0; - //pivot(res); + pivot(res); res.matrixPrint("Résultat ", 3); System.out.println("Nombre de pivot : " + nbPivot); } @@ -161,7 +161,6 @@ public class Simplex { } - // TODO : A REFAIRE POUR SWITCH DE Y AU CAS OU int ligneSortante(Matrix mat, int y) { int id = 0;