Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(t):
- (x, y, z, w) = t
- return x * y + z - w
- def specialiser(f, constantes, positions):
- v = [0]*(len(t) + len(constantes))
- for i,c in zip(positions, constantes):
- v[i] = c
- variables_pos = [i for i in range(len(v)) if i not in positions]
- def specialisee(t):
- for i,p in enumerate(variables_pos):
- v[p] = t[i]
- return f(tuple(v))
- return specialisee
- # On specialise f sur x et y (position 0 et 1) aux valeurs 5 et 6
- g = specialiser(f, (5, 6), (0, 1))
- optimise.minimize(g, [12.1, 121.5])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement