Skip to content
Snippets Groups Projects
Commit 4c8f325b authored by juliano.souzaluz's avatar juliano.souzaluz
Browse files

Update Main.java

parent 1acf10c8
Branches
No related tags found
No related merge requests found
...@@ -8,10 +8,11 @@ public class Main { ...@@ -8,10 +8,11 @@ public class Main {
/** /**
* Compter le nombre de variables S.C * Compter le nombre de variables S.C
*
* @param sc scanner * @param sc scanner
* @return le nombre de variables S.C * @return le nombre de variables S.C
*/ */
private static Integer nbVariables(Scanner sc) { private static Integer nbSc(Scanner sc) {
int count = 0; int count = 0;
while (sc.hasNextLine()) { while (sc.hasNextLine()) {
count++; count++;
...@@ -19,8 +20,10 @@ public class Main { ...@@ -19,8 +20,10 @@ public class Main {
} }
return count - 1; // A cause de la premiere ligne return count - 1; // A cause de la premiere ligne
} }
/** /**
* Compter le nombre d'inéquations S.C * Compter le nombre d'inéquations S.C
*
* @param sc scanner * @param sc scanner
* @return le nombre d'inéquations S.C * @return le nombre d'inéquations S.C
*/ */
...@@ -32,6 +35,7 @@ public class Main { ...@@ -32,6 +35,7 @@ public class Main {
/** /**
* Fonction main * Fonction main
*
* @param args arguments en entrées * @param args arguments en entrées
*/ */
public static void main(String[] args) throws FileNotFoundException, RuntimeException { public static void main(String[] args) throws FileNotFoundException, RuntimeException {
...@@ -40,12 +44,11 @@ public class Main { ...@@ -40,12 +44,11 @@ public class Main {
File f = new File("src/inputNonAdmissible.txt"); File f = new File("src/inputNonAdmissible.txt");
Scanner sc = new Scanner(f); Scanner sc = new Scanner(f);
String[] elements; String[] elements;
int widthMat = nbVariables(sc); int sousCondition = nbSc(sc), line = 0;
sc = new Scanner(f); // remettre le scanner à la première ligne sc = new Scanner(f); // remettre le scanner à la première ligne
int contraintes = nbContraintes(sc); int contraintes = nbContraintes(sc);
sc = new Scanner(f); // remettre le scanner à la première ligne sc = new Scanner(f); // remettre le scanner à la première ligne
int line = 0; Equation eq = new Equation(sousCondition * 2, contraintes); // lignes supp au cas où, il y a des "="
Equation eq = new Equation(widthMat*2, contraintes); // lignes supp au cas où, il y a des "="
// Max / Min + function obj // Max / Min + function obj
String firstLine = sc.nextLine(); String firstLine = sc.nextLine();
...@@ -72,7 +75,7 @@ public class Main { ...@@ -72,7 +75,7 @@ public class Main {
eq.printEq(line); eq.printEq(line);
// Tableau initial // Tableau initial
Simplex spx = new Simplex(widthMat, line+1, line + 3); Simplex spx = new Simplex(sousCondition + 1, line + contraintes, line + 3);
spx.createSimplex(eq, contraintes); spx.createSimplex(eq, contraintes);
spx.printSimplex("Tableau"); spx.printSimplex("Tableau");
...@@ -82,8 +85,7 @@ public class Main { ...@@ -82,8 +85,7 @@ public class Main {
spx.tabAux(phase); spx.tabAux(phase);
System.out.println("Tableau Auxiliaire:"); System.out.println("Tableau Auxiliaire:");
System.out.println(Arrays.deepToString(spx.getTabAux())); System.out.println(Arrays.deepToString(spx.getTabAux()));
} } else {
else {
spx.pivot(); spx.pivot();
spx.printSimplex("pivot"); spx.printSimplex("pivot");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment