Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from FuncDesigner import *
- from openopt import NLP
- x, y, z = oovars('x y z', lb=-1, ub=1)
- z.lb = 0
- # dice distribution
- s = discrete(range(1, 7), [1.0/6]*6)
- # values probabilities
- # future plans include:
- # common distributions like gauss, uniform, exponential, etc
- # possibility to use quantiles, e.g. constraint1 = P(sin(a)<0.3)>0.2 (probability of event sin(a)<0.3 must less than 0.2)
- f1 = -2*s * z**2
- f = f1 + 2*x + 3*y
- objective = f.M
- startPoint = {x:0, y:0, z:0.001}
- p = NLP(objective, startPoint, constraints = [f.std < 0.15])
- r = p.solve('scipy_cobyla')
- print(f.std(r))
- '''
- Solver: Time Elapsed = 0.33 CPU Time Elapsed = 0.33
- objFunValue: -5.3074085 (feasible, MaxResidual = 0)
- 0.149999999601
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement