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

affichage

parent f782af20
Branches
No related tags found
No related merge requests found
...@@ -93,20 +93,24 @@ public class Main { ...@@ -93,20 +93,24 @@ public class Main {
// true = phase 1 membres de droite pas admissible | false = phase 2 membres de droite admissible // true = phase 1 membres de droite pas admissible | false = phase 2 membres de droite admissible
if (spx.which_phase()) { if (spx.which_phase()) {
spx.tabAux(); Matrix m = spx.tabAux();
long stop = System.nanoTime();
long duration = TimeUnit.MILLISECONDS.convert(stop - start, TimeUnit.NANOSECONDS);
spx.resultPrint(m, duration);
} else { } else {
spx.pivot(spx.getMatEcart(), false); spx.pivot(spx.getMatEcart(), false);
if(debugging) { if(debugging) {
spx.printSimplex(spx.getMatEcart(), "Résultat"); spx.printSimplex(spx.getMatEcart(), "Résultat");
System.out.println("Nombre de pivot: " + spx.getNbPivot()); System.out.println("Nombre de pivot: " + spx.getNbPivot());
} }
// Mesure du temps
long stop = System.nanoTime();
long duration = TimeUnit.MILLISECONDS.convert(stop - start, TimeUnit.NANOSECONDS);
spx.resultPrint(spx.getMatEcart(), duration);
} }
sc.close(); sc.close();
// Mesure du temps
long stop = System.nanoTime();
long duration = TimeUnit.MILLISECONDS.convert(stop - start, TimeUnit.NANOSECONDS);
System.out.println("Temps d'exécution: " + duration + " ms");
} }
} }
...@@ -64,7 +64,7 @@ public class Simplex { ...@@ -64,7 +64,7 @@ public class Simplex {
return false; return false;
} }
void tabAux() { Matrix tabAux() {
if (debugging) System.out.println(); if (debugging) System.out.println();
double[] tabRes = new double[this.colonne + this.nbSousCondition + 1]; double[] tabRes = new double[this.colonne + this.nbSousCondition + 1];
Arrays.fill(tabRes, 1.0); Arrays.fill(tabRes, 1.0);
...@@ -105,7 +105,7 @@ public class Simplex { ...@@ -105,7 +105,7 @@ public class Simplex {
pivot(this.tabAux, true); pivot(this.tabAux, true);
double solutionOptimale = this.tabAux.getData(this.tabAux.getLine() - 1, this.tabAux.getCol() - 1); double solutionOptimale = this.tabAux.getData(this.tabAux.getLine() - 1, this.tabAux.getCol() - 1);
if (solutionOptimale > 0 + EPSILON) { if (solutionOptimale > EPSILON) {
System.out.println("Il n'y a pas de solutions admissibles pour ce problème."); System.out.println("Il n'y a pas de solutions admissibles pour ce problème.");
} }
if (Math.abs(solutionOptimale) < EPSILON || solutionOptimale == 0) { if (Math.abs(solutionOptimale) < EPSILON || solutionOptimale == 0) {
...@@ -120,7 +120,9 @@ public class Simplex { ...@@ -120,7 +120,9 @@ public class Simplex {
res.matrixPrint("Matrice Résultat "); res.matrixPrint("Matrice Résultat ");
System.out.println("Nombre de pivot : " + nbPivot); System.out.println("Nombre de pivot : " + nbPivot);
} }
return res;
} }
return null;
} }
int getFirstNeg(Matrix mat) { int getFirstNeg(Matrix mat) {
...@@ -193,6 +195,26 @@ public class Simplex { ...@@ -193,6 +195,26 @@ public class Simplex {
mat.matrixPrint(s); mat.matrixPrint(s);
} }
public void resultPrint(Matrix m, long time) {
int line = m.getLine() - 1;
int col = m.getCol() - 1;
System.out.println("-------------------Solution-------------------");
System.out.println("Status: Optimal");
System.out.format("Size: %d rows, %d cols\n", m.getLine(), m.getCol());
System.out.println("Obj value: " + -1 * m.getData(line, col));
System.out.println("Nombre de pivot(s) réalisé(s) sur le petit tableau post phase 1: " + this.nbPivot);
System.out.println("Time: " + time + " ms");
System.out.println("-------------------Variables------------------");
System.out.println("Variables:");
for (int i = 0; i < line; i++) {
System.out.format("X[%d]: = %.4f \n", i, m.getData(i, col));
}
for (int i = 0; i < col; i++) {
System.out.format("Z_Cstr_%d: = %.4f \n", i, m.getData(line, i));
}
}
boolean signe(Double x) { boolean signe(Double x) {
return x < 0; return x < 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment