Created
July 23, 2015 17:56
-
-
Save feilong/b1330ed03ad0fd88d1a9 to your computer and use it in GitHub Desktop.
Mathematical optimization w/ Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import numpy as np | |
| from scipy.optimize import minimize | |
| def cost_function(x): | |
| return (x[0]-3)**2 + (x[1]-2)**2 | |
| x0 = [0, 0] # initial guess | |
| method = 'nelder-mead' | |
| res = minimize(cost_function, x0, method=method, | |
| options={'xtol': 1e-8, 'disp': True}) | |
| print res.x |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
http://scipy-lectures.github.io/advanced/mathematical_optimization/