bonjour ,

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from numpy import random
import numpy as np
import matplotlib.pyplot as plt
 
def f(x):
    """Fonction de Rosenbrock a deux variables"""
    return (1-x[0])**2+(x[1]-x[0]**2)**2
 
import numpy as np
import matplotlib.pyplot as plt
import time
x1 , x2 = np.meshgrid(np.linspace(0,2,201),np.linspace(0,2,201))
 
subplot(212)
a=plt.contourf(x1,x2,f([x1,x2]),np.linspace(0,1,21))
# plt.colorbar()
 
import scipy.optimize as op
t1 = time.time()
op.fmin(f,(0.0,0.0))
t2 = time.time() - t1
print 'Temps d\'exécution : '+str(t2*1000)+' milli seconde'
 
solsimplexe = op.fmin(f,(0.0,0.0),retall=1)
"""
Le chemin suivit par l’algorithme est stocké
dans la variable solsimplexe[1]
 """
subplot(211)
plt.title('Graphe avec le simplex');
 
show
Comment introduire la variable solsimplexe[1] pour obtenir
un deuxième graphe avec le tracé du simplex ?

Une piste ou idée ...