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
f9249216
Commit
f9249216
authored
2 years ago
by
juliano.souzaluz
Browse files
Options
Downloads
Patches
Plain Diff
affichage
parent
f782af20
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Main.java
+9
-5
9 additions, 5 deletions
src/Main.java
src/Simplex.java
+25
-3
25 additions, 3 deletions
src/Simplex.java
with
34 additions
and
8 deletions
src/Main.java
+
9
−
5
View file @
f9249216
...
...
@@ -93,20 +93,24 @@ public class Main {
// true = phase 1 membres de droite pas admissible | false = phase 2 membres de droite admissible
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
{
spx
.
pivot
(
spx
.
getMatEcart
(),
false
);
if
(
debugging
)
{
spx
.
printSimplex
(
spx
.
getMatEcart
(),
"Résultat"
);
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
();
// 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"
);
}
}
This diff is collapsed.
Click to expand it.
src/Simplex.java
+
25
−
3
View file @
f9249216
...
...
@@ -64,7 +64,7 @@ public class Simplex {
return
false
;
}
void
tabAux
()
{
Matrix
tabAux
()
{
if
(
debugging
)
System
.
out
.
println
();
double
[]
tabRes
=
new
double
[
this
.
colonne
+
this
.
nbSousCondition
+
1
];
Arrays
.
fill
(
tabRes
,
1.0
);
...
...
@@ -100,12 +100,12 @@ public class Simplex {
}
}
}
if
(
debugging
)
this
.
tabAux
.
printTabAux
(
"Tableau auxiliaire"
,
this
.
nbContraintes
,
this
.
nbSousCondition
,
if
(
debugging
)
this
.
tabAux
.
printTabAux
(
"Tableau auxiliaire"
,
this
.
nbContraintes
,
this
.
nbSousCondition
,
this
.
tabAux
.
getCol
()
-
this
.
matEcart
.
getCol
()
-
1
);
pivot
(
this
.
tabAux
,
true
);
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."
);
}
if
(
Math
.
abs
(
solutionOptimale
)
<
EPSILON
||
solutionOptimale
==
0
)
{
...
...
@@ -120,7 +120,9 @@ public class Simplex {
res
.
matrixPrint
(
"Matrice Résultat "
);
System
.
out
.
println
(
"Nombre de pivot : "
+
nbPivot
);
}
return
res
;
}
return
null
;
}
int
getFirstNeg
(
Matrix
mat
)
{
...
...
@@ -193,6 +195,26 @@ public class Simplex {
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
)
{
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