def lambda_minimize self returns lambda_k min_value matrix lambda b_q0

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def lambda_minimize(self): # returns (lambda_k, min_value)
L = [] # matrix: ||L*lambda - b_q0|| -> min
for q0, data_row in enumerate(self.data):
l_row = []
for i, n_i in enumerate(self.x_dims):
for j_i in xrange(n_i):
variable = 'x%d%d' % (i + 1, j_i + 1)
for p_j in xrange(0, self.p_dims[i] + 1):
l_row.append(self.poly[p_j](self.data[q0, variable]))
L.append(l_row)
self.L = numpy.array(L, numpy.double)
func_to_minimize = approx_measure(self.L, self.b)
dim = sum((self.x_dims[i] * (self.p_dims[i] + 1)
for i in xrange(len(self.x_dims))))
bycoord = ByCoordOptimizer(func_to_minimize, dim)
# antigrad = Minimizer(func_to_minimize, numpy.array([1.] * dim), AntiGradientMethod)
return bycoord.minimize()