Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ANO
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
Arthur Mady
ANO
Commits
83804248
Commit
83804248
authored
4 months ago
by
ARTHUR MADY
Browse files
Options
Downloads
Patches
Plain Diff
TP4
parent
c56fda0d
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tp4/graphe.py
+45
-1
45 additions, 1 deletion
tp4/graphe.py
with
45 additions
and
1 deletion
tp4/graphe.py
+
45
−
1
View file @
83804248
...
...
@@ -50,7 +50,7 @@ Z = c(A,B)
C
=
ax
.
contour
(
A
,
B
,
Z
,
[
0
])
# On retire cette courbe de niveau du graphique final
C
.
remove
()
#
C.remove ()
# On trace la courbe 3D des points du graphe de f qui satisfont la contrainte
for
ii
,
seg
in
enumerate
(
C
.
allsegs
[
0
])
:
...
...
@@ -68,3 +68,47 @@ ax.quiver (a, b, f(a,b), grad_f[0], grad_f[1], 0, color='blue')
plt
.
show
()
#Q1
#f(a,b) + lambda*c(a,b)
#Q2
#Au niveau de n1, on voit que le grand vecteur est perpendiculaire a la courbe de niveau
#Les gds vecteurs sont delta-f, les petits delta-c
#Q3 les gradiants sont parallèles (presque)
#Le minimum local peut être l'un des deux
#En u5, delta-f est dirigé vers l'intérieur du cercle et donc la courbe de niveau en haut du graphique contient le minimum local de la foncton f
#U5 est surement la solution optimale.
#Q4
#Quand on évalue c(a;b) en (a*,b*), on obtient une valeur > 1/2
# Donc (a*,b*) ne satisfait pas la contrainte c(a,b) < 1/2
# Donc la solution optimale du problème d'optimisation avec contrainte se situe sur
#le cercle (pas à l'intérieur)
#Donc la contrainte sera active. On peut la transformer en une contrainte d'égalité
#c(a,b) = 1/2
#Q5 Graphiquement la solution optimale = (a,b) = (1.75, 0.68)
#Q7
def
Lagrangien
(
u
):
a
,
b
,
lmbda
=
u
return
f
(
a
,
b
)
+
lmbda
*
c
(
a
,
b
)
grad_L
=
ag
.
grad
(
Lagrangien
)
H_L
=
ag
.
hessian
(
Lagrangien
)
u
=
np
.
array
([
1.8
,.
9
,
0
],
dtype
=
np
.
float64
)
# a b lambda
for
i
in
range
(
5
):
g
=
grad_L
(
u
)
H
=
H_L
(
u
)
h
=
np
.
linalg
.
solve
(
H
,
-
g
)
u
=
u
+
h
print
(
'
u =
'
,
u
)
print
(
'
gradient du lagrangien =
'
,
g
)
print
(
'
valeurs propres hessienne du lagrangien =
'
,
np
.
linalg
.
eigvalsh
(
H
))
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