Skip to content
Snippets Groups Projects
Commit b3b3223c authored by thibault.capt's avatar thibault.capt
Browse files

update

parent 2bf8c34f
No related branches found
No related tags found
No related merge requests found
...@@ -71,10 +71,19 @@ public class Main { ...@@ -71,10 +71,19 @@ public class Main {
// Print // Print
eq.printEq(line); eq.printEq(line);
Simplex spx = new Simplex(4, 6); // Tableau initiale
Simplex spx = new Simplex(5, 6);
spx.createMatEcart(eq); spx.createMatEcart(eq);
// true = phase 1 | false = phase 2
if (spx.which_phase())
spx.tabAux();
else
spx.pivot();
spx.printSimplex(); spx.printSimplex();
sc.close(); sc.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
......
...@@ -61,12 +61,13 @@ public class Simplex { ...@@ -61,12 +61,13 @@ public class Simplex {
// Matrice Amxn // Matrice Amxn
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) { for (int j = 0; j < height; j++) {
if(j < nbContraintes) if (j < nbContraintes) {
setMatEcartById(eq.getMatAtId(i, j), i, j); setMatEcartById(eq.getMatAtId(i, j), i, j);
else } else {
setMatEcartById(j - nbContraintes == i ? 1.0 : 0.0, i, j); setMatEcartById(j - nbContraintes == i ? 1.0 : 0.0, i, j);
} }
} }
}
// Membre de droite // Membre de droite
for (int i = 0; i <= nbContraintes; i++) for (int i = 0; i <= nbContraintes; i++)
...@@ -79,4 +80,28 @@ public class Simplex { ...@@ -79,4 +80,28 @@ public class Simplex {
// overwrite la mat en bas à droite qui est à 1 // overwrite la mat en bas à droite qui est à 1
setMatEcartById(0.0, width - 1, height - 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;
}
} }
...@@ -2,3 +2,4 @@ max;8;9; ...@@ -2,3 +2,4 @@ max;8;9;
2;5;<=;12; 2;5;<=;12;
50;5;<=;150; 50;5;<=;150;
5;50;<=;100; 5;50;<=;100;
-1;-1000;<=;-1;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment