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 data_row in self.data:
l_row = []
for i, xi in self.xs:
for xij in xi:
for p_j in xrange(0, self.p_dims[i] + 1):
l_row.append(self.poly[p_j](data_row[xij]))
L.append(l_row)
self.L = numpy.array(L, numpy.double)
func_to_minimize = approx_measure(self.L, self.b)
dim = sum(len(xi) * (self.p_dims[i] + 1)
for i, xi in self.xs)))
minimizer = ByCoordOptimizer(func_to_minimize, dim)
# minimizer = Minimizer(func_to_minimize, numpy.array([1.] * dim), AntiGradientMethod)
return minimizer.minimize()