Théorie des graphes et problèmes d'optimisation
Théorie des graphes et problèmes d'optimisation
Recherche Opérationnelle 1
La théorie des graphes
Ce graphe se définit de
façon suivante:
G = (v,e)
v = (1,2,3,4,5)
e = (1,2), (1,3), (2,2),
(2,5), (4,2), (4,3), (4,5)
Recherche Opérationnelle 2
la théorie des graphes
Recherche Opérationnelle 3
la théorie des graphes
Recherche Opérationnelle 4
la théorie des graphes
Un circuit est un chemin fini et fermé dont l’extrémité
terminale du dernier arc coïncide avec l’extrémité
initiale du premier.
Recherche Opérationnelle 6
Le ProbLème d’affectation
Il s'agit d'affecter :
- des famille de produits à des zones de stock,
- des commerciaux à des secteurs,
- des ouvriers sur des machines,
- des projets a des étudiants
- etc…
Recherche Opérationnelle 7
Problème d’affectation
La méthode hongroise
( algorithme de KHUN)
Recherche Opérationnelle 8
ProbLème d’affectation
La méthode hongroise
Application :
• Les coûts de fabrication des ouvriers sur les diverses
machines sont donnés par le tableau ci-dessous.
• Chercher la meilleure affectation de manière à rendre le coût
de fabrication minimal
Recherche Opérationnelle 9
Problème d’affectation
La méthode hongroise
Etape 1: Obtention des zéros
Créer une nouvelle matrice des coûts en choisissant le
coût minimal dans chaque colonne et en le soustrayant
de chaque coût dans la colonne ( Idem pour les lignes ).
Recherche Opérationnelle 10
Problème d’affectation
La méthode hongroise
Recherche Opérationnelle 11
Problème d’affectation
La méthode hongroise
Recherche Opérationnelle 12
Problème d’affectation
La méthode hongroise
Etape 3: Recherche des rangées en nombre minimal
contenant tous les zéros (procédure de marquage):
a. On marque d’une croix toute ligne ne contenant aucun
zéro encadré.
b. On marque toute colonne qui a un zéro barré sur une ou
plusieurs lignes marquées.
c. On marque toute ligne qui a un zéro encadré sur une ou
plusieurs colonnes marquées.
d. On répète b) et c) jusqu’à ce qu’il n’y ait plus de colonne
ou de ligne à marquer.
On trace un trait sur toute colonne marquée.
On trace un trait sur toute ligne non marquée.
Recherche Opérationnelle 13
Problème d’affectation
La méthode hongroise
Recherche Opérationnelle 14
Problème d’affectation
La méthode hongroise
Recherche Opérationnelle 15
Problème d’affectation
La méthode hongroise
Recherche Opérationnelle 16
Problème d’affectation
La méthode hongroise
Recherche Opérationnelle 17
Problème d’affectation
La méthode hongroise
Recherche Opérationnelle 18
Le Problème Du
FLOT MAXIMAL
Recherche Opérationnelle 19
Le Problème Du FLOT MAXIMAL
Le problème des flots dans les réseaux concerne la circulation de matière sur
les arcs d’un graphe. Parmi les nombreuses applications qui relèvent de ce
problème, on trouve:
o etc.
Recherche Opérationnelle 20
Flots dans les réseaux
PROBLEME DU FLOT MAXIMUM
b
[3]
[7]
[5]
Entrée a [4] d e Sortie
[2]
[5]
[2]
c
Définition du flot réalisable
c c
Algorithme de Ford-Fulkerson
Initialisation du flot F : Fij = 0 (arcs antisaturés)
Fin = FAUX
Tant que NON Fin
Construction du graphe d’écart G = (X,F(U),E)
Recherche d’un chemin C dans G depuis l’entrée vers la
sortie
Si C existe Alors
Calcul de l’augmentation
Affectation de l’augmentation
Sinon
Fin = VRAI
ALGORITHME DE FORD-FULKERSON,
GRAPHE D'ECART
1
a b c d b
E [0,25]
1 10 15 - 20 2 S
2 20 5 5 - c
3
3 - - 10 10
d
Exemple de flot
a
b
[0,25], 25
E 2 S
Valeur du flot = 80
d
b
S [25,25] 2 T
c
Un flot complet 3
d
25
10 a
Graphe d’écart
15
1
10 5 5
10
35 5 b
10
25 5 5
S 2 T
5
5 c
15
10
20 20
3 30
10
d
Détermination d’un flot maximum
25
10 30
a
5 10 5 20 15 5 0 0 5
10 1
35 40 10 5
b
0 10
25 5 5
S 2 5 T
5
5 c
15
10
20 20
3 30
10
d
Valeur du flot = 85
Capacité minimale = 5
a
b
[25,25]
S 2 T
Un flot complet
d
30
10 a
Graphe d’écart 20
5 1
40 5 10 b
10
25 0 5
S 2 T
5
5 c
15
10
20 20
3 30
10
PLUS DE CHEMIN entre S et T d
Le Problème Du
chemin optimal
Recherche Opérationnelle 39
Dijkstra’s algorithm
notation:
c(x,y): link cost from node
computes least cost paths x to y; = ∞ if not direct
from one node (‘source”) neighbors
to all other nodes D(v): current value of cost
gives forwarding table for of path from source to
that node destination v
iterative: after k iterations, p(v): predecessor node
along path from source to
know least cost path to k v
destinations N': set of nodes whose
least cost path definitively
known
Dijkstra’s algorithm
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N' :
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'
Dijkstra’s algorithm: example
5
clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
v 3 w
2 5
u 2 z
1
3
1
x y 2
B-F equation says:
1
du(z) = min { c(u,v) + dv(z),
c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4
Distance vector algorithm
from
from
y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
node y cost to
table x y z y
2 1
x ∞ ∞ ∞
x z
from
y 2 0 1 7
z ∞∞ ∞
node z cost to
table x y z
x ∞∞ ∞
from
y ∞∞ ∞
z 7 1 0
time
Dx(z) = min{c(x,y) +
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to cost to
table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from
from
y ∞∞ ∞ y 2 0 1
from
y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y cost to cost to cost to
table x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from
from
y 2 0 1 y 2 0 1
from
y 2 0 1 7
z ∞∞ ∞ z 7 1 0 z 3 1 0
x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Why Distance Vector Works
San
2 Hops
1 Hop
From SJ
Jose
3 Hops From SJ
From SJ
Hop-1 nodes
calculate current
(next hop, dist), &
send to neighbors
Accurate info about SJ
ripples across network,
Shortest Path Converges
Iteration Node 1 Node 2 Node 3 Node 4 Node 5
2 3
1 1 San
5 2
4
Jose
3 1 3 6
2
2 5
4
Iteration Node 1 Node 2 Node 3 Node 4 Node 5
D3=D6+1
n3=6
D6=0
2 3 1
1 1
5 2
0
4 San
3 6
1 3
Jose
2 5 2
4
2
D5=D6+2 D6=0
n5=6
Iteration Node 1 Node 2 Node 3 Node 4 Node 5
3 1
2 3
1 1
5 2
3 0
4 San
3 6
1 3
Jose
2 2
5
4
6 2
Iteration Node 1 Node 2 Node 3 Node 4 Node 5
1
3 2 3
1 1
5 2
3 0
4 San
3 6
1 3
Jose
2
2 5
4
6 4 2
Le Problème
d’ordonnancement
Project Planning and scheduling
CPM / PERT
Recherche Opérationnelle 55
Project Planning
56
Gantt Chart
57
A Gantt Chart example
Month
0 2 4 6 8 10
Activity
Lay foundation
Build house
Select paint
Select carpet
Finish work
1 3 5 7 9 58
CPM/PERT
59
Graph Construction
60
Graph Construction Example
3
Lay foundation
Lay Dummy
foundation
2 3
2 4
Order material
Order material
Incorrect Correct
precedence precedence
relationship relationship
62
Project graph For A House
3
Lay foundation Dummy
0
2 Build Finish
3 1 house work
1 2 4 6 7
3 1
Design house Order and 1
and obtain receive materials Select 1 Select
financing paint carpet
5
63
Critical Path
64
All Possible Paths
3
Lay foundation Dummy
0
2 Build Finish
3 1 house work
1 2 4 6 7
3 1
Design house Order and 1
and obtain receive materials Select 1 Select
financing paint carpet
5
path1: 1-2-3-4-6-7
3 + 2 + 0 + 3 + 1 = 9 months; the critical path
path2: 1-2-3-4-5-6-7
3 + 2 + 0 + 1 + 1 + 1 = 8 months
path3: 1-2-4-6-7
3 + 1 + 3 + 1 = 8 months
path4: 1-2-4-5-6-7
3 + 1 + 1 + 1 + 1 = 7 months 65
Early Times
ES12 = 0
EF12 = ES12 + t12 = 0 + 3 = 3 months
ES23 = max (EF2) = 3 months
ES46 = max (EF4) = max (5,4) = 5 months
EF46 = ES46 + t46 = 5 + 3 = 8 months
EF67 =9 months, the project duration
67
Late Times
ES=5, EF=5
ES=3, EF=5 3
LS=5, LF=5
LS=3, LF=5 0 ES=8, EF=9
ES=5, EF=8
2
3 1 LS=8, LF=9
LS=5, LF=8 7
1 2 4 6
ES=0, EF=3 ES=3, EF=4 3 1
1
LS=0, LF=3 LS=4, LF=5 1 ES=6, EF=7
ES=5, EF=6
LS=7, LF=8
LS=6, LF=7 5
70
Activity Slack
71
Free slack of an activity
72
Activity Slack Data
ES=5, EF=5
ES=3, EF=5 3
LS=5, LF=5
LS=3, LF=5 0 ES=8, EF=9
ES=5, EF=8
2
3 1 LS=8, LF=9
LS=5, LF=8 7
1 2 4 6
ES=0, EF=3 ES=3, EF=4 3 1
1
LS=0, LF=3 LS=4, LF=5 1 ES=6, EF=7
ES=5, EF=6
LS=7, LF=8
LS=6, LF=7 5
Activity ES LS EF LF Slack (S) Free slack
1-2* 0 0 3 3 0 0
2-3 3 3 5 5 0 0
2-4 3 4 4 5 1 1
3-4* 5 5 5 5 0 0
4-5 5 6 6 7 1 0
4-6* 5 5 8 8 0 0
5-6 6 7 7 8 1 1
6-7* 8 8 9 9 0 0
73
* Critical path
Slack on Gantt Chart
0 2 4 6 8 10
• Activity
• Lay foundation
• Build house
• Select paint
• Select carpet
• Finish work
1 3 5 7 9
Recherche Opérationnelle 74
AON example: Beans on Toast
Beans
Start on Toast
AOA Ready
AON Start
Beans onto
toast
End
Add notation: “T” = time, “ES” = Earliest Start, “EF” = Earliest Finish
“LS” = Latest Start, “LF” = Latest Finish
Finding the critical path
The earliest finish of the final activity is also the latest acceptable finish for the
final activity, assuming we don’t want the project completion to be delayed.
Finding the critical path
Then we do a second, backwards, pass through the network, where for each node,
LF is min(LS of all downstream nodes) and LS is LF - T
Finding the critical path
Slack = 2 Slack = 2
The difference between EF and LF for a node is the slack for that activity
Finding the critical path
Slack = 2 Slack = 2
4. Repeat
PERT: Probabilistic Time Estimates
a = optimistic estimate
m = most likely time estimate
b = pessimistic time estimate
87
Example Beta Distributions
P (time)
P (time)
m t b a t m b
a
P (time)
a m=t b
88
PERT Example
Equipment testing
and modification
2 6
Final
Equipment Dummy debugging
installation
System
Training
1 3 5 8 9
System Manual System
development Testing changeover
System
Testing
Job Dummy
Position training
recruiting
Orientation
4 7
89
Activity Information
Time estimates (wks) Mean Time Variance
Activity a m b t s2
1-2 6 8 10 8 .44
1-3 3 6 9 6 1.00
1-4 1 3 5 3 .44
2-5 0 0 0 0 .00
2-6 2 4 12 5 2.78
3-5 2 3 4 3 .11
4-5 3 4 5 4 .11
4-7 2 2 2 2 .00
5-8 3 7 11 7 1.78
5-7 2 4 6 4 .44
7-8 0 0 0 0 .00
6-9 1 4 7 4 1.00
8-9 1 10 13 9 4.00
90
PERT Example
Equipment testing
and modification
2 6
5
Final
Equipment Dummy debugging
installation 0 4
8
System
6 3 Training 9
1 3 5 8 9
System Manual 7 System
development Testing changeover
System
Testing
Job 4 0 Dummy
Position 3 4
training
recruiting
Orientation
4 7
2
91
Early And Late Times
Activity t s2 ES EF LS LF S
1-2 8 0.44 0 8 1 9 1
1-3 6 1.00 0 6 0 6 0
1-4 3 0.44 0 3 2 5 2
2-5 0 0.00 8 8 9 9 1
2-6 5 2.78 8 13 16 21 8
3-5 3 0.11 6 9 6 9 0
4-5 4 0.11 3 7 5 9 2
4-7 2 0.00 3 5 14 16 11
5-8 7 1.78 9 16 9 16 0
5-7 4 0.44 9 13 12 16 3
7-8 0 0.00 13 13 16 16 3
6-9 4 1.00 13 17 21 25 8
8-9 9 4.00 16 25 16 25 0 92
Graph With Times
ES=8, EF=13
( LS=16 LF=21 )
ES=0, EF=8 2 5
6
ES=13, EF=17
( LS=1, LF=9 ) ES=8, EF=8 ( LS=21 LF=25 )
8
0
( LS=9, LF=9 ) 4
s2 = s2 13 + s2 35 + s2 58 + s2 89
= 6.89 weeks
94
Probabilistic Analysis
95
Normal Distribution Of Project Time
X ~ N (m ,s 2 ) Probability
xm
z
s
Zs
m = tp x Time
96
Standard Normal Distribution Of
transformed Project Time
Probability
Z ~ N (0,1 )
m =0 z Time
97
Probabilistic Analysis Example
98
Determining Probability
From Z Value
= 0.9719
m = 25 x = 30 Time (weeks)
99
Probabilistic Analysis Example