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
1acf10c8
Commit
1acf10c8
authored
2 years ago
by
juliano.souzaluz
Browse files
Options
Downloads
Patches
Plain Diff
push petite correction
parent
857b1698
No related branches found
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
+6
-6
6 additions, 6 deletions
src/Main.java
src/Simplex.java
+16
-15
16 additions, 15 deletions
src/Simplex.java
with
22 additions
and
21 deletions
src/Main.java
+
6
−
6
View file @
1acf10c8
...
@@ -7,11 +7,11 @@ import java.util.concurrent.TimeUnit;
...
@@ -7,11 +7,11 @@ import java.util.concurrent.TimeUnit;
public
class
Main
{
public
class
Main
{
/**
/**
* Compter le nombre d
'inéquation
s S.C
* Compter le nombre d
e variable
s S.C
* @param sc scanner
* @param sc scanner
* @return le nombre d
'inéquation
s S.C
* @return le nombre d
e variable
s S.C
*/
*/
private
static
Integer
nb
Lin
es
(
Scanner
sc
)
{
private
static
Integer
nb
Variabl
es
(
Scanner
sc
)
{
int
count
=
0
;
int
count
=
0
;
while
(
sc
.
hasNextLine
())
{
while
(
sc
.
hasNextLine
())
{
count
++;
count
++;
...
@@ -40,7 +40,7 @@ public class Main {
...
@@ -40,7 +40,7 @@ public class Main {
File
f
=
new
File
(
"src/inputNonAdmissible.txt"
);
File
f
=
new
File
(
"src/inputNonAdmissible.txt"
);
Scanner
sc
=
new
Scanner
(
f
);
Scanner
sc
=
new
Scanner
(
f
);
String
[]
elements
;
String
[]
elements
;
int
widthMat
=
nb
Lin
es
(
sc
);
int
widthMat
=
nb
Variabl
es
(
sc
);
sc
=
new
Scanner
(
f
);
// remettre le scanner à la première ligne
sc
=
new
Scanner
(
f
);
// remettre le scanner à la première ligne
int
contraintes
=
nbContraintes
(
sc
);
int
contraintes
=
nbContraintes
(
sc
);
sc
=
new
Scanner
(
f
);
// remettre le scanner à la première ligne
sc
=
new
Scanner
(
f
);
// remettre le scanner à la première ligne
...
@@ -71,9 +71,9 @@ public class Main {
...
@@ -71,9 +71,9 @@ public class Main {
// Print
// Print
eq
.
printEq
(
line
);
eq
.
printEq
(
line
);
// Tableau initial
e
// Tableau initial
Simplex
spx
=
new
Simplex
(
widthMat
,
line
+
1
,
line
+
3
);
Simplex
spx
=
new
Simplex
(
widthMat
,
line
+
1
,
line
+
3
);
spx
.
createSimplex
(
eq
);
spx
.
createSimplex
(
eq
,
contraintes
);
spx
.
printSimplex
(
"Tableau"
);
spx
.
printSimplex
(
"Tableau"
);
// 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
...
...
This diff is collapsed.
Click to expand it.
src/Simplex.java
+
16
−
15
View file @
1acf10c8
...
@@ -19,8 +19,7 @@ public class Simplex {
...
@@ -19,8 +19,7 @@ public class Simplex {
this
.
tabAux
=
new
Matrix
(
x
+
nbLines
+
1
,
y
+
1
);
this
.
tabAux
=
new
Matrix
(
x
+
nbLines
+
1
,
y
+
1
);
}
}
void
createSimplex
(
Equation
eq
)
{
void
createSimplex
(
Equation
eq
,
int
nbContraintes
)
{
int
nbContraintes
=
eq
.
getNbContraintes
();
// Matrice Amxn
// Matrice Amxn
for
(
int
i
=
0
;
i
<
this
.
x
;
i
++)
{
for
(
int
i
=
0
;
i
<
this
.
x
;
i
++)
{
for
(
int
j
=
0
;
j
<
this
.
y
;
j
++)
{
for
(
int
j
=
0
;
j
<
this
.
y
;
j
++)
{
...
@@ -38,39 +37,41 @@ public class Simplex {
...
@@ -38,39 +37,41 @@ public class Simplex {
// Fonction obj
// Fonction obj
for
(
int
i
=
0
;
i
<
nbContraintes
;
i
++)
for
(
int
i
=
0
;
i
<
nbContraintes
;
i
++)
this
.
matEcart
.
setData
(
this
.
x
-
1
,
i
,
eq
.
getFuncObj
().
get
(
i
));
this
.
matEcart
.
setData
(
this
.
x
-
1
,
i
,
eq
.
getFuncObj
().
get
(
i
));
// overwrite la matrice en bas à droite qui est à 1.
// overwrite la matrice en bas à droite qui est à 1.
this
.
matEcart
.
setData
(
this
.
x
-
1
,
this
.
y
-
1
,
0.0
);
this
.
matEcart
.
setData
(
this
.
x
-
1
,
this
.
y
-
1
,
0.0
);
}
}
/**
/**
* Si b[i] < 0 phase 1 sinon phase 2
* Si b[i] < 0 phase 1 sinon phase 2
*
* @return true = phase 1 | false = phase 2
* @return true = phase 1 | false = phase 2
*/
*/
int
which_phase
(){
int
which_phase
()
{
int
res
=
-
1
;
int
res
=
-
1
;
for
(
int
i
=
0
;
i
<
this
.
x
;
i
++)
{
for
(
int
i
=
0
;
i
<
this
.
x
;
i
++)
{
if
(
signe
(
this
.
matEcart
.
getData
(
i
,
this
.
y
-
1
)))
res
=
i
;
if
(
signe
(
this
.
matEcart
.
getData
(
i
,
this
.
y
-
1
)))
res
=
i
;
}
}
return
res
;
return
res
;
}
}
void
tabAux
(
int
line
)
{
void
tabAux
(
int
line
)
{
Double
[]
tabRes
=
new
Double
[
this
.
y
];
Double
[]
tabRes
=
new
Double
[
this
.
y
];
Arrays
.
fill
(
tabRes
,
0.0
);
Arrays
.
fill
(
tabRes
,
0.0
);
for
(
int
j
=
0
;
j
<
this
.
y
;
j
++)
{
for
(
int
j
=
0
;
j
<
this
.
y
;
j
++)
{
if
(
this
.
matEcart
.
getData
(
line
,
j
)
!=
0.0
)
{
if
(
this
.
matEcart
.
getData
(
line
,
j
)
!=
0.0
)
{
double
res
=
this
.
matEcart
.
getData
(
line
,
j
)
*
-
1
;
double
res
=
this
.
matEcart
.
getData
(
line
,
j
)
*
-
1
;
this
.
matEcart
.
setData
(
line
,
j
,
res
);
this
.
matEcart
.
setData
(
line
,
j
,
res
);
}
}
for
(
int
i
=
0
;
i
<
this
.
x
-
1
;
i
++)
for
(
int
i
=
0
;
i
<
this
.
x
-
1
;
i
++)
tabRes
[
j
]
-=
this
.
matEcart
.
getData
(
i
,
j
);
tabRes
[
j
]
-=
this
.
matEcart
.
getData
(
i
,
j
);
}
}
for
(
int
i
=
0
;
i
<
this
.
x
+
nbLines
+
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
this
.
x
+
nbLines
+
1
;
i
++)
{
for
(
int
j
=
0
;
j
<
this
.
y
+
1
;
j
++)
{
for
(
int
j
=
0
;
j
<
this
.
y
+
1
;
j
++)
{
if
(
i
<
this
.
x
&&
j
<
this
.
y
)
if
(
i
<
this
.
x
&&
j
<
this
.
y
)
this
.
tabAux
.
setData
(
i
,
j
,
this
.
matEcart
.
getData
(
i
,
j
));
this
.
tabAux
.
setData
(
i
,
j
,
this
.
matEcart
.
getData
(
i
,
j
));
else
if
(
i
>=
this
.
x
)
else
if
(
i
>=
this
.
x
)
this
.
tabAux
.
setData
(
i
,
j
,
this
.
matEcart
.
getData
(
i
-
5
,
j
));
this
.
tabAux
.
setData
(
i
,
j
,
this
.
matEcart
.
getData
(
i
-
5
,
j
));
else
if
(
j
==
this
.
y
)
else
if
(
j
==
this
.
y
)
this
.
tabAux
.
setData
(
i
,
j
,
tabRes
[
i
]);
this
.
tabAux
.
setData
(
i
,
j
,
tabRes
[
i
]);
...
@@ -80,7 +81,7 @@ public class Simplex {
...
@@ -80,7 +81,7 @@ public class Simplex {
int
getFirstNeg
()
{
int
getFirstNeg
()
{
for
(
int
j
=
0
;
j
<
this
.
y
;
j
++)
{
for
(
int
j
=
0
;
j
<
this
.
y
;
j
++)
{
if
(
signe
(
this
.
matEcart
.
getData
(
this
.
x
-
1
,
j
)))
return
j
;
if
(
signe
(
this
.
matEcart
.
getData
(
this
.
x
-
1
,
j
)))
return
j
;
}
}
return
-
1
;
return
-
1
;
}
}
...
@@ -115,7 +116,7 @@ public class Simplex {
...
@@ -115,7 +116,7 @@ public class Simplex {
double
tmp
=
this
.
matEcart
.
getData
(
id
,
this
.
y
-
1
)
/
this
.
matEcart
.
getData
(
id
,
y
);
double
tmp
=
this
.
matEcart
.
getData
(
id
,
this
.
y
-
1
)
/
this
.
matEcart
.
getData
(
id
,
y
);
for
(
int
i
=
1
;
i
<
this
.
x
-
1
;
i
++)
{
for
(
int
i
=
1
;
i
<
this
.
x
-
1
;
i
++)
{
double
tmp_s
=
this
.
matEcart
.
getData
(
i
,
this
.
y
-
1
)
/
this
.
matEcart
.
getData
(
i
,
y
);
double
tmp_s
=
this
.
matEcart
.
getData
(
i
,
this
.
y
-
1
)
/
this
.
matEcart
.
getData
(
i
,
y
);
if
(
tmp_s
<
tmp
)
{
if
(
tmp_s
<
tmp
)
{
id
=
i
;
id
=
i
;
tmp
=
tmp_s
;
tmp
=
tmp_s
;
}
}
...
...
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