High_Light

стоимость банки с чем-либо

Apr 25th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. from numpy import sqrt
  2. from scipy.optimize import minimize
  3. from numpy import pi
  4. V_0 = 200.0
  5.  
  6. z=12
  7. y=15
  8.  
  9. def V(x):
  10.     r,h = x
  11.     v = pi*r*r*h
  12.     return v
  13. def lim1(x):
  14.     return  V(x) - V_0
  15. def lim2(x):
  16.     return min(x)
  17. def S(x):
  18.     r,h = x
  19.     return 2*pi*r*h + 2*pi*r*r
  20. def P(x):
  21.     r,h,y=x
  22.     P=(4*pi*r+h)*y
  23. def Price(x):
  24.     z,r,h,y,S=x
  25.     Pr=(S*z)+((4*pi*r+h)*y)
  26.     return Pr
  27.  
  28. cons = ({'type': 'eq', 'fun': lim1},
  29.         {'type': 'ineq', 'fun': lim2})
  30.  
  31.  
  32. r0 = 5
  33. h0 = V_0/(pi*r0*r0)
  34. x0 = (r0,h0)
  35. sol = minimize(S,x0, constraints = cons)
  36.  
  37. #print sol.x
  38. #print V(sol.x)
  39. print S(sol.x)
  40. #print Price
  41. print P
Advertisement
Add Comment
Please, Sign In to add comment