Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-CHMIELEWSKI-Louis
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
Louis Chmielewski
AP-CHMIELEWSKI-Louis
Commits
1de6bfa1
Commit
1de6bfa1
authored
1 year ago
by
Louis Chmielewski
Browse files
Options
Downloads
Patches
Plain Diff
analyse_tris2
parent
dcdc168b
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.DS_Store
+0
-0
0 additions, 0 deletions
.DS_Store
Tp07/analyse_tris.csv
+98
-98
98 additions, 98 deletions
Tp07/analyse_tris.csv
Tp07/analyse_tris2.py
+94
-0
94 additions, 0 deletions
Tp07/analyse_tris2.py
Tp07/tris_nbcomp.png
+0
-0
0 additions, 0 deletions
Tp07/tris_nbcomp.png
with
192 additions
and
98 deletions
.DS_Store
+
0
−
0
View file @
1de6bfa1
No preview for this file type
This diff is collapsed.
Click to expand it.
Tp07/analyse_tris.csv
+
98
−
98
View file @
1de6bfa1
...
@@ -2,101 +2,101 @@ taille;"tri séléction";"tri insertion"
...
@@ -2,101 +2,101 @@ taille;"tri séléction";"tri insertion"
0; 0.00; 0.00
0; 0.00; 0.00
1; 0.00; 0.00
1; 0.00; 0.00
2; 1.00; 1.00
2; 1.00; 1.00
3; 3.00; 2.6
2
3; 3.00; 2.6
4
4; 6.00;
4.96
4; 6.00;
5.00
5; 10.00; 7.
72
5; 10.00; 7.
86
6; 15.00; 11.4
4
6; 15.00; 11.4
6
7; 21.00; 1
5.4
0
7; 21.00; 1
4.7
0
8; 28.00; 19.
02
8; 28.00; 19.
64
9; 36.00; 2
4.6
2
9; 36.00; 2
5.4
2
10; 45.00; 2
8.80
10; 45.00; 2
9.94
11; 55.00; 35.
70
11; 55.00; 35.
96
12; 66.00; 4
0.96
12; 66.00; 4
3.34
13; 78.00;
50.26
13; 78.00;
48.08
14; 91.00; 5
6.38
14; 91.00; 5
3.64
15; 105.00; 6
6.54
15; 105.00; 6
3.70
16; 120.00; 7
3
.3
4
16; 120.00; 7
1
.3
8
17; 136.00; 8
1.8
2
17; 136.00; 8
3.4
2
18; 153.00; 9
4.12
18; 153.00; 9
1.68
19; 171.00; 10
3.3
6
19; 171.00; 10
1.9
6
20; 190.00; 1
09.78
20; 190.00; 1
15.44
21; 210.00; 12
1.60
21; 210.00; 12
3.02
22; 231.00; 13
1.76
22; 231.00; 13
2.92
23; 253.00; 14
3.06
23; 253.00; 14
2.60
24; 276.00; 15
6.52
24; 276.00; 15
3.86
25; 300.00; 17
5.36
25; 300.00; 17
2.64
26; 325.00; 18
2.90
26; 325.00; 18
4.34
27; 351.00; 19
2.02
27; 351.00; 19
8.60
28; 378.00; 21
2.32
28; 378.00; 21
7.44
29; 406.00; 22
7.84
29; 406.00; 22
5.00
30; 435.00; 2
43.40
30; 435.00; 2
39.34
31; 465.00; 2
62.58
31; 465.00; 2
59.34
32; 496.00; 2
78.14
32; 496.00; 2
80.90
33; 528.00; 2
93.86
33; 528.00; 2
84.24
34; 561.00; 31
2.92
34; 561.00; 31
0.76
35; 595.00; 3
3
2.2
8
35; 595.00; 32
5
.2
6
36; 630.00; 34
4.32
36; 630.00; 34
3.40
37; 666.00; 35
4.34
37; 666.00; 35
9.78
38; 703.00; 3
97.1
8
38; 703.00; 3
75.0
8
39; 741.00; 4
1
0.
56
39; 741.00; 4
0
0.
10
40; 780.00; 4
29.42
40; 780.00; 4
30.74
41; 820.00; 45
3.40
41; 820.00; 45
2.26
42; 861.00; 46
1.80
42; 861.00; 46
8.32
43; 903.00; 4
8
5.4
6
43; 903.00; 4
9
5.
8
4
44; 946.00; 5
1
7.
1
0
44; 946.00; 5
0
7.
4
0
45; 990.00; 5
40.00
45; 990.00; 5
33.92
46; 1035.00; 55
4
.3
0
46; 1035.00; 55
5
.3
8
47; 1081.00; 5
75.3
4
47; 1081.00; 5
98.1
4
48; 1128.00;
607.3
4
48; 1128.00;
599.0
4
49; 1176.00; 6
20
.1
8
49; 1176.00; 6
35
.1
2
50; 1225.00; 6
47.48
50; 1225.00; 6
58.20
51; 1275.00; 6
93.9
6
51; 1275.00; 6
76.2
6
52; 1326.00; 7
12.04
52; 1326.00; 7
09.66
53; 1378.00; 732.
64
53; 1378.00; 732.
12
54; 1431.00; 76
8.84
54; 1431.00; 76
0.52
55; 1485.00;
794.12
55; 1485.00;
802.84
56; 1540.00; 8
20.92
56; 1540.00; 8
07.68
57; 1596.00; 8
22
.3
4
57; 1596.00; 8
46
.3
8
58; 1653.00; 8
77.84
58; 1653.00; 8
61.46
59; 1711.00;
917.66
59; 1711.00;
890.74
60; 1770.00; 94
8.4
2
60; 1770.00; 94
6.7
2
61; 1830.00; 9
56.04
61; 1830.00; 9
92.92
62; 1891.00; 10
05.00
62; 1891.00; 10
23.54
63; 1953.00; 10
42.6
0
63; 1953.00; 10
19.5
0
64; 2016.00; 10
3
7.
82
64; 2016.00; 10
5
7.
94
65; 2080.00; 108
7.02
65; 2080.00; 108
6.24
66; 2145.00; 11
47.22
66; 2145.00; 11
28.60
67; 2211.00; 11
84.68
67; 2211.00; 11
65.44
68; 2278.00; 12
15.4
4
68; 2278.00; 12
04.8
4
69; 2346.00; 12
3
9.
1
0
69; 2346.00; 12
1
9.
9
0
70; 2415.00; 12
47.28
70; 2415.00; 12
81.70
71; 2485.00; 131
0.1
4
71; 2485.00; 131
6.6
4
72; 2556.00; 13
36.78
72; 2556.00; 13
42.46
73; 2628.00; 1
395
.5
0
73; 2628.00; 1
418
.5
2
74; 2701.00; 14
17
.10
74; 2701.00; 14
05
.10
75; 2775.00; 14
64.58
75; 2775.00; 14
51.02
76; 2850.00; 1
482.6
2
76; 2850.00; 1
518.2
2
77; 2926.00; 15
45
.8
4
77; 2926.00; 15
18
.8
0
78; 3003.00; 156
6.4
8
78; 3003.00; 156
4.5
8
79; 3081.00; 162
2
.5
2
79; 3081.00; 162
3
.5
8
80; 3160.00; 16
37.6
4
80; 3160.00; 16
42.0
4
81; 3240.00; 1
686.34
81; 3240.00; 1
710.88
82; 3321.00; 174
0.88
82; 3321.00; 174
5.06
83; 3403.00; 17
89.50
83; 3403.00; 17
64.28
84; 3486.00; 181
4.38
84; 3486.00; 181
6.94
85; 3570.00; 185
7.88
85; 3570.00; 185
4.54
86; 3655.00; 19
29.30
86; 3655.00; 19
12.42
87; 3741.00; 198
0
.8
8
87; 3741.00; 19
6
8.8
2
88; 3828.00; 197
3.5
2
88; 3828.00; 197
5.6
2
89; 3916.00; 20
66.94
89; 3916.00; 20
40.76
90; 4005.00; 2
085.78
90; 4005.00; 2
121.34
91; 4095.00; 21
25.72
91; 4095.00; 21
39.34
92; 4186.00; 22
20.08
92; 4186.00; 22
12.86
93; 4278.00; 22
40.4
4
93; 4278.00; 22
08.7
4
94; 4371.00; 22
83.70
94; 4371.00; 22
74.04
95; 4465.00; 23
59.8
8
95; 4465.00; 23
34.4
8
96; 4560.00; 23
85.16
96; 4560.00; 23
51.64
97; 4656.00; 24
50.00
97; 4656.00; 24
29.18
98; 4753.00; 24
73.9
6
98; 4753.00; 24
24.4
6
99; 4851.00; 2
53
1.
3
2
99; 4851.00; 2
48
1.
8
2
100; 4950.00; 25
6
4.
28
100; 4950.00; 25
5
4.
04
This diff is collapsed.
Click to expand it.
Tp07/analyse_tris2.py
0 → 100755
+
94
−
0
View file @
1de6bfa1
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
:mod:`analyse_tris` module
:author: FIL - Faculté des Sciences et Technologies - Univ. Lille <http://portail.fil.univ-lille1.fr>_
:date: janvier 2017
:dernières révisions: février 2018, février 2019
Analyse empirique des tris
"""
from
random
import
shuffle
from
typing
import
Callable
from
compare
import
compare
from
ap_decorators
import
count
from
tris
import
*
from
functools
import
cmp_to_key
################################################
# ANALYSE EMPIRIQUE DES TRIS #
################################################
# ajout d'un compteur à la fonction compare
compare
=
count
(
compare
)
def
analyser_tri
(
tri
:
Callable
[[
list
[
T
],
Callable
[[
T
,
T
],
int
]],
NoneType
],
nbre_essais
:
int
,
taille
:
int
)
->
float
:
"""
renvoie: le nombre moyen de comparaisons effectuées par l
'
algo tri
pour trier des listes de taille t, la moyenne étant calculée
sur n listes aléatoires.
précondition: n > 0, t >= 0, la fonc
"""
res
=
0
for
i
in
range
(
nbre_essais
):
compare
.
counter
=
0
l
=
[
k
for
k
in
range
(
taille
)]
shuffle
(
l
)
tri
(
l
,
compare
)
res
+=
compare
.
counter
return
res
/
nbre_essais
def
tri_sort
(
l
:
list
[
int
],
cmp
):
"""
à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$
"""
l
.
sort
(
key
=
cmp_to_key
(
cmp
))
if
(
__name__
==
'
__main__
'
):
from
matplotlib
import
pyplot
as
plt
# Calcul de nombres moyens de comparaison pour des listes
# de tailles comprises entre 0 et TAILLE_MAX
NB_ESSAIS
=
50
TAILLE_MAX
=
100
c_select
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
c_insert
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
c_sort
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
for
t
in
range
(
TAILLE_MAX
+
1
):
c_select
[
t
]
=
analyser_tri
(
tri_select
,
1
,
t
)
# inutile de moyenner pour le tri par sélection
c_insert
[
t
]
=
analyser_tri
(
tri_insert
,
NB_ESSAIS
,
t
)
c_sort
[
t
]
=
analyser_tri
(
tri_sort
,
NB_ESSAIS
,
t
)
# Sauvegarde des données calculées dans un fichier au format CSV
prem_ligne
=
'
taille;
"
tri séléction
"
;
"
tri insertion
"
\n
'
ligne
=
'
{:3d};{:8.2f};{:8.2f}
\n
'
with
open
(
'
analyse_tris.csv
'
,
'
wt
'
,
encoding
=
'
utf8
'
)
as
sortie
:
sortie
.
write
(
prem_ligne
)
for
t
in
range
(
TAILLE_MAX
+
1
):
sortie
.
write
(
ligne
.
format
(
t
,
c_select
[
t
],
c_insert
[
t
]))
# Représentation graphique
plt
.
plot
(
list
(
range
(
TAILLE_MAX
+
1
)),
c_select
,
'
b.
'
,
label
=
'
Tri sélection
'
)
plt
.
plot
(
list
(
range
(
TAILLE_MAX
+
1
)),
c_insert
,
'
r.
'
,
label
=
'
Tri insertion
'
)
plt
.
plot
(
list
(
range
(
TAILLE_MAX
+
1
)),
c_sort
,
'
g.
'
,
label
=
'
Tri sort
'
)
plt
.
title
(
'
Tris : nbre de comparaisons
'
)
plt
.
legend
()
plt
.
xlabel
(
'
n = taille des listes
'
)
plt
.
ylabel
(
'
c(n) = nbre de comparaisons
'
)
plt
.
savefig
(
'
tris_nbcomp.png
'
)
plt
.
show
()
This diff is collapsed.
Click to expand it.
Tp07/tris_nbcomp.png
+
0
−
0
View replaced file @
dcdc168b
View file @
1de6bfa1
27.7 KiB
|
W:
|
H:
29.1 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
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