Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
is4-ano-2022
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Melissa Larbi
is4-ano-2022
Commits
20bc2030
Commit
20bc2030
authored
2 years ago
by
Melissa LARBI
Browse files
Options
Downloads
Patches
Plain Diff
compte rendu
parent
8e208b78
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tp4/tp4.py
+0
-80
0 additions, 80 deletions
tp4/tp4.py
with
0 additions
and
80 deletions
tp4/tp4.py
deleted
100644 → 0
+
0
−
80
View file @
8e208b78
#partie 01: résolution graphique
# question 01:
# 1_ est ce que le minimum local satisfait la contrainte:
# 0.2255*0.2255 + 0.9312*0.9312 = 0.91 > 0.5
# donc le minimum local ne satisfait pas la contrainte
# à l'optimum la contrainte sera-t-elle active?
# active c'est que la miminum local verifie que g(x)=0 graphiquement on le retrouve sur le cercle de la contrainte
# donc on peut tansformer la contrainte d'inégalité en une égalité
# question 02: sur le fichier graphe.py
# question 03: sur le fichier graphe.py
# partie 02: le calcul du minimum
# question 4: le langrangien du problème:
def
f
(
a
,
b
):
return
a
**
3
+
2
*
a
**
2
-
2
*
a
*
b
+
b
**
2
+
a
*
b
**
3
-
2
*
b
+
5
def
contrainte
(
a
,
b
):
return
a
**
2
+
b
**
2
-
(
1
/
2
)
**
2
def
langrangien
(
u
):
# les variabes de lagrangien sont a, b et lambda
a
,
b
,
lmbda
=
u
[
0
],
u
[
1
],
u
[
2
]
return
f
(
a
,
b
)
-
lmbda
*
contrainte
(
a
,
b
)
# question 05+06+07
# minimiser f sous la contraint revient à chercher les points stationnaires du lagrangien
import
autograd
as
ag
import
numpy
as
np
nable_lagrangie
=
ag
.
grad
(
langrangien
)
Hessienne_lagrangien
=
ag
.
hessian
(
langrangien
)
# point de départ:
a
,
b
,
lmbda
=
0.23
,
0.8
,
0
u
=
np
.
array
([
a
,
b
,
lmbda
],
dtype
=
np
.
float64
)
# résoudre le problème en utilisant l'algorithme de neuton
def
newton
(
u
,
nb_iteration
):
res
=
[]
for
i
in
range
(
nb_iteration
):
res
.
append
(
u
)
H
=
Hessienne_lagrangien
(
u
)
w
=
nable_lagrangie
(
u
)
h
=
np
.
linalg
.
solve
(
-
H
,
w
)
u
=
u
+
h
return
res
print
(
newton
(
u
,
6
)[
-
1
])
# partie 03 : estimation de paramètre pour la fonction logistic
# la correction de cette partie est sur tel
def
fonction
(
x
,
u
):
keppa
=
u
[
0
]
alpha
=
u
[
1
]
rho
=
u
[
2
]
return
keppa
/
(
1
+
np
.
exp
(
alpha
-
rho
*
x
))
nable
=
ag
.
grad
(
fonction
)
Hessienne
=
ag
.
hessian
(
fonction
)
u
=
np
.
array
([
5.163
,
1.188
],
dtype
=
np
.
float64
)
def
newton2
(
u
,
nb_iteration
):
res
=
[]
for
i
in
range
(
nb_iteration
):
res
.
append
(
u
)
H
=
Hessienne_lagrangien
(
u
)
w
=
nable_lagrangie
(
u
)
h
=
np
.
linalg
.
solve
(
-
H
,
w
)
u
=
u
+
h
return
res
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