def mixed x0 func rosenbrock 30 80 eps 0000000001 rb Cb 10 10 cons con

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def mixed(x0, func=rosenbrock(30, 2, 80), eps=0.0000000001):
rb = 0.5
Cb = 10
r = 1
C = 10
cons = constraints()
while True:
bar = barier(rb, cons)
pen = penalty(r, cons)
added = lambda x: pen(x) - bar(x)
f = lambda x: func(x) + added(x)
x0 = scipy.optimize.minimize(f, x0, method='CG').x
if abs(added(x0)) <= eps:
return x0
else:
rb = rb / Cb
r = r * C