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
a6405613
Commit
a6405613
authored
2 years ago
by
thibault.capt
Browse files
Options
Downloads
Patches
Plain Diff
travailler avec arraylist et pas double[][]
parent
734a0c98
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
src/Main.java
+49
-49
49 additions, 49 deletions
src/Main.java
src/Simplex2.java
+15
-9
15 additions, 9 deletions
src/Simplex2.java
with
66 additions
and
59 deletions
.gitignore
+
2
−
1
View file @
a6405613
...
...
@@ -219,3 +219,4 @@ replay_pid*
*.Identifier
log.txt
/.idea/
This diff is collapsed.
Click to expand it.
src/Main.java
+
49
−
49
View file @
a6405613
...
...
@@ -5,7 +5,6 @@ import java.util.Scanner;
import
java.util.concurrent.TimeUnit
;
public
class
Main
{
/**
* Compter le nombre d'inéquations S.C
* @param sc scanner
...
...
@@ -34,9 +33,8 @@ public class Main {
* Fonction main
* @param args arguments en entrées
*/
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
long
start
=
System
.
nanoTime
();
try
{
File
f
=
new
File
(
"src/input.txt"
);
Scanner
sc
=
new
Scanner
(
f
);
String
[]
elements
;
...
...
@@ -76,6 +74,11 @@ public class Main {
spx
.
createSimplex
(
eq
);
spx
.
printSimplex
(
"Tableau"
);
// Tableau initiale
//Simplex spx = new Simplex(line+1, line + 3, widthMat);
//spx.createMatEcart(eq);
//spx.printSimplex("Tableau");
// true = phase 1 membres de droite pas admissible | false = phase 2 membres de droite admissible
int
phase
=
spx
.
which_phase
();
if
(
phase
!=
-
1
)
{
...
...
@@ -89,9 +92,6 @@ public class Main {
}
sc
.
close
();
}
catch
(
FileNotFoundException
e
)
{
throw
new
RuntimeException
(
e
);
}
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/Simplex2.java
+
15
−
9
View file @
a6405613
...
...
@@ -19,7 +19,7 @@ public class Simplex2 {
this
.
nbLines
=
nbLines
;
this
.
x
=
x
;
this
.
y
=
y
;
this
.
simplex
=
new
ArrayList
<
ArrayList
<
Double
>
>();
this
.
simplex
=
new
ArrayList
<>();
}
public
void
printSimplex
(
String
title
)
{
...
...
@@ -84,10 +84,9 @@ public class Simplex2 {
private
int
ligneSortante
(
int
y
)
{
int
id
=
0
;
int
i
=
0
;
double
tmp
=
simplex
.
get
(
id
).
get
(
this
.
y
-
1
)
/
simplex
.
get
(
id
).
get
(
y
);
for
(
ArrayList
<
Double
>
doubles
:
simplex
)
{
double
tmp_s
=
doubles
.
get
(
this
.
y
-
1
)
/
doubles
.
get
(
y
-
1
);
for
(
int
i
=
1
;
i
<
this
.
x
-
1
;
i
++
)
{
double
tmp_s
=
simplex
.
get
(
i
)
.
get
(
this
.
y
-
1
)
/
simplex
.
get
(
i
)
.
get
(
y
);
if
(
tmp_s
<
tmp
)
{
id
=
i
;
tmp
=
tmp_s
;
...
...
@@ -98,20 +97,27 @@ public class Simplex2 {
}
void
pivot
()
{
// TODO Verif pivot id fausse
int
firstNeg
=
getFirstNeg
();
if
(
firstNeg
==
-
1
)
return
;
boolean
has_neg
=
false
;
int
id
=
ligneSortante
(
firstNeg
);
double
pivot
=
simplex
.
get
(
id
).
get
(
firstNeg
);
ArrayList
<
Double
>
tmp
=
new
ArrayList
<>();
for
(
Double
d
:
simplex
.
get
(
id
))
d
/=
pivot
;
tmp
.
add
(
d
/
pivot
);
simplex
.
set
(
id
,
tmp
);
tmp
=
new
ArrayList
<>();
int
id_tmp
=
0
;
for
(
ArrayList
<
Double
>
doubles
:
simplex
)
{
pivot
=
doubles
.
get
(
firstNeg
);
for
(
Double
d
:
doubles
)
{
if
(
doubles
.
indexOf
(
d
)
!=
id
)
{
d
-=
pivot
*
simplex
.
get
(
id
).
get
(
doubles
.
indexOf
(
d
));
}
if
(
doubles
.
indexOf
(
d
)
!=
id
)
tmp
.
add
(
pivot
*
simplex
.
get
(
id
).
get
(
doubles
.
indexOf
(
d
))
)
;
id_tmp
++;
}
simplex
.
set
(
id_tmp
,
tmp
);
}
for
(
Double
d
:
simplex
.
get
(
x
-
1
))
{
if
(
signe
(
d
))
{
...
...
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