Guest User

Untitled

a guest
Jan 10th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. from scipy.optimize import minimize
  2.  
  3. def objective(x):
  4. return x[1]
  5.  
  6. def constraint(x):
  7. return x[1] - (x[0]**1.5 - 2*x[0] + 3.0) # placeholder for large calculation
  8.  
  9. x0 = [4.0,2.2]
  10.  
  11. b = (0.0,5.0)
  12. bnds = (b,b)
  13.  
  14. cons = [{'type': 'ineq', 'fun':constraint}]
  15.  
  16. sol = minimize(objective, x0, method='SLSQP',bounds=bnds,constraints=cons)
Add Comment
Please, Sign In to add comment