VL_BFGS minimizer doesn't like HPSpace and LMSpace
The VL_BFGS minimizer has problems with the minimization of HPSpace and LMSpace. If we take a quadratic potential
`
np.random.seed(0)
N_dim = 500
#x_space = HPSpace(N_dim)
x_space = LMSpace(N_dim)
x = Field(x_space, val=np.random.rand(N_dim))
N = DiagonalOperator(x_space, diagonal = 1.)
class QuadraticPot(Energy):
def __init__(self, position, N):
super(QuadraticPot, self).__init__(position)
self.N = N
def at(self, position):
return self.__class__(position, N = self.N)
@property
def value(self):
H = 0.5 *self.position.dot(self.N.inverse_times(self.position))
return H.real
@property
def gradient(self):
g = self.N.inverse_times(self.position)
return_g = g.copy_empty(dtype=np.float)
return_g.val = g.val.real
return return_g
@property
def curvature(self):
return self.N
minimizer = VL_BFGS(iteration_limit=1000,convergence_tolerance=1E-4, convergence_level=3)
energy = QuadraticPot(position=x , N=N)
print energy.value
(energy, convergence) = minimizer(energy)
print energy.value
`
it doesn't converge to 0. For an example in this case above, the energy of the system is only reduced to a half of the starting energy. I think I'm lacking a piece of knowledge to understand this problem.