Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp-math
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Math
2e-annee
tp-math
Commits
c2792bb5
Commit
c2792bb5
authored
2 years ago
by
juliano.souzaluz
Browse files
Options
Downloads
Patches
Plain Diff
nouvelle manière de parcourir les négatifs
parent
6695b259
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Simplex.java
+27
-10
27 additions, 10 deletions
src/Simplex.java
with
27 additions
and
10 deletions
src/Simplex.java
+
27
−
10
View file @
c2792bb5
...
...
@@ -8,7 +8,7 @@ public class Simplex {
private
final
int
ligne
;
// Ligne
private
final
int
colonne
;
// Colonne
private
int
nbPivot
;
private
static
final
double
EPSILON
=
1
E
-
40
;
private
static
final
double
EPSILON
=
1
E
-
7
;
private
final
int
nbContraintes
;
public
Matrix
getMatEcart
()
{
...
...
@@ -145,7 +145,6 @@ public class Simplex {
// remplir la nouvelle matrice avec les valeurs de la matrice auxiliaire, mais dans la taille de la matrice d'écart
res
.
matrixFill
(
res
.
getLine
(),
res
.
getCol
(),
tabAux
.
getDatas
());
if
(
debugging
)
res
.
matrixPrint
(
"Petit tableau"
);
nbPivot
=
0
;
// reset du nombre de pivots, on pourrait implémenter un pivot de phase 1 et un pivot de phase 2
// retour a la phase 2 avec le pivot sur la nouvelle matrice
pivot
(
res
,
true
);
if
(
debugging
)
{
...
...
@@ -164,10 +163,22 @@ public class Simplex {
* @return la colonne du premier négatif rencontré
*/
int
getFirstNeg
(
Matrix
mat
)
{
for
(
int
j
=
0
;
j
<
mat
.
getCol
()
-
1
;
j
++)
{
int
id
=
-
1
;
double
tmpVal
=
0
;
double
val
=
0
;
/*for (int j = 0; j < mat.getCol() - 1; j++) {
if (signe(mat.getData(mat.getLine() - 1, j))) return j;
}*/
for
(
int
j
=
0
;
j
<
mat
.
getCol
()
-
1
;
j
++)
{
tmpVal
=
mat
.
getData
(
mat
.
getLine
()
-
1
,
j
);
if
(
signe
(
tmpVal
))
{
if
(
val
>
tmpVal
)
{
val
=
tmpVal
;
id
=
j
;
}
}
}
return
-
1
;
return
id
;
}
/**
...
...
@@ -281,12 +292,6 @@ public class Simplex {
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
++)
{
...
...
@@ -298,8 +303,20 @@ public class Simplex {
if
(
m
.
getData
(
line
,
i
)
!=
0.0
)
System
.
out
.
format
(
"Z_Cstr_%d: = %.4f \n"
,
i
,
m
.
getData
(
line
,
i
));
}
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"
);
}
/**
* Retourne True ou False en fonction du signe, True si négatif
*
* @param x La valeur
* @return True si négatif
*/
boolean
signe
(
Double
x
)
{
return
x
<
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment